|
| 1 | +;;; meow-use-package.el --- use-package keywords for Meow -*- lexical-binding: t; -*- |
| 2 | + |
| 3 | +;; This file is not part of GNU Emacs. |
| 4 | + |
| 5 | +;; This program is free software; you can redistribute it and/or |
| 6 | +;; modify it under the terms of the GNU General Public License |
| 7 | +;; as published by the Free Software Foundation; either version 3 |
| 8 | +;; of the License, or (at your option) any later version. |
| 9 | + |
| 10 | +;; This program is distributed in the hope that it will be useful, |
| 11 | +;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | +;; GNU General Public License for more details. |
| 14 | + |
| 15 | +;; You should have received a copy of the GNU General Public License |
| 16 | +;; along with GNU Emacs; see the file COPYING. If not, write to the |
| 17 | +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 | +;; Boston, MA 02110-1301, USA. |
| 19 | + |
| 20 | +;;; Commentary: |
| 21 | +;; Add keywords to be used in `use-package' declarations. |
| 22 | +;; - :meow-state |
| 23 | +;; Can be used to populate `meow-mode-state-list' in the same manner as |
| 24 | +;; setting up hooks with the :hook keyword. For example: |
| 25 | + |
| 26 | +;; (use-package sly |
| 27 | +;; :meow-state ((sly-inspector-mode . motion) |
| 28 | +;; (sly-db-mode . motion))) |
| 29 | + |
| 30 | +;; The above would make the `sly-inspector' and `sly-db' modes start in Meow's |
| 31 | +;; motion state. |
| 32 | + |
| 33 | +;;; Code: |
| 34 | + |
| 35 | +(require 'cl) |
| 36 | +(require 'use-package) |
| 37 | + |
| 38 | +;;;; :meow-state keyword |
| 39 | + |
| 40 | +(add-to-list 'use-package-keywords ':meow-state 'append) |
| 41 | + |
| 42 | +;; We re-use the normalize method from :hook. This way we get the parsing of |
| 43 | +;; both a single cons, and a list of several. |
| 44 | +(defalias 'use-package-normalize/:meow-state #'use-package-normalize/:hook) |
| 45 | + |
| 46 | +(defun use-package-handler/:meow-state (name-symbol keyword args rest state) |
| 47 | + (use-package-concat |
| 48 | + (use-package-process-keywords name-symbol rest state) |
| 49 | + `(,@(cl-loop for arg in args |
| 50 | + collect `(add-to-list 'meow-mode-state-list (quote ,arg)))))) |
| 51 | + |
| 52 | +(provide 'meow-use-package) |
| 53 | +;;; meow-use-package.el ends here |
0 commit comments