bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#33618: 27.0.50; ada-mode breaks M-x grep


From: Stefan Monnier
Subject: bug#33618: 27.0.50; ada-mode breaks M-x grep
Date: Wed, 05 Dec 2018 09:26:45 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

>> > Opening a file in ada-mode using the new ada-mode from GNU ELPA globally
>> > sets compilation-search-path (for me, it got set to `("~/tmp")`
>> > probably because the Ada file was in ~/tmp), which in
>> > turn breaks M-x grep in the sense that clicking on a match doesn't jump
>> > to the file but prompts you to find the file (unless you happened to
>> > grep from one of the directories mentioned in the
>> > compilation-search-path, of course).
>> 
>> I use the patch below currently to work around this problem.
>> Should I install it into `master` (with a few more comments and
>> probably etc/NEWS or even manual updates)?
>
> If the problem is in ada-mode in ELPA, it should be fixed there, IMO.
> Why do we need to change our code to cater to problems in packages,
> even if those packages are on ELPA?  It sounds wrong to me, FWIW.

Because I think the problem in ada-mode is linked to a design problem
with that variable: it is defined to be a global variable, and
compile.el looks it up from inside the compilation buffer, so there's no
convenient way for a major mode like ada-mode to tell compile.el which
search-path to use for which file/project: all they can do is change the
global value.

The patch I use changes compile.el so the var is looked up from the
buffer from which the compilation is launched (e.g. an ada-mode buffer)
and then stashed into the compilation buffer (for later use).

Note that the hunk below (which is part of the patch I sent) is
sufficient to unbreak grep, but other tools that (like grep) build on
`compilation-start` would still be affected.


        Stefan


--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -834,7 +834,8 @@ grep-mode
   (set (make-local-variable 'compilation-disable-input) t)
   (set (make-local-variable 'compilation-error-screen-columns)
        grep-error-screen-columns)
-  (add-hook 'compilation-filter-hook 'grep-filter nil t))
+  (setq-local compilation-search-path '(nil))
+  (add-hook 'compilation-filter-hook #'grep-filter nil t))
 
 (defun grep--save-buffers ()
   (when grep-save-buffers





reply via email to

[Prev in Thread] Current Thread [Next in Thread]