unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#8684: 24.0.50; Grep mode trips up on Entering directory lines
@ 2011-05-17 15:52 Brent Goodrick
  2011-05-17 18:15 ` Stefan Monnier
  2011-05-20 23:19 ` bug#8684: The fix introduce another bug sss
  0 siblings, 2 replies; 6+ messages in thread
From: Brent Goodrick @ 2011-05-17 15:52 UTC (permalink / raw)
  To: 8684

This bug report will be sent to the Free Software Foundation,
not to your local site managers!
Please write in English if possible, because the Emacs maintainers
usually do not have translators to read other languages for them.

Your report will be posted to the bug-gnu-emacs@gnu.org mailing list
and the gnu.emacs.bug news group, and at http://debbugs.gnu.org.

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug.  If you can, give
a recipe starting from `emacs -Q':

When you are searching build logs for matches using M-x grep, and the
resulting grep matches lines of the form:

  Entering directory `/some/bogus/directory/here'

And if you then click on lines _after_ the line such as the "Entering
directory" line, then you get a prompt asking about "Find this grep
hit in" which is not correct grep mode like it probably is correct in
compile mode.

For some reason, this seems to only occur for cases where the grep
buffer is saved to a file and then reloaded, but I have seen this
occur in my non-"-Q" session for my own scripts I use to run grep
(versus running grep directly), and I have not debugged it further
than this bug I am reporting now that relies upon first saving the
grep mode buffer to a file and reloading it (see below).

You can reproduce this on Emacs built from scratch by following the
following recipe that simulates it:

1. On Linux, cut and paste the following into a file called
   /tmp/demo-bug.el:

--- cut here ---
(let* ((tmpdir (expand-file-name (make-temp-name "emacs-bug-demo-dir")
temporary-file-directory))
       (fn1 (expand-file-name "somefile1.txt" tmpdir))
       (fn2 (expand-file-name "somefile2.txt" tmpdir))
       (saved-grep-file (expand-file-name "somegrep.txt" tmpdir)))
  (make-directory tmpdir t)
  (with-temp-file fn1
    (insert "# | make[3]: Entering directory `/some/bogus/directory/here'"))
  (with-temp-file fn2
    (insert "This is a line that also has the Entering word on it.
Click on this line in grep mode."))
  ;; For debugging, just wipe out all other grep buffers from the current
  ;; session:
  (mapc (lambda (buffer)
      (with-current-buffer buffer
        (when (eq major-mode 'grep-mode)
          (kill-buffer buffer))))
    (buffer-list))
  ;; Force default-directory in some buffer to be that where our temporary files
  ;; reside, e.g., fn2 is good enough:
  (with-current-buffer (progn
             (find-file fn2)
             (current-buffer))
    (grep "grep -n Entering *.txt")
    ;; Let the grep finish:
    (accept-process-output nil 1))
  (with-current-buffer (get-buffer "*grep*")
    (let ((contents (buffer-string)))
      ;; Store the grep contents into a file (without this, the error does not
      ;; reproduce ... I do not know why):
      (with-temp-file saved-grep-file
    (insert contents))
      (find-file saved-grep-file)
      (goto-char (point-min))
      (re-search-forward "Click on this line in grep mode")
      (call-interactively 'compile-goto-error))))

--- cut here ---

2. Execute the above file via this command:

   emacs -Q -l /tmp/demo-bug.el:

Notice that I call `compile-goto-error' interactively above to
simulate what you would do if you hit the RETurn key on that line. You
should expect to see a prompt for "Find this grep hit in" versus what
it should do which is drive straight to that line that contains the
"Click on this line in grep mode" string shown.

Theory of cause:

I conjecture that the fault lies in the fact that grep mode needs to
define a variable called `grep-directory-matcher' that is the analog
of `compilation-directory-matcher' which is deployed as a buffer local
variable when the grep mode is defined with its call to
`define-compilation-mode'. I have proved this by my hackaround this
bug that I have in place right now, which is this in my .emacs:

;; Require grep mode first
(require 'grep)

;; Hack in our definition of grep-directory-matcher and force grep mode to
;; use it. We have to do this after the above require of grep:
(defvar grep-directory-matcher nil)
(let* ((base (find-lisp-object-file-name 'grep (symbol-function 'grep)))
       (grep-defining-elisp-file
    (car
     (remove-if-not (lambda (fn)
              (file-exists-p fn))
            (list base
                  (concat base ".gz"))))))
  (unless grep-defining-elisp-file
    (error "ASSERTION FAILED: Could not find grep defining file in
order to hack it"))
  ;; Force the file to load which forces another evaluation of the call to
  ;; define-compilation-mode from within that file. This is the only way I could
  ;; figure out how to hack around this problem other than globally setting
  ;; compilation-directory-matcher to nil which is not right for all compilation
  ;; mode buffers in general:
  (load grep-defining-elisp-file))



Thanks,

bgoodr


If Emacs crashed, and you have the Emacs process in the gdb debugger,
please include the output from the following gdb commands:
    `bt full' and `xbacktrace'.
For information about debugging Emacs, please read the file
/home/brentg/install/Linux.x86_64/share/emacs/24.0.50/etc/DEBUG.


In GNU Emacs 24.0.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.20.1)
 of 2011-01-15 on hungover
Windowing system distributor `The X.Org Foundation', version 11.0.10707000
configured using `configure  '--with-x-toolkit' '--with-xft'
'--prefix=/home/brentg/install/Linux.x86_64''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Grep

Minor modes in effect:
  tooltip-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
C-g M-x r e p o r t - e m a <tab> <return>

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Grep finished (matches found)
Mark set
Quit

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr message sendmail rfc822 mml easymenu
mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mailabbrev mail-utils gmm-utils mailheader
emacsbug grep compile comint regexp-opt ring tooltip ediff-hook vc-hooks
lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image fringe
lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev
loaddefs button minibuffer faces cus-face files text-properties overlay
md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process dbusbind
dynamic-setting system-font-setting font-render-setting move-toolbar gtk
x-toolkit x multi-tty emacs)





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

* bug#8684: 24.0.50; Grep mode trips up on Entering directory lines
  2011-05-17 15:52 bug#8684: 24.0.50; Grep mode trips up on Entering directory lines Brent Goodrick
@ 2011-05-17 18:15 ` Stefan Monnier
  2011-05-17 19:33   ` Brent Goodrick
  2011-05-20 23:19 ` bug#8684: The fix introduce another bug sss
  1 sibling, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2011-05-17 18:15 UTC (permalink / raw)
  To: Brent Goodrick; +Cc: 8684

> When you are searching build logs for matches using M-x grep, and the
> resulting grep matches lines of the form:

>   Entering directory `/some/bogus/directory/here'

> And if you then click on lines _after_ the line such as the "Entering
> directory" line, then you get a prompt asking about "Find this grep
> hit in" which is not correct grep mode like it probably is correct in
> compile mode.

Does the patch below help?


        Stefan


=== modified file 'lisp/progmodes/grep.el'
--- lisp/progmodes/grep.el	2011-05-12 15:10:17 +0000
+++ lisp/progmodes/grep.el	2011-05-17 18:07:41 +0000
@@ -698,6 +698,7 @@
        grep-hit-face)
   (set (make-local-variable 'compilation-error-regexp-alist)
        grep-regexp-alist)
+  (set (make-local-variable 'compilation-directory-matcher) nil)
   (set (make-local-variable 'compilation-process-setup-function)
        'grep-process-setup)
   (set (make-local-variable 'compilation-disable-input) t)






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

* bug#8684: 24.0.50; Grep mode trips up on Entering directory lines
  2011-05-17 18:15 ` Stefan Monnier
@ 2011-05-17 19:33   ` Brent Goodrick
  2011-05-17 20:56     ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Brent Goodrick @ 2011-05-17 19:33 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 8684

Hi Stefan,

Yes, that does fix the issue and seems like an acceptable fix IMO.

Thanks,
bg

On Tue, May 17, 2011 at 11:15 AM, Stefan Monnier
<monnier@iro.umontreal.ca> wrote:
>> When you are searching build logs for matches using M-x grep, and the
>> resulting grep matches lines of the form:
>
>>   Entering directory `/some/bogus/directory/here'
>
>> And if you then click on lines _after_ the line such as the "Entering
>> directory" line, then you get a prompt asking about "Find this grep
>> hit in" which is not correct grep mode like it probably is correct in
>> compile mode.
>
> Does the patch below help?
>
>
>        Stefan
>
>
> === modified file 'lisp/progmodes/grep.el'
> --- lisp/progmodes/grep.el      2011-05-12 15:10:17 +0000
> +++ lisp/progmodes/grep.el      2011-05-17 18:07:41 +0000
> @@ -698,6 +698,7 @@
>        grep-hit-face)
>   (set (make-local-variable 'compilation-error-regexp-alist)
>        grep-regexp-alist)
> +  (set (make-local-variable 'compilation-directory-matcher) nil)
>   (set (make-local-variable 'compilation-process-setup-function)
>        'grep-process-setup)
>   (set (make-local-variable 'compilation-disable-input) t)
>
>





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

* bug#8684: 24.0.50; Grep mode trips up on Entering directory lines
  2011-05-17 19:33   ` Brent Goodrick
@ 2011-05-17 20:56     ` Stefan Monnier
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2011-05-17 20:56 UTC (permalink / raw)
  To: Brent Goodrick; +Cc: 8684-done

> Yes, that does fix the issue and seems like an acceptable fix IMO.

Thank you, installed,


        Stefan





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

* bug#8684: The fix introduce another bug
  2011-05-17 15:52 bug#8684: 24.0.50; Grep mode trips up on Entering directory lines Brent Goodrick
  2011-05-17 18:15 ` Stefan Monnier
@ 2011-05-20 23:19 ` sss
  2011-05-21 23:19   ` Stefan Monnier
  1 sibling, 1 reply; 6+ messages in thread
From: sss @ 2011-05-20 23:19 UTC (permalink / raw)
  To: 8684

[-- Attachment #1: Type: text/plain, Size: 166 bytes --]

When type enter key in *grep* buffer, the following message will showed.

compilation-next-error: No grep hit here.

If I revert the change, the message disappears.


[-- Attachment #2: Type: text/html, Size: 274 bytes --]

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

* bug#8684: The fix introduce another bug
  2011-05-20 23:19 ` bug#8684: The fix introduce another bug sss
@ 2011-05-21 23:19   ` Stefan Monnier
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2011-05-21 23:19 UTC (permalink / raw)
  To: sss; +Cc: 8684

> When type enter key in *grep* buffer, the following message will showed.
> compilation-next-error: No grep hit here.
> If I revert the change, the message disappears.

I've installed the patch below which should hopefully fix the original
problem as well as the new one.


        Stefan


=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog	2011-05-21 22:33:12 +0000
+++ lisp/ChangeLog	2011-05-21 23:17:35 +0000
@@ -1,3 +1,7 @@
+2011-05-21  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* progmodes/grep.el (grep-mode): Fix last change (bug#8684).
+
 2011-05-21  Glenn Morris  <rgm@gnu.org>
 
 	* files.el (hack-local-variables-prop-line, hack-local-variables):

=== modified file 'lisp/progmodes/grep.el'
--- lisp/progmodes/grep.el	2011-05-17 18:14:30 +0000
+++ lisp/progmodes/grep.el	2011-05-21 23:13:56 +0000
@@ -698,7 +698,9 @@
        grep-hit-face)
   (set (make-local-variable 'compilation-error-regexp-alist)
        grep-regexp-alist)
-  (set (make-local-variable 'compilation-directory-matcher) nil)
+  ;; compilation-directory-matcher can't be nil, so we set it to a regexp that
+  ;; can never match.
+  (set (make-local-variable 'compilation-directory-matcher) "\\`a\\`")
   (set (make-local-variable 'compilation-process-setup-function)
        'grep-process-setup)
   (set (make-local-variable 'compilation-disable-input) t)






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

end of thread, other threads:[~2011-05-21 23:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-17 15:52 bug#8684: 24.0.50; Grep mode trips up on Entering directory lines Brent Goodrick
2011-05-17 18:15 ` Stefan Monnier
2011-05-17 19:33   ` Brent Goodrick
2011-05-17 20:56     ` Stefan Monnier
2011-05-20 23:19 ` bug#8684: The fix introduce another bug sss
2011-05-21 23:19   ` Stefan Monnier

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