Tor-björn Claesson <tclaes...@gmail.com> writes: > I'm making progress, macrostep is great, thanks:-) Here is a new patch with > my progress so far.
Thanks! I am not yet reviewing fully. > I have a problem I do not understand: The definition of > org-cite-basic-follow using org-menu-define in oc-basic.el does not work > unless i evaluate it manually, otherwise org-cite-basic-follow is nil when > I try to follow citations. > +;;; Main macro definition > +(cl-defmacro org-menu-define (name > + docstring > + contents > + &key ((:display display) nil) > + &key ((:default-action default-action) nil) > + &key ((:parameter-types types) nil)) > + "Define an org menu." > + (setq org-menu-display (cons `(,name . ,display) org-menu-display)) > + (setq org-menu-default-actions (cons `(,name . ,default-action) > org-menu-default-actions)) > + > + `(transient-define-prefix ,name (object &optional prefix) >... The setq calls above are evaluated when macro is expanded, not when the menu is called. Macro expansion may happen during compile time, when loading un-compiled library, or when you evaluate the macro expression manually. If the expansion happens during compile time, it can only affect the Emacs instance that is doing the compilation, but will have 0 effect when you use the compiled function later. This is likely the reason why you are not seeing the desired effect all the time. Remember that macro is generating the code to be evaluated later. Doing computations during expansion is rarely needed, except when you are computing some constants to be inlined. You may probably consider moving setq calls inside `(...), so that it is evaluated later, during runtime. Something like `(progn (setq ..) (transient-define-prefix ...)) -- Ihor Radchenko // yantar92, Org mode maintainer, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92>