From: Jean Louis <bugs@gnu.support>
To: Help GNU Emacs <help-gnu-emacs@gnu.org>
Subject: Is it alright to define-derived-mode dynamically?
Date: Thu, 24 Dec 2020 08:19:38 +0100 [thread overview]
Message-ID: <courier.000000005FE4410C.00005C0B@stw1.rcdrun.com> (raw)
I wonder if it is alright to define the derived mode dynamically
within a function:
(defun rcd-db-report (title entries &optional tabulated-list-format
tabulated-list-sort-key mode-map)
(let* ((tabulated-list-format (or tabulated-list-format [("ID" 10 t) ("Button" 20 t)]))
(title "Database"))
(let* ((buffer title)
(buffer (get-buffer-create buffer)))
(switch-to-buffer-other-window buffer)
(setq tabulated-list-format tabulated-list-format)
(setq tabulated-list-sort-key tabulated-list-sort-key)
(setq tabulated-list-entries entries)
(define-derived-mode rcd-db-list tabulated-list-mode "Database List" "Database List Report"
(hl-line-mode)
(use-local-map mode-map)
(setq tabulated-list-padding 1)
(tabulated-list-init-header)
(tabulated-list-print t))
(rcd-db-list))))
As I would like to pass the keymap as mode-map to be each time
different, but I wonder if it is alright defining derived mode in a
function. So far it works.
I can see that I may define function within a function as well, but I
wonder if that is alright.
next reply other threads:[~2020-12-24 7:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-24 7:19 Jean Louis [this message]
2020-12-24 14:44 ` Is it alright to define-derived-mode dynamically? Stefan Monnier
2020-12-25 10:42 ` Jean Louis
2020-12-25 17:34 ` Stefan Monnier
2020-12-25 20:03 ` 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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=courier.000000005FE4410C.00005C0B@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.
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).