[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] scratch/hook-helpers 0386e23 04/19: Modified define-hook-helper t
From: |
Ian Dunn |
Subject: |
[elpa] scratch/hook-helpers 0386e23 04/19: Modified define-hook-helper to more closely match defun. |
Date: |
Sun, 23 Apr 2017 12:50:38 -0400 (EDT) |
branch: scratch/hook-helpers
commit 0386e23bd5a14e37db00e8c970d8f4424af0caa7
Author: Ian Dunn <address@hidden>
Commit: Ian Dunn <address@hidden>
Modified define-hook-helper to more closely match defun.
* hook-helpers.el (define-hook-helper):
(define-mode-hook-helper): Modify to more closely match defun.
---
hook-helpers.el | 26 ++++++++------------------
1 file changed, 8 insertions(+), 18 deletions(-)
diff --git a/hook-helpers.el b/hook-helpers.el
index a9bc425..7c83545 100644
--- a/hook-helpers.el
+++ b/hook-helpers.el
@@ -37,16 +37,14 @@
;; TODO:
;; - List hook helpers? Is this useful to anyone?
-;; - Would it be more useful to specify ‘args’ as an argument, identical to the
-;; way a normal defun is defined? It's not used that often.
;;; Code:
(defconst hook-helper--helper-prefix "hook-helper")
;;;###autoload
-(cl-defmacro define-hook-helper (hook &rest body &key name append args (suffix
"hook") &allow-other-keys)
- "Define a hook helper for the variable HOOK-hook.
+(cl-defmacro define-hook-helper (hook args &optional docstring &rest body &key
name append (suffix "hook") &allow-other-keys)
+ "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
quoted. The keywords are:
@@ -58,17 +56,12 @@ quoted. The keywords are:
:append If non-nil, append the hook helper to the hook variable.
-:args Should be a list to pass as the arguments of the new
- function. ARGS is not a list of variables, but symbols
- that become the names of the arguments. As such, this
- can be any form allowed as an argument list.
-
:suffix Allows a user to specify that the hook variable doesn't
end with ‘-hook’, but instead with another suffix, such as
‘-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 1))
+ (declare (indent defun) (doc-string 3))
;; From package.el - remove the keys from BODY
(while (keywordp (car body))
(setq body (cddr body)))
@@ -81,10 +74,8 @@ quoted. The keywords are:
(function ,func-sym)
,append))))
-(put 'define-hook-helper 'lisp-indent-function 'defun)
-
;;;###autoload
-(defmacro define-mode-hook-helper (mode &rest body)
+(defmacro define-mode-hook-helper (mode args &optional docstring &rest body)
"Define hook helper for MODE.
The suffix \"-mode\" is added to MODE before passing it to
@@ -92,7 +83,7 @@ The suffix \"-mode\" is added to MODE before passing it to
BODY is passed verbatim to ‘define-hook-helper’, so all allowed
keys for that macro are allowed here."
- (declare (indent 1))
+ (declare (indent defun) (doc-string 3))
`(define-hook-helper ,(intern (format "%s-mode" mode)) ,@body))
;; Add font lock for both macros.
@@ -100,12 +91,10 @@ keys for that macro are allowed here."
'emacs-lisp-mode
'(("(\\(define-hook-helper\\)\\_>[ \t]*\\(\\(?:\\sw\\|\\s_\\)+\\)?"
(1 font-lock-keyword-face)
- (2 font-lock-constant-face nil t))
+ (2 font-lock-function-name-face))
("(\\(define-mode-hook-helper\\)\\_>[ \t]*\\(\\(?:\\sw\\|\\s_\\)+\\)?"
(1 font-lock-keyword-face)
- (2 font-lock-constant-face nil t))))
-
-(put 'define-mode-hook-helper 'lisp-indent-function 'defun)
+ (2 font-lock-function-name-face))))
(cl-defmacro remove-hook-helper (hook &key name (suffix "hook"))
"Remove a hook helper from HOOK-hook.
@@ -115,6 +104,7 @@ 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))))
+
(provide 'hook-helpers)
;;; hook-helpers.el ends here
- [elpa] scratch/hook-helpers 7981caf 06/19: Removed docstring argument from `hook-helpers'., (continued)
- [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, 2017/04/23
- [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 <=
- [elpa] scratch/hook-helpers 0fc0b3d 14/19: Fixed bug in define-hook-helper, Ian Dunn, 2017/04/23
- [elpa] scratch/hook-helpers dff9910 10/19: Added `define-hook-function' to allow defining a function to be added to multiple hooks., Ian Dunn, 2017/04/23
- [elpa] scratch/hook-helpers a46803b 17/19: Fixed failing tests, Ian Dunn, 2017/04/23
- [elpa] scratch/hook-helpers 93ae501 12/19: Finished last commit., Ian Dunn, 2017/04/23
- [elpa] scratch/hook-helpers 7970dcf 01/19: Initial commit., Ian Dunn, 2017/04/23
- [elpa] scratch/hook-helpers ff95f49 18/19: Preparations to push to ELPA, Ian Dunn, 2017/04/23
- [elpa] scratch/hook-helpers 365d8de 19/19: Add 'packages/hook-helpers/' from commit 'ff95f4944f3d6d1a43aca141cb7fa36a9043704d', Ian Dunn, 2017/04/23