6
votes
Accepted
Why isn't emacs-lisp-mode derived from lisp-mode?
Because lisp-mode is actually meant to be the major mode for Common-Lisp. Emacs-Lisp and Common-Lisp are closely related but neither is a superset of the other, so they should both derive from the ...
4
votes
Accepted
How to run a 'prog-mode-hook' after more specific hooks?
You can use after-change-major-mode-hook:
(add-hook 'after-change-major-mode-hook 'my-after-change-major-mode-prog-mode)
(defun my-after-change-major-mode-prog-mode ()
"Custom `after-change-major-...
4
votes
Accepted
Prevent hooks from parent mode in derived mode
Prevent hooks from parent mode in derived mode
Not trivial. I certainly can't think of a nice approach. You may find https://stackoverflow.com/a/19295380 of interest, though.
How can I disable ...
3
votes
Accepted
Hide a command from user
The nearest language-supported way is:
(put 'my-command-to-suppress 'disabled
"Don't do it! No, really, don't! I mean it!")
This does not completely disable the command, but (by ...
3
votes
Accepted
Derived mode without merging keymap
From the manual (elisp) Derived Modes, define-derived-mode defines keymaps using the following rules:
The new mode has its own sparse keymap, named ‘VARIANT-map’.
‘define-derived-mode’ ...
2
votes
How to run a 'prog-mode-hook' after more specific hooks?
Here's another option:
(defun my-prog-mode-hook ()
(when (derived-mode-p 'rust-mode)
(setq fci-rule-column 99))
(fci-mode 1))
(add-hook 'prog-mode-hook #'my-prog-mode-hook)
2
votes
Accepted
Derived major mode: new keyword fontification not playing nice with parent mode's
For issue #1, setting { and } to word syntax is wrong. You can give them "symbol constituent" syntax, but not "word" (otherwise you break the expected behavior of M-f and friends)....
1
vote
Accepted
disable lsp-mode for derived mode of haskell
Creating a wrapper like this and using it instead of lsp function should be good enough:
(defun my/lsp ()
(unless (eq major-mode <REPLACE-ME-WITH-MAJOR-MODE>)
(lsp)))
1
vote
Accepted
Syntax highlighting of keywords only if following builtin
In mwe-args-regexp you need (regexp-opt mwe-args-list "\\(?2:") and then everything should work.
Explanation: without the extra argument, regexp-opt produces a shy group construct which ...
1
vote
Accepted
How to find inheritance of modes?
Property derived-mode-parent of a mode symbol gives you the parent mode it is derived from.
(get 'latex-mode 'derived-mode-parent)
(get 'tex-mode 'derived-mode-parent)
This will give you a list of ...
1
vote
defalias derived mode to parent mode
Here's how you can do what you intended, while avoiding the inf-loop:
(defalias 'old-conf-mode (symbol-function 'conf-mode))
(define-derived-mode conf-mode old-conf-mode ...)
Note that this is still ...
1
vote
Accepted
defalias derived mode to parent mode
The nature of a derived mode is that its parent is called before the body of the child mode is evaluated1.
Therefore if the child becomes its own parent (or grandparent, etc...), that causes infinite ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
derived-mode × 16major-mode × 4
font-lock × 2
cc-mode × 2
org-mode × 1
debugging × 1
regular-expressions × 1
hooks × 1
keymap × 1
syntax-highlighting × 1
commands × 1
lsp-mode × 1
org-ref × 1
menu-bar × 1
auto-fill-mode × 1
nxml × 1
aliases × 1