summary refs log tree commit diff stats
path: root/init.el
diff options
context:
space:
mode:
Diffstat (limited to 'init.el')
-rw-r--r--init.el48
1 files changed, 47 insertions, 1 deletions
diff --git a/init.el b/init.el index b17b21a..ab2e693 100644 --- a/init.el +++ b/init.el
@@ -937,7 +937,53 @@ successive invocations."
937 "C-c l v" #'find-variable)) 937 "C-c l v" #'find-variable))
938 938
939(setup flymake 939(setup flymake
940 (:hook-into prog-mode) 940
941 (defvar flymake-inhibit-major-modes nil
942 "Which major-modes NOT to enable `flymake' in.")
943
944 (defvar flymake-inhibit-file-name-regexps '("init\\.el\\'"
945 "early-init\\.el\\'")
946 "List of file regexps NOT to enable `flymake' in.")
947
948 (defvar flymake-inhibit-buffer-name-regexps (list (rx "*scratch*"))
949 "List of buffer-name regexps NOT to enable `flymake' in.")
950
951 (defun list-string-match-p (string regexp-list)
952 "Return t if at least one regex in RETGEXP-LIST matches STRING, else nil."
953 (when string ; if STRING is nil, return nil.
954 (catch 'found
955 (dolist (regexp regexp-list)
956 (when (string-match regexp string)
957 (throw 'found t))))))
958
959 (defun flymake-unless ()
960 "Turn on `flymake-mode', UNLESS it's inhibited.
961There are three methods to inhibit flymake in a file. From most
962specific to most general, they are these:
963
964- `flymake-inhibit': a file-local-variable
965
966- `flymake-inhibit-buffer-name-regexps': a list of regexps to
967 match the buffer name against. If one of them matches, inhibit
968 `flymake-mode'.
969
970- `flymake-inhibit-file-name-regexps': a list of regexps to match
971 the filename against. If one of them matches, inhibit
972 `flymake-mode'.
973
974- `flymake-inhibit-major-modes': a list of major-modes in which
975 to inhibit `flymake-mode'. Really only useful if you want to
976 generally add `flymake-mode' to `prog-mode-hook'."
977 (unless (or (bound-and-true-p flymake-inhibit) ; file-local variable
978 (list-string-match-p (buffer-name)
979 flymake-inhibit-buffer-name-regexps)
980 (list-string-match-p (buffer-file-name)
981 flymake-inhibit-file-name-regexps)
982 (apply #'derived-mode-p flymake-inhibit-major-modes))
983 (flymake-mode-on)))
984
985 (add-hook 'prog-mode-hook #'flymake-unless)
986
941 (:bind "M-n" #'flymake-goto-next-error 987 (:bind "M-n" #'flymake-goto-next-error
942 "M-p" #'flymake-goto-prev-error)) 988 "M-p" #'flymake-goto-prev-error))
943 989