conao3 / leaf.el

Flexible, declarative, and modern init.el package configuration
GNU General Public License v3.0
500 stars 27 forks source link

leaf-alias #514

Open jgarte opened 2 years ago

jgarte commented 2 years ago

Could leaf have a macro like this (Sorry, Github markdown does not allow to indent lisp code nicely in code blocks.):

(leaf-alias open find-file
                openo find-file-other-window)

Instead of writing the following in vanilla elisp:

(defalias 'open 'find-file)
(defalias 'openo 'find-file-other-window)

Or, is there another package that already covers this?

I suppose I could also write a macro for this but if it's already out there I would like to consult that source first.

jgarte commented 2 years ago

Hmmm, could I do similar to leaf-list...

(defmacro leaf-list (&rest args)
  "Make list from ARGS.
Same as `list' but this macro does not evaluate any arguments."
  `(quote ,args))

But this instead:

(defmacro leaf-alias (&rest args)
  "Make list of defalias from ARGS.
Same as `defalias' but this macro does not evaluate any arguments."
  `(quote ,args)) ...

I realize the above is wrong and a simplistic translation/macro template. Any help/advice is much appreciated.

Maybe this is a better template:

:leaf-defalias       `(,@(mapcar (lambda (elm) `(defalias ,elm)) leaf--value) ,@leaf--body)