unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Is it alright to define-derived-mode dynamically?
@ 2020-12-24  7:19 Jean Louis
  2020-12-24 14:44 ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Jean Louis @ 2020-12-24  7:19 UTC (permalink / raw)
  To: Help GNU Emacs

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.




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

end of thread, other threads:[~2020-12-25 20:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-24  7:19 Is it alright to define-derived-mode dynamically? Jean Louis
2020-12-24 14:44 ` Stefan Monnier
2020-12-25 10:42   ` Jean Louis
2020-12-25 17:34     ` Stefan Monnier
2020-12-25 20:03       ` 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).