From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Sam Steingold Newsgroups: gmane.emacs.devel Subject: Re: Refactoring flymake.el Date: Thu, 17 Aug 2017 14:08:24 -0400 Organization: disorganization Message-ID: References: <87378q2r62.fsf@lolita> Reply-To: sds@gnu.org NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1502993468 12216 195.159.176.226 (17 Aug 2017 18:11:08 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 17 Aug 2017 18:11:08 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (darwin) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Aug 17 20:11:02 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1diPFv-0002b3-Dj for ged-emacs-devel@m.gmane.org; Thu, 17 Aug 2017 20:10:55 +0200 Original-Received: from localhost ([::1]:38653 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diPG1-0001A0-Ug for ged-emacs-devel@m.gmane.org; Thu, 17 Aug 2017 14:11:01 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38835) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diPDp-0007sx-LI for emacs-devel@gnu.org; Thu, 17 Aug 2017 14:08:46 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1diPDl-0000aV-Uw for emacs-devel@gnu.org; Thu, 17 Aug 2017 14:08:45 -0400 Original-Received: from [195.159.176.226] (port=38159 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1diPDl-0000Y0-Mm for emacs-devel@gnu.org; Thu, 17 Aug 2017 14:08:41 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1diPDV-0003Vs-R9 for emacs-devel@gnu.org; Thu, 17 Aug 2017 20:08:25 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 64 Original-X-Complaints-To: usenet@blaine.gmane.org X-Attribution: Sam X-Disclaimer: You should not expect anyone to agree with me. Cancel-Lock: sha1:+ob2SMUKWSK2TTiY0UxSld06yIk= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:217598 Archived-At: 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.