forked from colonelpanic/dotfiles
[Emacs] Add major mode blacklisting macro
This commit is contained in:
parent
0c894d113e
commit
e2a4c891c1
@ -933,6 +933,26 @@ This was stolen from https://github.com/jwiegley/dot-emacs
|
||||
(imalison:disable-mode-hook nlinum-mode)
|
||||
(imalison:disable-mode-hook yas-minor-mode)
|
||||
#+END_SRC
|
||||
** Add a blacklist to a major mode
|
||||
Sometimes a major mode's syntax highlighting can take a really long time to load
|
||||
in certain buffers. Usually you can just set a header to tell emacs not to run
|
||||
the major mode, but for cases where you can't always edit the file ahead of time
|
||||
this macro allows you to define a blacklist for your major mode that will
|
||||
prevent the major mode from being enabled on that file.
|
||||
#+begin_src emacs-lisp
|
||||
(defmacro imalison:add-blacklist-to-major (major-mode-fn-symbol)
|
||||
(let ((blacklist-var-symbol (imalison:concat-symbols major-mode-fn-symbol "-blacklist"))
|
||||
(check-blacklist-symbol (imalison:concat-symbols major-mode-fn-symbol "-check-blacklist")))
|
||||
`(progn
|
||||
(defvar ,blacklist-var-symbol nil)
|
||||
(defun ,check-blacklist-symbol (mode-fn &rest args)
|
||||
(unless (and (not (equal major-mode (quote ,major-mode-fn-symbol)))
|
||||
(equal nil args)
|
||||
(cl-loop for blacklist-regex in ,blacklist-var-symbol
|
||||
thereis (string-match blacklist-regex (buffer-name))))
|
||||
(apply mode-fn args)))
|
||||
(advice-add (quote ,major-mode-fn-symbol) :around (quote ,check-blacklist-symbol)))))
|
||||
#+end_src
|
||||
** Other
|
||||
The stuff in this section is pretty crusty. I don't think its used anywhere, but
|
||||
I keep it around just in case I need it.
|
||||
|
Loading…
Reference in New Issue
Block a user