Created
September 17, 2013 01:57
-
-
Save porterjamesj/6589173 to your computer and use it in GitHub Desktop.
two macros that both produce the correct result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; needed for both | |
(defun venv--gen-fun (command) | |
`(defun ,(intern (format "pcomplete/eshell-mode/%s" command)) () | |
(pcomplete-here* (venv-get-candidates)))) | |
;; with the common lisp loop macro | |
(defmacro venv--make-pcompletions (commands) | |
`(progn ,@(loop for item in commands | |
collect (venv--gen-fun item)))) | |
;; with dash.el's map | |
(defmacro venv--make-pcompletions (commands) | |
`(progn ,@(-map #'venv--gen-fun commands))) | |
;; Note that they both need to be called as follows: | |
;; (venv--make-pcompletions ("stuff" "to" "complete")) | |
;; | |
;; They can work with a symbol being passed as well, | |
;; but this requires wrapping `commands' in a call to | |
;; `symbol-value' where it is used, as follows: | |
;; (defmacro venv--make-pcompletions (commands) | |
;; `(progn ,@(-map #'venv--gen-fun (symbol-value commands)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment