unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#10239: compilation-auto-jump-to-first-error vs. giant binary executables
@ 2011-12-06 23:14 jidanni
  2019-09-29 17:08 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: jidanni @ 2011-12-06 23:14 UTC (permalink / raw)
  To: 10239

$ 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.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#10239: compilation-auto-jump-to-first-error vs. giant binary executables
  2011-12-06 23:14 bug#10239: compilation-auto-jump-to-first-error vs. giant binary executables jidanni
@ 2019-09-29 17:08 ` Lars Ingebrigtsen
  2019-09-29 17:30   ` 積丹尼 Dan Jacobson
  2019-09-29 17:43   ` Andreas Schwab
  0 siblings, 2 replies; 7+ messages in thread
From: Lars Ingebrigtsen @ 2019-09-29 17:08 UTC (permalink / raw)
  To: jidanni; +Cc: 10239, 25329

jidanni@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





^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#10239: compilation-auto-jump-to-first-error vs. giant binary executables
  2019-09-29 17:08 ` Lars Ingebrigtsen
@ 2019-09-29 17:30   ` 積丹尼 Dan Jacobson
  2019-09-29 17:43   ` Andreas Schwab
  1 sibling, 0 replies; 7+ messages in thread
From: 積丹尼 Dan Jacobson @ 2019-09-29 17:30 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 10239, 25329

>>>>> "LI" == Lars Ingebrigtsen <larsi@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!





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#10239: compilation-auto-jump-to-first-error vs. giant binary executables
  2019-09-29 17:08 ` Lars Ingebrigtsen
  2019-09-29 17:30   ` 積丹尼 Dan Jacobson
@ 2019-09-29 17:43   ` Andreas Schwab
  2019-09-29 18:48     ` bug#25329: " Lars Ingebrigtsen
  1 sibling, 1 reply; 7+ messages in thread
From: Andreas Schwab @ 2019-09-29 17:43 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 10239, 25329, jidanni

On Sep 29 2019, Lars Ingebrigtsen <larsi@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@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#25329: bug#10239: compilation-auto-jump-to-first-error vs. giant binary executables
  2019-09-29 17:43   ` Andreas Schwab
@ 2019-09-29 18:48     ` Lars Ingebrigtsen
  2019-10-09 23:20       ` bug#10239: " Lars Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2019-09-29 18:48 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: 10239, 25329, jidanni

Andreas Schwab <schwab@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





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#10239: bug#25329: bug#10239: compilation-auto-jump-to-first-error vs. giant binary executables
  2019-09-29 18:48     ` bug#25329: " Lars Ingebrigtsen
@ 2019-10-09 23:20       ` Lars Ingebrigtsen
  2019-10-10  8:32         ` bug#25329: " Andreas Schwab
  0 siblings, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2019-10-09 23:20 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: 10239, 25329, 35745, jidanni

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Andreas Schwab <schwab@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





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#25329: bug#10239: bug#25329: bug#10239: compilation-auto-jump-to-first-error vs. giant binary executables
  2019-10-09 23:20       ` bug#10239: " Lars Ingebrigtsen
@ 2019-10-10  8:32         ` Andreas Schwab
  0 siblings, 0 replies; 7+ messages in thread
From: Andreas Schwab @ 2019-10-10  8:32 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 10239, 25329, 35745, jidanni

On Okt 10 2019, Lars Ingebrigtsen <larsi@gnus.org> wrote:

> Lars Ingebrigtsen <larsi@gnus.org> writes:
>
>> Andreas Schwab <schwab@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@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-10-10  8:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-06 23:14 bug#10239: compilation-auto-jump-to-first-error vs. giant binary executables jidanni
2019-09-29 17:08 ` Lars Ingebrigtsen
2019-09-29 17:30   ` 積丹尼 Dan Jacobson
2019-09-29 17:43   ` Andreas Schwab
2019-09-29 18:48     ` bug#25329: " Lars Ingebrigtsen
2019-10-09 23:20       ` bug#10239: " Lars Ingebrigtsen
2019-10-10  8:32         ` bug#25329: " Andreas Schwab

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).