unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* What is better way to automatically generate set of functions?
@ 2021-05-15 20:14 Jean Louis
  2021-05-15 21:48 ` Stefan Monnier via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 5+ messages in thread
From: Jean Louis @ 2021-05-15 20:14 UTC (permalink / raw)
  To: Help GNU Emacs

As I wish to create automatically set of functions, I have come up
with this solution that works:

(defun hyperscope-generate-function-by-hyperdocument-type (type)
  (let* ((type (downcase (string-replace " " "-" type)))
	 (function-name (intern (format "hyperscope-add-new-%s-hyperdocument" type))))
    `,(defalias function-name (lambda () (message "Hello")))))

(hyperscope-generate-function-by-hyperdocument-type "Asciidoc")
 ⇒ hyperscope-add-new-asciidoc-hyperdocument

(hyperscope-add-new-asciidoc-hyperdocument) ⇒ "Hello"

(hyperscope-generate-function-by-hyperdocument-type "Markdown")
 ⇒ hyperscope-add-new-markdown-hyperdocument

(hyperscope-add-new-markdown-hyperdocument) ⇒ "Hello"

But I would rather like it to be something like:

(defun hyperscope-generate-function-by-hyperdocument-type (type)
  (let* ((type (downcase (string-replace " " "-" type)))
	 (function-name (intern (format "hyperscope-add-new-%s-hyperdocument" type))))
    `,(defun ,function-name (lambda () (message "Hello")))))

Only that in the last case I am not getting it to work.

Is there a way to make it with `defun'?


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/
https://rms-support-letter.github.io/








^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-05-16  8:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2021-05-16  8:04       ` SOLVED: " Jean Louis

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).