[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] scratch/hook-helpers 17f7d5d 07/19: Restored docstring argument i
From: |
Ian Dunn |
Subject: |
[elpa] scratch/hook-helpers 17f7d5d 07/19: Restored docstring argument in `define-hook-helper'. |
Date: |
Sun, 23 Apr 2017 12:50:39 -0400 (EDT) |
branch: scratch/hook-helpers
commit 17f7d5d92d817641f6341676f6fd319cae2c21cf
Author: Ian Dunn <address@hidden>
Commit: Ian Dunn <address@hidden>
Restored docstring argument in `define-hook-helper'.
* hook-helpers.el (define-hook-helper): Restored docstring argument.
---
hook-helpers.el | 42 +++++++++++++++++++++++++++---------------
1 file changed, 27 insertions(+), 15 deletions(-)
diff --git a/hook-helpers.el b/hook-helpers.el
index 1cbd268..85df095 100644
--- a/hook-helpers.el
+++ b/hook-helpers.el
@@ -43,7 +43,7 @@
(defconst hook-helper--helper-prefix "hook-helper")
;;;###autoload
-(cl-defmacro define-hook-helper (hook args &rest body &key name append (suffix
"hook") &allow-other-keys)
+(defmacro define-hook-helper (hook args &optional docstring &rest body)
"Define a hook helper for the variable HOOK-hook with ARGS as the argument
list.
This helper consists of all the code in BODY. HOOK should not be
@@ -61,18 +61,31 @@ quoted. The keywords are:
‘-function’. SUFFIX should be a string, and defaults to ‘hook’
if not specified. Note that SUFFIX is not assumed to start with
a hyphen."
- (declare (indent defun))
- ;; From package.el - remove the keys from BODY
- (while (keywordp (car body))
- (setq body (cddr body)))
- (let ((func-sym (intern (format "%s--%s%s" hook-helper--helper-prefix
(symbol-name hook) (if name (concat "/" (symbol-name name)) "")))))
- `(progn
- (defun ,func-sym ,args
- ,(format "Function to run for %s-%s" (symbol-name hook) suffix)
- ,@body)
- (add-hook (quote ,(intern (concat (symbol-name hook) "-" suffix)))
- (function ,func-sym)
- ,append))))
+ (declare (indent defun) (doc-string 3))
+ ;; From `define-derived-mode'
+ (when (and docstring (not (stringp docstring)))
+ ;; Some trickiness, since what appears to be the docstring may really be
+ ;; the first element of the body.
+ (push docstring body)
+ (setq docstring nil))
+ ;; Process the key words
+ (let ((name nil)
+ (append nil)
+ (suffix "hook"))
+ (while (keywordp (car body))
+ (pcase (pop body)
+ (`:name (setq name (pop body)))
+ (`:append (setq append (pop body)))
+ (`:suffix (setq suffix (pop body)))
+ (_ (pop body))))
+ (let ((func-sym (intern (format "%s--%s%s" hook-helper--helper-prefix
(symbol-name hook) (if name (concat "/" (symbol-name name)) "")))))
+ `(progn
+ (defun ,func-sym ,args
+ ,(format "Function to run for %s-%s" (symbol-name hook) suffix)
+ ,@body)
+ (add-hook (quote ,(intern (concat (symbol-name hook) "-" suffix)))
+ (function ,func-sym)
+ ,append)))))
;;;###autoload
(defmacro define-mode-hook-helper (mode args &rest body)
@@ -81,7 +94,7 @@ quoted. The keywords are:
The suffix \"-mode\" is added to MODE before passing it to
‘define-hook-helper’.
-BODY is passed verbatim to ‘define-hook-helper’, so all allowed
+ARGS and BODY are passed verbatim to ‘define-hook-helper’, so all allowed
keys for that macro are allowed here."
(declare (indent defun))
`(define-hook-helper ,(intern (format "%s-mode" mode)) ,args ,@body))
@@ -101,7 +114,6 @@ keys for that macro are allowed here."
NAME and SUFFIX are exactly as in ‘define-hook-helper’, and can
be used to find the exact helper to remove."
- (declare (indent 1))
(let ((func-sym (intern (format "%s--%s%s" hook-helper--helper-prefix
(symbol-name hook) (if name (concat "/" (symbol-name name)) "")))))
`(remove-hook (quote ,(intern (concat (symbol-name hook) "-" suffix)))
(function ,func-sym))))
- [elpa] branch scratch/hook-helpers created (now 365d8de), Ian Dunn, 2017/04/23
- [elpa] scratch/hook-helpers 597fce1 03/19: Updated README to include savannah project link., Ian Dunn, 2017/04/23
- [elpa] scratch/hook-helpers 7981caf 06/19: Removed docstring argument from `hook-helpers'., Ian Dunn, 2017/04/23
- [elpa] scratch/hook-helpers 17f7d5d 07/19: Restored docstring argument in `define-hook-helper'.,
Ian Dunn <=
- [elpa] scratch/hook-helpers b373c79 08/19: Removed define-mode-hook-helpers, since it only moves the word "mode" around., Ian Dunn, 2017/04/23
- [elpa] scratch/hook-helpers f1409ec 05/19: Updated README to include new usage., Ian Dunn, 2017/04/23
- [elpa] scratch/hook-helpers 73d0cb5 13/19: Added gitignore file, Ian Dunn, 2017/04/23
- [elpa] scratch/hook-helpers e253e03 11/19: Implemented new design for anonymous helpers, Ian Dunn, 2017/04/23
- [elpa] scratch/hook-helpers 5e4a3a8 02/19: Added remove-hook-helper to README., Ian Dunn, 2017/04/23
- [elpa] scratch/hook-helpers 706af98 15/19: Clean up describe-hook-helpers, Ian Dunn, 2017/04/23
- [elpa] scratch/hook-helpers 3bb2282 09/19: Updated README, removing define-mode-hook-helper., Ian Dunn, 2017/04/23
- [elpa] scratch/hook-helpers 7f1eccf 16/19: Fixed bug in hkhlp-normalize-hook-spec, Ian Dunn, 2017/04/23
- [elpa] scratch/hook-helpers 0386e23 04/19: Modified define-hook-helper to more closely match defun., Ian Dunn, 2017/04/23
- [elpa] scratch/hook-helpers 0fc0b3d 14/19: Fixed bug in define-hook-helper, Ian Dunn, 2017/04/23