[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
What is better way to automatically generate set of functions?
From: |
Jean Louis |
Subject: |
What is better way to automatically generate set of functions? |
Date: |
Sat, 15 May 2021 23:14:51 +0300 |
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/
- What is better way to automatically generate set of functions?,
Jean Louis <=