Skip to content

Commit

Permalink
Fix some docs
Browse files Browse the repository at this point in the history
  • Loading branch information
DogLooksGood committed Dec 1, 2024
1 parent 888615a commit b3281d4
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 29 deletions.
8 changes: 4 additions & 4 deletions meow-cheatsheet.el
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,19 @@ Currently `meow-cheatsheet-layout-qwerty', `meow-cheatsheet-layout-dvorak',
(goto-char (point-min))
(when (search-forward tgt nil t)
(let ((x (- (point) (line-beginning-position))))
(backward-delete-char 9)
(delete-char -9)
(insert (concat " " upper " "))
(forward-line 1)
(forward-char x)
(backward-delete-char 9)
(delete-char -9)
(insert (propertize (meow--short-command-name upper-cmd) 'face 'meow-cheatsheet-highlight))
(forward-line 2)
(forward-char x)
(backward-delete-char 9)
(delete-char -9)
(insert (concat " " lower " "))
(forward-line 1)
(forward-char x)
(backward-delete-char 9)
(delete-char -9)
(insert (propertize (meow--short-command-name lower-cmd) 'face 'meow-cheatsheet-highlight)))))))

(defun meow--cheatsheet-render-char-thing-table (&optional key-face)
Expand Down
2 changes: 1 addition & 1 deletion meow-core.el
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ there's no chance for meow to call an init function."
(meow--cancel-second-selection)))

(defun meow--enable-theme-advice (theme)
"Prepare face if the theme to enable is `user'."
"Prepare face if the THEME to enable is `user'."
(when (eq theme 'user)
(meow--prepare-face)))

Expand Down
4 changes: 4 additions & 0 deletions meow-keymap.el
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@

(require 'meow-var)

(declare-function meow-describe-key "meow-command")
(declare-function meow-end-or-call-kmacro "meow-command")
(declare-function meow-end-kmacro "meow-command")

(defvar meow-keymap
(let ((keymap (make-sparse-keymap)))
(define-key keymap [remap describe-key] #'meow-describe-key)
Expand Down
42 changes: 23 additions & 19 deletions meow-keypad.el
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,15 @@

;;; Commentary:
;; Keypad state is a special state to simulate C-x and C-c key sequences.
;; There are three commands:
;;
;; Useful commands:
;;
;; meow-keypad
;; Enter keypad state.
;;
;; meow-keypad-start
;; Enter keypad state, and simulate this key with Control modifier.
;;
;; meow-keypad-self-insert
;; This command is bound to every single key in keypad state.
;; The rules,
;; - If current key is SPC, the next will be considered without modifier.
;; - If current key is m, the next will be considered with Meta modifier.
;; - Other keys, or SPC and m after a prefix, means append a key input, by default, with Control modifier.
;;
;; meow-keypad-undo
;; Remove the last input, if there's no input in the sequence, exit the keypad state.

;;; Code:

(require 'subr-x)
Expand All @@ -43,7 +37,7 @@
(require 'meow-beacon)

(defun meow--keypad-format-upcase (k)
"Return S-k for upcase k."
"Return S-k for upcase K."
(let ((case-fold-search nil))
(if (and (stringp k)
(string-match-p "^[A-Z]$" k))
Expand All @@ -68,13 +62,17 @@
(t "")))

(defun meow--keypad-lookup-key (keys)
"Lookup the command which is bound at KEYS."
(let* ((overriding-local-map meow--keypad-base-keymap)
(keybind (key-binding keys)))
(unless (and (meow--is-self-insertp keybind)
(not meow-keypad-self-insert-undefined))
keybind)))

(defun meow--keypad-has-sub-meta-keymap-p ()
"Check if there's a keymap belongs to Meta prefix.
A key sequences starts with ESC is accessible via Meta key."
(and (not meow--use-literal)
(not meow--use-both)
(not meow--use-meta)
Expand All @@ -85,7 +83,9 @@
(lookup-key keymap ""))))))

(defun meow--keypad-format-keys (&optional prompt)
"Return a display format for current input keys."
"Return a display format for current input keys.
The message is prepended with an optional PROMPT."
(let ((result ""))
(setq result
(thread-first
Expand Down Expand Up @@ -132,6 +132,9 @@
(meow--keypad-quit))

(defun meow--make-keymap-for-describe (keymap control)
"Parse the KEYMAP to make it suitable for describe.
Argument CONTROL, non-nils stands for current input is prefixed with Control."
(let ((km (make-keymap)))
(suppress-keymap km t)
(when (keymapp keymap)
Expand All @@ -146,6 +149,7 @@
km))

(defun meow--keypad-get-keymap-for-describe ()
"Get a keymap for describe."
(let* ((input (thread-first
(mapcar #'meow--keypad-format-key-1 meow--keypad-keys)
(reverse)
Expand Down Expand Up @@ -226,9 +230,11 @@
km)))))))

(defun meow--keypad-clear-message ()
"Clear displayed message by calling `meow-keypad-clear-describe-keymap-function'."
(funcall meow-keypad-clear-describe-keymap-function))

(defun meow--keypad-display-message ()
"Display a message for current input state."
(let (overriding-local-map)
(when meow-keypad-describe-keymap-function
(when (or
Expand Down Expand Up @@ -365,6 +371,7 @@ Returning DEF will result in a generated title."
(meow--keypad-quit)))

(defun meow--keypad-show-message ()
"Show message for current keypad input."
(let ((message-log-max))
(message "KEYPAD%s: %s%s"
(if meow--keypad-help " describe key" "")
Expand All @@ -375,6 +382,7 @@ Returning DEF will result in a generated title."
(propertize (meow--keypad-format-keys nil) 'face 'font-lock-string-face))))

(defun meow--keypad-in-beacon-p ()
"Return whether keypad is started from BEACON state."
(and (meow--beacon-inside-secondary-selection)
meow--beacon-overlays))

Expand Down Expand Up @@ -435,13 +443,15 @@ try replacing the last modifier and try again."
t)))))

(defun meow--keypad-handle-input-with-keymap (input-event)
"Handle INPUT-EVENT with `meow-keypad-state-keymap'."
(let* ((k (kbd (single-key-description input-event)))
(cmd (lookup-key meow-keypad-state-keymap k)))
(if cmd
(call-interactively cmd)
(meow--keypad-handle-input-event input-event))))

(defun meow--keypad-handle-input-event (input-event)
""
(meow--keypad-clear-message)
(when-let* ((key (single-key-description input-event)))
(let ((has-sub-meta (meow--keypad-has-sub-meta-keymap-p)))
Expand Down Expand Up @@ -492,12 +502,6 @@ try replacing the last modifier and try again."
nil)
(meow--keypad-try-execute))))

(defun meow-keypad-self-insert ()
"Default command when keypad state is enabled."
(interactive)
(setq this-command last-command)
(meow--keypad-handle-input-event last-input-event))

(defun meow-keypad ()
"Enter keypad state and convert inputs."
(interactive)
Expand Down
17 changes: 14 additions & 3 deletions meow-shims.el
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ Argument ENABLE non-nil means turn on."
(defvar meow--magit-setup nil)

(defun meow--magit-blame-hook-function ()
"Switch meow state when entering/leaving magit-blame-read-only-mode."
"Switch meow state when entering/leaving `magit-blame-read-only-mode'."
(if (bound-and-true-p magit-blame-read-only-mode)
(meow--switch-to-motion)
(meow--switch-to-normal)))
Expand Down Expand Up @@ -393,6 +393,7 @@ Argument ENABLE non-nil means turn on."
(defvar meow--which-key-setup nil)

(defun meow--which-key-describe-keymap ()
"Use which-key for keypad popup."
(if which-key-mode
(setq meow-keypad-describe-keymap-function
(lambda (keymap)
Expand All @@ -403,6 +404,8 @@ Argument ENABLE non-nil means turn on."
meow-keypad-clear-describe-keymap-function nil)))

(defun meow--setup-which-key (enable)
"Setup which-key.
Argument ENABLE non-nil means turn on."
(setq meow--which-key-setup enable)
(if enable
(add-hook 'which-key-mode-hook 'meow--which-key-describe-keymap)
Expand All @@ -416,10 +419,14 @@ Argument ENABLE non-nil means turn on."
(defun meow--input-method-advice (fnc key)
"Advice for `quail-input-method'.
Only use the input method in insert mode."
Only use the input method in insert mode.
Argument FNC, input method function.
Argument KEY, the current input."
(funcall (if (and (boundp 'meow-mode) meow-mode (not (meow-insert-mode-p))) #'list fnc) key))

(defun meow--setup-input-method (enable)
"Setup input-method.
Argument ENABLE non-nil means turn on."
(setq meow--input-method-setup enable)
(if enable
(advice-add 'quail-input-method :around 'meow--input-method-advice)
Expand Down Expand Up @@ -482,11 +489,13 @@ Argument ENABLE non-nil means turn on."
(declare-function eat-eshell-semi-char-mode "eat")
(declare-function eat-eshell-char-mode "eat")

(declare-function meow-insert-mode "meow-core")

(defun meow--eat-eshell-mode-override-enable ()
(setq-local meow--eat-eshell-mode-override t)
(add-hook 'meow-insert-enter-hook #'eat-eshell-char-mode nil t)
(add-hook 'meow-insert-exit-hook #'eat-eshell-emacs-mode nil t)
(if meow-insert-mode
(if (bound-and-true-p meow-insert-mode)
(eat-eshell-char-mode)
(eat-eshell-emacs-mode)))

Expand All @@ -511,6 +520,8 @@ Argument ENABLE non-nil means turn on."
(defvar meow--ediff-setup nil)

(defun meow--setup-ediff (enable)
"Setup Ediff.
Argument ENABLE, non-nil means turn on."
(if enable
(add-hook 'ediff-mode-hook 'meow-motion-mode)
(remove-hook 'ediff-mode-hook 'meow-motion-mode)))
Expand Down
5 changes: 3 additions & 2 deletions meow-var.el
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@ This doesn't affect how keypad works on recording or executing a kmacro."
Each item is a (THING FORWARD_SYNTAX_TO_INCLUDE BACKWARD-SYNTAX_TO_INCLUDE)."
:group 'meow
:type '(list :key-type (symbol :tag "Thing")
:value-type (list string)))
:type '(repeat (list (symbol :tag "Thing")
(string :tag "Forward Syntax")
(string :tag "Backward Syntax"))))

(defcustom meow-expand-hint-counts
'((word . 30)
Expand Down

0 comments on commit b3281d4

Please sign in to comment.