Skip to content

Commit

Permalink
Merge branch 'meow-edit:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
jidibinlin authored Nov 29, 2024
2 parents 2dd81e7 + dd79ccc commit 4beb60a
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 41 deletions.
15 changes: 7 additions & 8 deletions CUSTOMIZATIONS.org
Original file line number Diff line number Diff line change
Expand Up @@ -112,22 +112,21 @@ see the documentation for the internal function =meow-register-state=.
Default:

#+begin_src emacs-lisp
((fundamental-mode . normal)
(text-mode . normal)
((conf-mode . normal)
(fundamental-mode . normal)
(help-mode . motion)
(prog-mode . normal)
(conf-mode . normal)
(json-mode . normal)
...)
(text-mode . normal))
#+end_src

A list of rules to specify the initial Meow state for major mode.
A list of rules: each of which specifies the initial Meow state for a major mode.

Value should be a list, each item is ~(major-mode . init-state)~.
The ~init-state~ can be any state, including custom ones.

By default, Meow will use ~motion~ for special modes (in which none of
By default, Meow uses ~motion~ for special modes (in which none of
the alphabet keys trigger a `self-insert` command), and ~normal~ for
other modes.
other modes. The default value aims to be general, minimal and sensible.

** meow-expand-exclude-mode-list

Expand Down
10 changes: 9 additions & 1 deletion GET_STARTED.org
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,22 @@ You can write your own setup function from scratch or pick one from below as you
- [[file:KEYBINDING_COLEMAK.org][Colemak layout]]

* Enable meow globally
Add the following code to your configuration.
Add the following code to your configuration, assuming that your function to set
up bindings is called ~meow-setup~:
#+begin_src emacs-lisp
<define your meow-setup>
(require 'meow)
(meow-setup)
(meow-global-mode 1)
#+end_src

NOTE: You don't need to do this if you use the [[https://github.com/meow-edit/doom-meow][Doom module]], as it takes care of
loading and enabling Meow. In addition the module defines ~+meow--setup-*~
functions for all the example layouts included here, so that passing the
corresponding module flag is enough to set up those layouts. (If you want to use
a custom layout, you will need to define your own setup function and call it in
your configuration.)

* Tutorial in Emacs
Now you can open the tutorial with ~M-x meow-tutor~.

Expand Down
19 changes: 18 additions & 1 deletion meow-keypad.el
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
(require 'meow-var)
(require 'meow-util)
(require 'meow-helpers)
(require 'meow-beacon)

(defun meow--keypad-format-upcase (k)
"Return S-k for upcase k."
Expand Down Expand Up @@ -367,6 +368,22 @@ Returning DEF will result in a generated title."
(propertize pre 'face 'font-lock-comment-face)))
(propertize (meow--keypad-format-keys nil) 'face 'font-lock-string-face))))

(defun meow--keypad-execute (command)
"Execute the COMMAND.
If there are beacons, execute it at every beacon."
(cond
((and meow-keypad-execute-on-beacons
(not defining-kbd-macro)
(not executing-kbd-macro)
(meow--beacon-inside-secondary-selection)
meow--beacon-overlays)
(call-interactively command)
(meow--beacon-apply-command command))

(t
(call-interactively command))))

(defun meow--keypad-try-execute ()
"Try execute command.
Expand All @@ -389,7 +406,7 @@ try replacing the last modifier and try again."
(meow--keypad-quit)
(setq real-this-command cmd
this-command cmd)
(call-interactively cmd))))
(meow--keypad-execute cmd))))
((keymapp cmd)
(when meow-keypad-message (meow--keypad-show-message))
(meow--keypad-display-message))
Expand Down
73 changes: 71 additions & 2 deletions meow-shims.el
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,26 @@ Argument ENABLE non-nil means turn on."
(add-hook 'meow-insert-exit-hook #'meow--company-maybe-abort-advice)
(remove-hook 'meow-insert-exit-hook #'meow--company-maybe-abort-advice)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; corfu

(declare-function corfu-quit "corfu")

(defvar meow--corfu-setup nil
"Whether already setup corfu.")

(defun meow--corfu-maybe-abort-advice ()
"Adviced for `meow-insert-exit'."
(when (bound-and-true-p corfu-mode) (corfu-quit)))

(defun meow--setup-corfu (enable)
"Setup for corfu.
Argument ENABLE non-nil means turn on."
(setq meow--corfu-setup enable)
(if enable
(add-hook 'meow-insert-exit-hook #'meow--corfu-maybe-abort-advice)
(remove-hook 'meow-insert-exit-hook #'meow--corfu-maybe-abort-advice)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; repeat-map

Expand Down Expand Up @@ -449,6 +469,49 @@ Argument ENABLE non-nil means turn on."
;; These vars allow us the select through the polymode chunk
(add-to-list 'polymode-move-these-vars-from-old-buffer v))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; eat-eshell

(defvar meow--eat-eshell-setup nil)
(defvar meow--eat-eshell-mode-override nil)

(declare-function eat-eshell-emacs-mode "eat")
(declare-function eat-eshell-semi-char-mode "eat")
(declare-function eat-eshell-char-mode "eat")

(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
(eat-eshell-char-mode)
(eat-eshell-emacs-mode)))

(defun meow--eat-eshell-mode-override-disable ()
(setq-local meow--eat-eshell-mode-override nil)
(remove-hook 'meow-insert-enter-hook #'eat-eshell-char-mode t)
(remove-hook 'meow-insert-exit-hook #'eat-eshell-emacs-mode t))

(defun meow--setup-eat-eshell (enable)
(setq meow--eat-eshell-setup enable)
(if enable
(progn (add-hook 'eat-eshell-exec-hook #'meow--eat-eshell-mode-override-enable)
(add-hook 'eat-eshell-exit-hook #'meow--eat-eshell-mode-override-disable)
(add-hook 'eat-eshell-exit-hook #'meow--update-cursor))

(remove-hook 'eat-eshell-exec-hook #'meow--eat-eshell-mode-override-enable)
(remove-hook 'eat-eshell-exit-hook #'meow--eat-eshell-mode-override-disable)
(remove-hook 'eat-eshell-exit-hook #'meow--update-cursor)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Ediff
(defvar meow--ediff-setup nil)

(defun meow--setup-ediff (enable)
(if enable
(add-hook 'ediff-mode-hook 'meow-motion-mode)
(remove-hook 'ediff-mode-hook 'meow-motion-mode)))

;; Enable / Disable shims

(defun meow--enable-shims ()
Expand All @@ -466,6 +529,7 @@ Argument ENABLE non-nil means turn on."
(eval-after-load "magit" (lambda () (meow--setup-magit t)))
(eval-after-load "wgrep" (lambda () (meow--setup-wgrep t)))
(eval-after-load "company" (lambda () (meow--setup-company t)))
(eval-after-load "corfu" (lambda () (meow--setup-corfu t)))
(eval-after-load "polymode" (lambda () (meow--setup-polymode t)))
(eval-after-load "cider" (lambda () (meow--setup-cider t)))
(eval-after-load "sly" (lambda () (meow--setup-sly t)))
Expand All @@ -474,7 +538,9 @@ Argument ENABLE non-nil means turn on."
(eval-after-load "undo-tree" (lambda () (meow--setup-undo-tree t)))
(eval-after-load "diff-hl" (lambda () (meow--setup-diff-hl t)))
(eval-after-load "quail" (lambda () (meow--setup-input-method t)))
(eval-after-load "skk" (lambda () (meow--setup-ddskk t))))
(eval-after-load "skk" (lambda () (meow--setup-ddskk t)))
(eval-after-load "eat" (lambda () (meow--setup-eat-eshell t)))
(eval-after-load "ediff" (lambda () (meow--setup-ediff t))))

(defun meow--disable-shims ()
"Remove shim setups."
Expand All @@ -486,13 +552,16 @@ Argument ENABLE non-nil means turn on."
(when meow--edebug-setup (meow--setup-edebug nil))
(when meow--magit-setup (meow--setup-magit nil))
(when meow--company-setup (meow--setup-company nil))
(when meow--corfu-setup (meow--setup-corfu nil))
(when meow--wgrep-setup (meow--setup-wgrep nil))
(when meow--polymode-setup (meow--setup-polymode nil))
(when meow--cider-setup (meow--setup-cider nil))
(when meow--which-key-setup (meow--setup-which-key nil))
(when meow--diff-hl-setup (meow--setup-diff-hl nil))
(when meow--input-method-setup (meow--setup-input-method nil))
(when meow--ddskk-setup (meow--setup-ddskk nil)))
(when meow--ddskk-setup (meow--setup-ddskk nil))
(when meow--eat-eshell-setup (meow--setup-eat-eshell nil))
(when meow--ediff-setup (meow--setup-ediff nil)))

;;; meow-shims.el ends here
(provide 'meow-shims)
2 changes: 1 addition & 1 deletion meow-tutor.el
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@
[| \"1\" |] [| \"2\" |] [| \"3\" |]
1. Move the cursor to the line below marked -->
2. Select the whole line (you know how to do this)
2. Select the \"1 2 3\"
3. Press \\[meow-grab] to grab the selection
4. Press \\[meow-back-word] to create fake cursors at the beginning of each word
in the backwards direction.
Expand Down
40 changes: 12 additions & 28 deletions meow-var.el
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ This will affect how selection is displayed."
:group 'meow
:type '(repeat sexp))

(defcustom meow-keypad-execute-on-beacons nil
"Execute keypad command directly on beacons when using it directly from
beacon state.
This doesn't affect how keypad works on recording or executing a kmacro."
:group 'meow
:type 'boolean)

(defcustom meow-selection-command-fallback
'((meow-change . meow-change-char)
(meow-kill . meow-C-k)
Expand Down Expand Up @@ -231,35 +239,11 @@ This option will affect the color of position hint and fake region cursor."
:type 'boolean)

(defcustom meow-mode-state-list
'((authinfo-mode . normal)
(beancount-mode . normal)
(bibtex-mode . normal)
(cider-repl-mode . normal)
(cider-test-report-mode . normal)
(cider-browse-spec-view-mode . motion)
(cargo-process-mode . motion)
(conf-mode . normal)
(deadgrep-edit-mode . normal)
(deft-mode . normal)
(diff-mode . normal)
(ediff-mode . motion)
(gud-mode . normal)
(haskell-interactive-mode . normal)
(help-mode . normal)
(helpful-mode . normal)
(json-mode . normal)
(jupyter-repl-mode . normal)
(mix-mode . normal)
(occur-edit-mode . normal)
(pass-view-mode . normal)
'((conf-mode . normal)
(fundamental-mode . normal)
(help-mode . motion)
(prog-mode . normal)
(py-shell-mode . normal)
(restclient-mode . normal)
(telega-chat-mode . normal)
(term-mode . normal)
(text-mode . normal)
(vterm-mode . normal)
(Custom-mode . normal))
(text-mode . normal))
"A list of rules, each is (major-mode . init-state).
The init-state can be any state, including custom ones."
Expand Down

0 comments on commit 4beb60a

Please sign in to comment.