[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Refactoring flymake.el
From: |
Sam Steingold |
Subject: |
Re: Refactoring flymake.el |
Date: |
Thu, 17 Aug 2017 14:08:24 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (darwin) |
Hi João,
One thing about flymake that inconveniences me is that I cannot disable
it for some specific files.
I have a bunch of "scratch.py" files that I use as poor man's notebooks.
To disable flymake on them, I made this chanfe to flymake.el today:
--8<---------------cut here---------------start------------->8---
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index ed34d9aaa5..edb87c92b3 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -133,6 +133,13 @@ flymake-master-file-count-limit
:group 'flymake
:type 'integer)
+(defcustom flymake-disallowed-file-name-regexp nil
+ "File names matching this regexp will not be checked.
+This overrides `flymake-allowed-file-name-masks'."
+ :group 'flymake
+ :type 'string
+ :version "26.1")
+
(defcustom flymake-allowed-file-name-masks
'(("\\.\\(?:c\\(?:pp\\|xx\\|\\+\\+\\)?\\|CC\\)\\'" flymake-simple-make-init)
("\\.xml\\'" flymake-xml-init)
@@ -228,14 +235,16 @@ flymake-get-file-name-mode-and-masks
"Return the corresponding entry from `flymake-allowed-file-name-masks'."
(unless (stringp file-name)
(error "Invalid file-name"))
- (let ((fnm flymake-allowed-file-name-masks)
- (mode-and-masks nil))
- (while (and (not mode-and-masks) fnm)
- (if (string-match (car (car fnm)) file-name)
- (setq mode-and-masks (cdr (car fnm))))
- (setq fnm (cdr fnm)))
- (flymake-log 3 "file %s, init=%s" file-name (car mode-and-masks))
- mode-and-masks))
+ (unless (and flymake-disallowed-file-name-regexp
+ (string-match flymake-disallowed-file-name-regexp file-name))
+ (let ((fnm flymake-allowed-file-name-masks)
+ (mode-and-masks nil))
+ (while (and (not mode-and-masks) fnm)
+ (let ((item (pop fnm)))
+ (when (string-match (car item) file-name)
+ (setq mode-and-masks (cdr item)))))
+ (flymake-log 3 "file %s, init=%s" file-name (car mode-and-masks))
+ mode-and-masks)))
(defun flymake-can-syntax-check-file (file-name)
"Determine whether we can syntax check FILE-NAME.
--8<---------------cut here---------------end--------------->8---
and set `flymake-disallowed-file-name-regexp` to "scratch".
it seems to be working, so I was thinking about pushing it.
Do you think there is a better approach?
Thanks.
--
Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.1504
http://steingoldpsychology.com http://www.childpsy.net
http://islamexposedonline.com http://iris.org.il http://no2bds.org
In the race between idiot-proof software and idiots, the idiots are winning.
- Refactoring flymake.el, João Távora, 2017/08/17
- Re: Refactoring flymake.el, John Wiegley, 2017/08/17
- Re: Refactoring flymake.el,
Sam Steingold <=
- Re: Refactoring flymake.el, Stefan Monnier, 2017/08/17
- Re: Refactoring flymake.el, Sam Steingold, 2017/08/18
- Re: Refactoring flymake.el, Dmitry Gutov, 2017/08/18
- Re: Refactoring flymake.el, Sam Steingold, 2017/08/18
- Re: Refactoring flymake.el, Dmitry Gutov, 2017/08/18
- Re: Refactoring flymake.el, Sam Steingold, 2017/08/18
- Re: Refactoring flymake.el, Noam Postavsky, 2017/08/18
- Re: Refactoring flymake.el, Sam Steingold, 2017/08/18
- Re: Refactoring flymake.el, Clément Pit-Claudel, 2017/08/18
- Re: Refactoring flymake.el, Stefan Monnier, 2017/08/18