Skip to content

Commit

Permalink
Add :meow-state keyword for use-package declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
Olivia5k committed Oct 16, 2022
1 parent d180d47 commit 618c71a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
15 changes: 15 additions & 0 deletions CUSTOMIZATIONS.org
Original file line number Diff line number Diff line change
Expand Up @@ -358,3 +358,18 @@ change the variable =meow-cursor-type-insert=.

Association list of symbols to their corresponding keymaps. Used
to generate =meow-*-define-key= helpers.

* Integration to other packages
** :meow-state use-package keyword

Simple keyword ~:meow-state~ added to [[https://github.com/jwiegley/use-package][use-package]] declarations. Used to help
populate ~meow-mode-state-list~, as follows:

#+begin_src emacs-lisp
(use-package sly
:meow-state ((sly-inspector-mode . motion)
(sly-db-mode . motion)))
#+end_src

The above would make the ~sly-inspector~ and ~sly-db~ modes start in Meow's
~motion~ state.
15 changes: 15 additions & 0 deletions meow-shims.el
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,21 @@ 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))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; use-package

(when (fboundp #'use-package)
(add-to-list 'use-package-keywords ':meow-state 'append)
;; We re-use the normalize method from :hook. This way we get the parsing of
;; both a single cons, and a list of several.
(defalias 'use-package-normalize/:meow-state #'use-package-normalize/:hook)

(defun use-package-handler/:meow-state (name-symbol keyword args rest state)
(use-package-concat
(use-package-process-keywords name-symbol rest state)
`(,@(cl-loop for arg in args
collect `(add-to-list 'meow-mode-state-list ',arg))))))

;; Enable / Disable shims

(defun meow--enable-shims ()
Expand Down

0 comments on commit 618c71a

Please sign in to comment.