Skip to content

Instantly share code, notes, and snippets.

@porterjamesj
Created September 17, 2013 01:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save porterjamesj/6589173 to your computer and use it in GitHub Desktop.
Save porterjamesj/6589173 to your computer and use it in GitHub Desktop.
two macros that both produce the correct result
;; 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