all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jean Louis <bugs@gnu.support>
To: Help GNU Emacs <help-gnu-emacs@gnu.org>
Subject: What is better way to automatically generate set of functions?
Date: Sat, 15 May 2021 23:14:51 +0300	[thread overview]
Message-ID: <courier.0000000060A02BC2.00006B5F@stw1.rcdrun.com> (raw)

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/








             reply	other threads:[~2021-05-15 20:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-15 20:14 Jean Louis [this message]
2021-05-15 21:48 ` What is better way to automatically generate set of functions? 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

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

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

  git send-email \
    --in-reply-to=courier.0000000060A02BC2.00006B5F@stw1.rcdrun.com \
    --to=bugs@gnu.support \
    --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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.