Advertisement
Guest User

Untitled

a guest
Jul 25th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. (defmacro make-cmd (cmd &optional search)
  2. "Some function factory."
  3. (let ((fn (intern (concat "fn-" cmd))))
  4. `(defun ,fn (&optional args)
  5. (interactive)
  6. (let ((str (symbol-name ',fn))
  7. ,@(when search
  8. '((dir "~"))))
  9. (message "Called %S from %S" str
  10. (or (and (bound-and-true-p dir) dir)
  11. default-directory))))))
  12.  
  13. ;; functions `fn-f1' and `fn-f2' aren't added to obarray
  14. (dolist (x '("f1" "f2"))
  15. `(make-cmd ,x t))
  16.  
  17. ;; works like this
  18. (make-cmd "f1" t)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement