help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Is it alright to define-derived-mode dynamically?


From: Jean Louis
Subject: Is it alright to define-derived-mode dynamically?
Date: Thu, 24 Dec 2020 08:19:38 +0100

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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]