|
From: | Michael Heerdegen |
Subject: | Re: Why is defun not executed during load-file? |
Date: | Mon, 31 May 2021 01:26:11 +0200 |
User-agent: | Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Jean Louis <bugs@gnu.support> writes: > I am fine to generate functions without macros, just tell me how. I > need names of functions dynamically generated. I think you can use `defalias', a simple function. That would require to use lexical binding so that variables like `prompt' can get captured in a closure. That would look like this: #+begin_src emacs-lisp ;;;; Your first file line -*- lexical-binding: t -*- ;; [...] (defun hyperscope-generate-the-add-function-by-hyperdocument-type (type-name id function-name) (defalias function-name (lambda () (interactive) (let* ((parent (hyperscope-select-set)) (prompt (format "New `%s' hyperdocument name: " type-name)) (name (read-from-minibuffer prompt))) (hlink-add-generic name "" id parent nil))) ;; Docstring gets an argument of `defalias': (format "Add new `%s' hyperdocument to Hyperscope." type-name))) #+end_src Michael.
[Prev in Thread] | Current Thread | [Next in Thread] |