[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Example use of macro to minimize and generalize the code
From: |
Jean Louis |
Subject: |
Re: Example use of macro to minimize and generalize the code |
Date: |
Tue, 1 Jun 2021 03:39:25 +0300 |
User-agent: |
Mutt/2.0.7+183 (3d24855) (2021-05-28) |
* Michael Heerdegen <michael_heerdegen@web.de> [2021-06-01 03:35]:
> Jean Louis <bugs@gnu.support> writes:
>
> > [...]
> > That is why `ignore' is there. Ignore is there to suppress the byte
> > compiler warning just as you guessed it.
> >
> > Otherwise:
> >
> > In when-tabulated-id:
> > rcd-cf.el:165:45: Warning: Unused lexical argument `id'
>
> Sure - but why do you add an argument to that macro that it (or its
> expansion) doesn't use at all? That's very confusing, it would be
> better to remove the argument. Or - could the macro be rewritten to not
> ignore that argument?
I would like to improve but I have to understand what you mean. This
is the macro, arguments are table, id and body. I need all of them.
- table is there as I don't want my functions invoked in other tables,
it could cause havoc;
- ID is necessary;
- functions can be then invoked programmatically and interactively
with less arguments:
So help me understand...
(defmacro when-tabulated-id (table id &rest body)
(declare (indent 2) (debug t))
(ignore id)
`(if id
(progn
,@body)
(if (or (eq ,table 'any)
(string-equal ,table rcd-current-table))
(let ((id (tabulated-list-get-id)))
(if id
(progn ,@body)
(message "Did not get ID")))
(message "This function is for table `%s' only" ,table))))
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
Sign an open letter in support of Richard M. Stallman
https://stallmansupport.org/
- RE: [External] : Re: Why is defun not executed during load-file?, (continued)
- RE: [External] : Re: Why is defun not executed during load-file?, Drew Adams, 2021/05/30
- Re: [External] : Re: Why is defun not executed during load-file?, Emanuel Berg, 2021/05/30
- RE: [External] : Re: Why is defun not executed during load-file?, Drew Adams, 2021/05/31
- Re: [External] : Re: Why is defun not executed during load-file?, Emanuel Berg, 2021/05/31
- Re: [External] : Re: Why is defun not executed during load-file?, Stefan Monnier, 2021/05/31
- Re: [External] : Re: Why is defun not executed during load-file?, Marcin Borkowski, 2021/05/31
- Example use of macro to minimize and generalize the code, Jean Louis, 2021/05/31
- Re: Example use of macro to minimize and generalize the code, Michael Heerdegen, 2021/05/31
- Re: Example use of macro to minimize and generalize the code, Jean Louis, 2021/05/31
- Re: Example use of macro to minimize and generalize the code, Michael Heerdegen, 2021/05/31
- Re: Example use of macro to minimize and generalize the code,
Jean Louis <=
- Re: Example use of macro to minimize and generalize the code, Michael Heerdegen, 2021/05/31
- Re: Example use of macro to minimize and generalize the code, Jean Louis, 2021/05/31
- Example use of macro to minimize and generalize the code (2), Jean Louis, 2021/05/31
- Re: [External] : Re: Why is defun not executed during load-file?, Michael Heerdegen, 2021/05/31
- RE: [External] : Re: Why is defun not executed during load-file?, Drew Adams, 2021/05/31