[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Example use of macro to minimize and generalize the code
From: |
Michael Heerdegen |
Subject: |
Re: Example use of macro to minimize and generalize the code |
Date: |
Tue, 01 Jun 2021 16:02:13 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Jean Louis <bugs@gnu.support> writes:
> (defmacro when-tabulated-id (table &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))))
Yes, better.
The downside now is that using the macro hides the fact that the code
depends on the id, and the resulting code is (still) hard to understand.
Why don't you consider to make the id a real argument?
Regards,
Michael.
- Re: Example use of macro to minimize and generalize the code,
Michael Heerdegen <=