unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: help-gnu-emacs@gnu.org
Subject: Re: What is better way to automatically generate set of functions?
Date: Sat, 15 May 2021 18:53:40 -0400	[thread overview]
Message-ID: <jwv7djzzk0w.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <YKBIdcHLZdDKFfea@protected.localdomain> (Jean Louis's message of "Sun, 16 May 2021 01:17:25 +0300")

> For now, this here works, but is not elegant.
>
> (defun hyperscope-generate-the-add-function-by-hyperdocument-type (type id)
>   (let* ((type (downcase (string-replace " " "-" type)))
> 	 (function-name (intern (format "hyperscope-add-new-%s-hyperdocument" type))))
>     (eval (list
> 	   'defun function-name ()
> 	   (format "Add new `%s' hyperdocument to Hyperscope." type)
> 	   '(interactive)
> 	   `(let* ((parent (hyperscope-select-set))
> 		   (prompt ,(format "New `%s' hyperdocument name: " type))
> 		   (name (read-from-minibuffer prompt)))
> 	      (hlink-add-generic name "" ,id parent nil))))))

I suspect you can to use `defmacro` at the top and remove the `eval`.


        Stefan




  reply	other threads:[~2021-05-15 22:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-15 20:14 What is better way to automatically generate set of functions? Jean Louis
2021-05-15 21:48 ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-05-15 22:17   ` Jean Louis
2021-05-15 22:53     ` Stefan Monnier [this message]
2021-05-16  8:04       ` SOLVED: " Jean Louis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwv7djzzk0w.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).