Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

51 lines (41 sloc) 1.657 kb
(defun dss/-get-hook-funcs (hook)
(delq nil (mapcar
(lambda (e) (if (symbolp e) e))
hook)))
(defun dss/-get-hook-funcs-names (hook)
(mapcar 'symbol-name
(dss/-get-hook-funcs
(if (symbolp hook)
(symbol-value hook)
hook))))
(defun dss/-get-all-hooks ()
(let (hlist (list))
(mapatoms (lambda (a)
(if (and (not (null (string-match ".*-hook"
(symbol-name a))))
(not (functionp a)))
(add-to-list 'hlist a))))
hlist))
;;; mapatoms (symbolp x) (functionp x) (commandp (symbol-function x)) (fbound x)
;;; also see http://stackoverflow.com/questions/605785/how-do-i-get-a-list-of-emacs-lisp-non-interactive-functions
(defun dss/remove-from-hook (hook fname &optional local)
(interactive
(let ((hook (intern (ido-completing-read
"Which hook? "
(mapcar #'symbol-name (dss/-get-all-hooks))))))
(list hook
(ido-completing-read "Which? " (dss/-get-hook-funcs-names hook)))))
(remove-hook hook
(if (stringp fname)
(intern fname)
fname)
local))
(defun dss/remove-after-save-hook (fname)
(interactive (list (ido-completing-read
"Which? "
(dss/-get-hook-funcs-names after-save-hook))))
(dss/remove-from-hook 'after-save-hook fname t))
(defun dss/add-after-save-hook (fname)
(interactive "aWhich function: ")
(add-hook 'after-save-hook fname t t))
(provide 'dss-hook-management)
Jump to Line
Something went wrong with that request. Please try again.