GNU bug report logs - #25329
add /bin/sh etc. to a blacklist for compilation mode to stop trying to open them

Previous Next

Package: emacs;

Reported by: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>

Date: Mon, 2 Jan 2017 05:33:02 UTC

Severity: wishlist

Tags: fixed, patch

Merged with 10239, 15032, 16218, 28035, 32968, 35745

Fixed in version 27.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 25329 in the body.
You can then email your comments to 25329 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#25329; Package emacs. (Mon, 02 Jan 2017 05:33:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 02 Jan 2017 05:33:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
To: bug-gnu-emacs <bug-gnu-emacs <at> gnu.org>
Subject: add /bin/sh etc. to a blacklist for compilation mode to stop trying
 to open them
Date: Mon, 02 Jan 2017 13:31:04 +0800
[Message part 1 (text/plain, inline)]
Can somebody please add a blacklist to compilation mode consisting of the
major shells, to stop it from opening them for each little error like:

[b.jpg (image/jpeg, attachment)]

Forcibly Merged 10239 15032 16218 25329. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Mon, 02 Jan 2017 07:12:02 GMT) Full text and rfc822 format available.

Forcibly Merged 10239 15032 16218 25329 28035. Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Thu, 10 Aug 2017 12:00:02 GMT) Full text and rfc822 format available.

Merged 10239 15032 16218 25329 28035 32968. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sun, 07 Oct 2018 15:13:01 GMT) Full text and rfc822 format available.

Forcibly Merged 10239 15032 16218 25329 28035 32968 35745. Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Wed, 15 May 2019 11:40:01 GMT) Full text and rfc822 format available.

Severity set to 'wishlist' from 'normal' Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Wed, 15 May 2019 15:35:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25329; Package emacs. (Sun, 29 Sep 2019 17:09:02 GMT) Full text and rfc822 format available.

Message #18 received at 25329 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: jidanni <at> jidanni.org
Cc: 10239 <at> debbugs.gnu.org, 25329 <at> debbugs.gnu.org
Subject: Re: bug#10239: compilation-auto-jump-to-first-error vs. giant
 binary executables
Date: Sun, 29 Sep 2019 19:08:40 +0200
jidanni <at> jidanni.org writes:

> $ cat Makefile
> a:;set -Y
> $ emacs -Q -eval '(setq compilation-auto-jump-to-first-error t)' -f compile
> RET
> /bin/sh: line 0: set: -Y: invalid option
> Wham pow! We are looking at a whole megabyte of binary ELF /bin/sh executable.
> I didn't try it on lager files or with ones with strings the colorizer
> would try to color etc.

The problem is that compilation mode interprets this

/bin/sh: 1: test: -gt: unexpected operator

as an error (which is right), but believes that this error originates in
/bin/sh, so when you jump to the first error in the buffer, you're
presented with /bin/sh in a buffer, which isn't very helpful.

In addition, it identifies this line:

make: *** [Makefile:1: a] Error 2

as another error, which is even more right, but it thinks that the file
name is "*** [Makefile", which is wrong.

So I took a whack at fixing both these things with a new mechanism that
allows transformation of detected file names (and ignoring them in the
case of /bin/sh).

Patch included below.

Does this seems like a good mechanism for doing this stuff?

diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index d80fef3103..a29dc5cc47 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -58,6 +58,16 @@ compilation-window-height
   :type '(choice (const :tag "Default" nil)
 		 integer))
 
+(defcustom compilation-transform-file-match-alist
+  '(("/bin/[a-z]*sh\\'" nil)
+    ("\\*+ \\[\\(Makefile\\)" "\\1"))
+  "Alist of regexp/replacements to alter file names in compilation errors.
+If the replacement is nil, the file will not be considered an
+error after all.  If not nil, it should be a regexp replacement
+string."
+  :type '(repeat (list regexp string))
+  :version "27.1")
+
 (defvar compilation-filter-hook nil
   "Hook run after `compilation-filter' has inserted a string into the buffer.
 It is called with the variable `compilation-filter-start' bound
@@ -1155,19 +1165,36 @@ compilation-error-properties
                      (setq end-col (match-string-no-properties end-col))
                      (- (string-to-number end-col) -1)))
               (and end-line -1)))
-    (if (consp type)			; not a static type, check what it is.
+    (if (consp type)            ; not a static type, check what it is.
 	(setq type (or (and (car type) (match-end (car type)) 1)
 		       (and (cdr type) (match-end (cdr type)) 0)
 		       2)))
-
-    (when (and compilation-auto-jump-to-next
-               (>= type compilation-skip-threshold))
-      (kill-local-variable 'compilation-auto-jump-to-next)
-      (run-with-timer 0 nil 'compilation-auto-jump
-                      (current-buffer) (match-beginning 0)))
-
-    (compilation-internal-error-properties
-     file line end-line col end-col type fmt)))
+    ;; Remove matches like /bin/sh and do other file name transforms.
+    (save-match-data
+      (let ((transformed nil))
+        (dolist (f file)
+          (let ((match
+                 (cl-loop for (regexp replacement)
+                          in compilation-transform-file-match-alist
+                          when (string-match regexp f)
+                          return (or replacement t))))
+            (cond ((not match)
+                   (push f transformed))
+                  ((stringp match)
+                   (push (replace-match match nil nil f) transformed)))))
+        (setq file (nreverse transformed))))
+    (if (not file)
+        ;; If we ignored all the files with errors on this line, then
+        ;; return nil.
+        nil
+      (when (and compilation-auto-jump-to-next
+                 (>= type compilation-skip-threshold))
+        (kill-local-variable 'compilation-auto-jump-to-next)
+        (run-with-timer 0 nil 'compilation-auto-jump
+                        (current-buffer) (match-beginning 0)))
+
+      (compilation-internal-error-properties
+       file line end-line col end-col type fmt))))
 
 (defun compilation-beginning-of-line (&optional n)
   "Like `beginning-of-line', but accounts for lines hidden by `selective-display'."


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) patch. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 29 Sep 2019 17:09:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25329; Package emacs. (Sun, 29 Sep 2019 17:31:02 GMT) Full text and rfc822 format available.

Message #23 received at 25329 <at> debbugs.gnu.org (full text, mbox):

From: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 10239 <at> debbugs.gnu.org, 25329 <at> debbugs.gnu.org
Subject: Re: bug#10239: compilation-auto-jump-to-first-error vs. giant binary
 executables
Date: Mon, 30 Sep 2019 01:30:36 +0800
>>>>> "LI" == Lars Ingebrigtsen <larsi <at> gnus.org> writes:
LI> Patch included below.

LI> Does this seems like a good mechanism for doing this stuff?
I bet it will. Thanks for fixing it!




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25329; Package emacs. (Sun, 29 Sep 2019 17:44:02 GMT) Full text and rfc822 format available.

Message #26 received at 25329 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 10239 <at> debbugs.gnu.org, 25329 <at> debbugs.gnu.org, jidanni <at> jidanni.org
Subject: Re: bug#10239: compilation-auto-jump-to-first-error vs. giant binary
 executables
Date: Sun, 29 Sep 2019 19:43:49 +0200
On Sep 29 2019, Lars Ingebrigtsen <larsi <at> gnus.org> wrote:

> diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
> index d80fef3103..a29dc5cc47 100644
> --- a/lisp/progmodes/compile.el
> +++ b/lisp/progmodes/compile.el
> @@ -58,6 +58,16 @@ compilation-window-height
>    :type '(choice (const :tag "Default" nil)
>  		 integer))
>  
> +(defcustom compilation-transform-file-match-alist
> +  '(("/bin/[a-z]*sh\\'" nil)
> +    ("\\*+ \\[\\(Makefile\\)" "\\1"))

That doesn't make sense.  "Makefile" can be anything.

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25329; Package emacs. (Sun, 29 Sep 2019 18:49:02 GMT) Full text and rfc822 format available.

Message #29 received at 25329 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Andreas Schwab <schwab <at> linux-m68k.org>
Cc: 10239 <at> debbugs.gnu.org, 25329 <at> debbugs.gnu.org, jidanni <at> jidanni.org
Subject: Re: bug#10239: compilation-auto-jump-to-first-error vs. giant
 binary executables
Date: Sun, 29 Sep 2019 20:48:24 +0200
Andreas Schwab <schwab <at> linux-m68k.org> writes:

>> +(defcustom compilation-transform-file-match-alist
>> +  '(("/bin/[a-z]*sh\\'" nil)
>> +    ("\\*+ \\[\\(Makefile\\)" "\\1"))
>
> That doesn't make sense.  "Makefile" can be anything.

I wanted to be conservative when introducing the feature.  If we decide
to add this feature, the regexps will evolve over the years.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25329; Package emacs. (Wed, 09 Oct 2019 23:21:02 GMT) Full text and rfc822 format available.

Message #32 received at 25329 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Andreas Schwab <schwab <at> linux-m68k.org>
Cc: 10239 <at> debbugs.gnu.org, 25329 <at> debbugs.gnu.org, 35745 <at> debbugs.gnu.org,
 jidanni <at> jidanni.org
Subject: Re: bug#25329: bug#10239: compilation-auto-jump-to-first-error vs.
 giant binary executables
Date: Thu, 10 Oct 2019 01:20:05 +0200
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Andreas Schwab <schwab <at> linux-m68k.org> writes:
>
>>> +(defcustom compilation-transform-file-match-alist
>>> +  '(("/bin/[a-z]*sh\\'" nil)
>>> +    ("\\*+ \\[\\(Makefile\\)" "\\1"))
>>
>> That doesn't make sense.  "Makefile" can be anything.
>
> I wanted to be conservative when introducing the feature.  If we decide
> to add this feature, the regexps will evolve over the years.

There weren't any other comments, so I've now applied the patch and I'm
closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 09 Oct 2019 23:21:06 GMT) Full text and rfc822 format available.

bug marked as fixed in version 27.1, send any further explanations to 35745 <at> debbugs.gnu.org and 積丹尼 Dan Jacobson <jidanni <at> jidanni.org> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 09 Oct 2019 23:21:07 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25329; Package emacs. (Thu, 10 Oct 2019 08:33:02 GMT) Full text and rfc822 format available.

Message #39 received at 25329 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 10239 <at> debbugs.gnu.org, 25329 <at> debbugs.gnu.org, 35745 <at> debbugs.gnu.org,
 jidanni <at> jidanni.org
Subject: Re: bug#10239: bug#25329: bug#10239:
 compilation-auto-jump-to-first-error vs. giant binary executables
Date: Thu, 10 Oct 2019 10:32:19 +0200
On Okt 10 2019, Lars Ingebrigtsen <larsi <at> gnus.org> wrote:

> Lars Ingebrigtsen <larsi <at> gnus.org> writes:
>
>> Andreas Schwab <schwab <at> linux-m68k.org> writes:
>>
>>>> +(defcustom compilation-transform-file-match-alist
>>>> +  '(("/bin/[a-z]*sh\\'" nil)
>>>> +    ("\\*+ \\[\\(Makefile\\)" "\\1"))
>>>
>>> That doesn't make sense.  "Makefile" can be anything.
>>
>> I wanted to be conservative when introducing the feature.  If we decide
>> to add this feature, the regexps will evolve over the years.
>
> There weren't any other comments, so I've now applied the patch and I'm
> closing this bug report.

This has been obsoleted by Pauls patch.

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 07 Nov 2019 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 161 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.