Questions tagged [defmacro]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
2 answers
72 views

Defmacro: Create functions from a list o functions

I have this code: (defmacro with-ignore-mouse-events (&rest body) "Macro to ignore mouse events before evaluating BODY." `(progn (when (input-pending-p) (let ((event (...
Gabriele Nicolardi's user avatar
0 votes
1 answer
43 views

Macros expanding to addhook

I have the following configuration lines in my init.el file regarding a specific mode: (add-hook 'pdf-view-mode-hook (lambda () (local-set-key (kbd "SPC h") #'evil-window-left))) (add-hook '...
Peter Petigru's user avatar
0 votes
2 answers
188 views

How does a Lisp macro behave?

Have read that macro provide a way to perform transformations before the code is actually evaluated. When the macro is called, its arguments are passed to the macro as unevaluated forms. The macro ...
Dilna's user avatar
  • 1
-2 votes
1 answer
51 views

Defining a macro that does nothing

I am defining a macro that accepts any number of arguments that actually do nothing. From a previous discussion, it was pointed out to me that a macro does not evaluate its arguments, which is ...
Dilna's user avatar
  • 1
0 votes
2 answers
197 views

How do I properly use keyword/named arguments in a macro with cl-defmacro?

I'm trying to use cl-defmacro, with the supposed benefit of having optional arguments specified with keywords. However, I'm not getting the outcome I would expect. (cl-defmacro asd (a &rest body &...
aaa's user avatar
  • 436
0 votes
1 answer
76 views

How to use the same variable name with let when calling defmacro?

This is only an example, I understand this can easily be achieved with a function. Don't Work This is what I've come up with based on the elisp manual and a couple of answers/articles that I have ...
Rick's user avatar
  • 25
0 votes
1 answer
72 views

How do I use a while loop with a macro?

This works when I remove the loop but with the loop it does not work. (defmacro my/def-key (state map) (let ((x '( (kbd "<leader>z z") (lambda nil (interactive)(message ...
ritchie's user avatar
  • 149
1 vote
1 answer
123 views

The forbidden question about defmacro: when does the expansion occur?

I have recently learned (in shock!) that it is impossible to predict the moment a macro defined via defmacro is expanded (i.e., its code is run in order to generate the expanded form which will in ...
Ruy's user avatar
  • 839
4 votes
1 answer
464 views

Bug in defmacro?

I think I found a bug in defmacro so I'd like to ask for confirmation before I make a fool of myself reporting something silly! Here is how to reproduce it: Define the following macro which simply ...
Ruy's user avatar
  • 839
2 votes
2 answers
143 views

How to distinguish from within a macro definition whether a parameter is a constant string, as opposed to a symbol whose value is a string?

I want to write an emacs macro via defmacro that takes a parameter which could either be (1) a constant string or (2) a symbol whose value is a string. Within the macro definition I want to be able to ...
Ruy's user avatar
  • 839