[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: What is better way to automatically generate set of functions?
From: |
Stefan Monnier |
Subject: |
Re: What is better way to automatically generate set of functions? |
Date: |
Sat, 15 May 2021 18:53:40 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> 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