From 8edda6689bbd02a719851a9d73aa002f5ff4def8 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Tue, 21 Jun 2016 14:44:51 -0700 Subject: [PATCH] Add named-build macro Removes old attempts at named-builder-builder --- dotfiles/emacs.d/README.org | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/dotfiles/emacs.d/README.org b/dotfiles/emacs.d/README.org index 1f4e0acf..b63930c3 100644 --- a/dotfiles/emacs.d/README.org +++ b/dotfiles/emacs.d/README.org @@ -420,7 +420,17 @@ By advising ~imenu--make-index-alist~ with ~imalison:flatten-imenu-index~ we mak when (and filepath (file-exists-p (file-truename filepath))) collect (file-truename filepath))))) #+END_SRC +** Named Build +imalison:named-build is used to name a lambda produced by another macro applied to the given forms. +#+BEGIN_SRC emacs-lisp + (defmacro imalison:named-build (name builder &rest args) + `(defalias (quote ,name) (,builder ,@args))) + (put 'imalison:named-build 'lisp-indent-function 1) + (defmacro imalison:named-builder-builder (named-builder-name builder-name) + `(defmacro ,named-builder-name (function-name &rest args) + (cons ,builder-name args))) +#+END_SRC ** Compose functions The composed functions can take arbitrarily many arguments and returning arbitrarily many arguments. #+BEGIN_SRC emacs-lisp @@ -646,17 +656,6 @@ This was taken from [[http://emacs.stackexchange.com/questions/7583/transiently- (defun imalison:font-size-decr () (interactive) (imalison:font-size-adj -1)) (defun imalison:font-size-reset () (interactive) (imalison:font-size-adj 0)) #+END_SRC -** Named Builder Builder -Abandoned attempt to write a macro that produces macros that name the functions that they produce. -#+BEGIN_SRC emacs-lisp - (defmacro imalison:named-function-builder (base-name argument-list &rest body) - (let ((named-argument-list (cons 'function-name argument-list)) - (named-macro-name (intern (concat (symbol-name base-name) "-named")))) - `(progn - (defmacro ,named-macro-name ,named-argument-list - (defalias function-name ,@body)) - (defmacro ,base-name ,argument-list ,@body)))) -#+END_SRC ** Message Result Builder This macro is useful when writing emacs-lisp. It creates a new interactive command that shows you the result of evaluating a function, with optionally provided arguments. #+BEGIN_SRC emacs-lisp