[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/taxy 7a63677 08/42: Add: (taxy-define-key-definer)
From: |
ELPA Syncer |
Subject: |
[elpa] externals/taxy 7a63677 08/42: Add: (taxy-define-key-definer) |
Date: |
Wed, 15 Sep 2021 12:57:27 -0400 (EDT) |
branch: externals/taxy
commit 7a63677cb3388c32ba7b035ab8917f5a288596b1
Author: Adam Porter <adam@alphapapa.net>
Commit: Adam Porter <adam@alphapapa.net>
Add: (taxy-define-key-definer)
---
taxy.el | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/taxy.el b/taxy.el
index b161c3b..3fbbb5d 100644
--- a/taxy.el
+++ b/taxy.el
@@ -263,6 +263,47 @@ KEY is passed to `cl-sort', which see."
(defalias 'taxy-sort* #'taxy-sort-taxys)
+;;;; Defining key functions
+
+;; Utilities to define key functions and helpers in a standard way.
+
+(defmacro taxy-define-key-definer (name variable prefix docstring)
+ "Define a macro NAME that defines a key-function-defining macro.
+The defined macro, having string DOCSTRING, associates the
+defined key functions with their aliases in an alist stored in
+symbol VARIABLE. The defined key functions are named having
+string PREFIX, which will have a hyphen appended to it. The key
+functions take one or more arguments, the first of which is the
+item being tested, bound within the function to `item'."
+ ;; Example docstring:
+
+ ;; "Define a `taxy-org-ql-view' key function by NAME having BODY taking
ARGS.
+ ;; Within BODY, `element' is bound to the `org-element' element
+ ;; being tested.
+
+ ;; Defines a function named `taxy-org-ql--predicate-NAME', and adds
+ ;; an entry to `taxy-org-ql-view-keys' mapping NAME to the new
+ ;; function symbol."
+ (declare (indent defun))
+ ;; I'm not sure why it's necessary to bind the variable in the first
+ ;; level of the expansion here, but double-unquoting the variable in
+ ;; the defined macro's form leaves the second comma in place, which
+ ;; breaks the second expansion, and this works around that.
+ `(let ((variable ',variable))
+ (defvar ,variable nil
+ ,(format "Alist mapping key aliases to key functions defined with `%s'."
+ name))
+ (defmacro ,name (name args &rest body)
+ ,docstring
+ (declare (indent defun)
+ (debug (&define symbolp listp &rest def-form)))
+ (let* ((fn-symbol (intern (format "%s-%s" ,prefix name)))
+ (fn `(lambda (item ,@args)
+ ,@body)))
+ `(progn
+ (fset ',fn-symbol ,fn)
+ (setf (map-elt ,variable ',name) ',fn-symbol))))))
+
;;;; Footer
(provide 'taxy)
- [elpa] externals/taxy 0cda29a 38/42: Add: (taxy-magit-section-define-column-definer) Custom-type, (continued)
- [elpa] externals/taxy 0cda29a 38/42: Add: (taxy-magit-section-define-column-definer) Custom-type, ELPA Syncer, 2021/09/15
- [elpa] externals/taxy a7ff557 33/42: Docs: Document new things, ELPA Syncer, 2021/09/15
- [elpa] externals/taxy 5020b43 31/42: Change: (deffy-goto-form) Bug #50576 is fixed., ELPA Syncer, 2021/09/15
- [elpa] externals/taxy 0826a47 02/42: WIP: taxy-magit-section column/table formatting, ELPA Syncer, 2021/09/15
- [elpa] externals/taxy d456f88 24/42: Add: (deffy-side-window-action), ELPA Syncer, 2021/09/15
- [elpa] externals/taxy 3787f4f 25/42: Fix: (deffy-buffer) Ensure file name, ELPA Syncer, 2021/09/15
- [elpa] externals/taxy 7ecc461 15/42: Fix: (taxy-magit-section-define-column-definer) Use defcustoms, ELPA Syncer, 2021/09/15
- [elpa] externals/taxy 8b7a95a 35/42: Docs: Clarify, ELPA Syncer, 2021/09/15
- [elpa] externals/taxy 2f4d9c3 05/42: Add: (taxy-magit-section-insert-indent-items), ELPA Syncer, 2021/09/15
- [elpa] externals/taxy 9f9cfef 34/42: Docs: Reorder sections, ELPA Syncer, 2021/09/15
- [elpa] externals/taxy 7a63677 08/42: Add: (taxy-define-key-definer),
ELPA Syncer <=
- [elpa] externals/taxy 69872e4 06/42: Docs: Update readme, ELPA Syncer, 2021/09/15
- [elpa] externals/taxy d682c37 13/42: Add: (taxy-make-take-function), ELPA Syncer, 2021/09/15
- [elpa] externals/taxy 8d108ef 18/42: WIP: Rename elispy to deffy, ELPA Syncer, 2021/09/15
- [elpa] externals/taxy 468e9b9 01/42: Meta: Add .dir-locals.el, ELPA Syncer, 2021/09/15
- [elpa] externals/taxy 2430282 20/42: Tidy: Indentation, ELPA Syncer, 2021/09/15
- [elpa] externals/taxy b37dd39 17/42: WIP: Tidy, ELPA Syncer, 2021/09/15
- [elpa] externals/taxy 43b8504 36/42: Docs: Update changelog, ELPA Syncer, 2021/09/15
- [elpa] externals/taxy 16d4e50 23/42: Fix/Tidy: (deffy-buffer), ELPA Syncer, 2021/09/15
- [elpa] externals/taxy 45372f6 27/42: Fix: (taxy-magit-section-format-items) Width, ELPA Syncer, 2021/09/15
- [elpa] externals/taxy 956efdd 37/42: Comment: Update TODO, ELPA Syncer, 2021/09/15