unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#30503: 27.0.50; allow hiding M-x grep command line
@ 2018-02-17 16:25 Charles A. Roelli
  2018-02-17 17:06 ` Eli Zaretskii
  2018-02-20 20:54 ` Juri Linkov
  0 siblings, 2 replies; 14+ messages in thread
From: Charles A. Roelli @ 2018-02-17 16:25 UTC (permalink / raw)
  To: 30503

The first thing you see after M-x grep is a 1382-character line like
this:

find . -type d \( -path \*/SCCS -o -path \*/RCS -o -path \*/CVS -o -path \*/MCVS -o -path \*/.src -o -path \*/.svn -o -path \*/.git -o -path \*/.hg -o -path \*/.bzr -o -path \*/_MTN -o -path \*/_darcs -o -path \*/\{arch\} \) -prune -o \! -type d \( -name .\#\* -o -name \*.o -o -name \*\~ -o -name \*.bin -o -name \*.lbin -o -name \*.so -o -name \*.a -o -name \*.ln -o -name \*.blg -o -name \*.bbl -o -name \*.elc -o -name \*.lof -o -name \*.glo -o -name \*.idx -o -name \*.lot -o -name \*.fmt -o -name \*.tfm -o -name \*.class -o -name \*.fas -o -name \*.lib -o -name \*.mem -o -name \*.x86f -o -name \*.sparcf -o -name \*.dfsl -o -name \*.pfsl -o -name \*.d64fsl -o -name \*.p64fsl -o -name \*.lx64fsl -o -name \*.lx32fsl -o -name \*.dx64fsl -o -name \*.dx32fsl -o -name \*.fx64fsl -o -name \*.fx32
 fsl -o -name \*.sx64fsl -o -name \*.sx32fsl -o -name \*.wx64fsl -o -name \*.wx32fsl -o -name \*.fasl -o -name \*.ufsl -o -name \*.fsl -o -name \*.dxl -o -name \*.lo -o -name \*.la -o -name \*.gmo -o
  -name \*.mo -o -name \*.toc -o -name \*.aux -o -name \*.cp -o -name \*.fn -o -name \*.ky -o -name \*.pg -o -name \*.tp -o -name \*.vr -o -name \*.cps -o -name \*.fns -o -name \*.kys -o -name \*.pgs -o -name \*.tps -o -name \*.vrs -o -name \*.pyc -o -name \*.pyo \) -prune -o  -type f \( -iname \* -o -iname .\[\!.\]\* -o -iname ..\?\* \) -exec grep --color -nH --null -e Emacs \{\} +

Could we provide an option to hide the barrage of ignored directories
and files?  It might also be worth adding a text button or keybinding
to toggle their visibility interactively.





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

* bug#30503: 27.0.50; allow hiding M-x grep command line
  2018-02-17 16:25 bug#30503: 27.0.50; allow hiding M-x grep command line Charles A. Roelli
@ 2018-02-17 17:06 ` Eli Zaretskii
  2018-02-17 19:13   ` Charles A. Roelli
  2018-02-20 20:54 ` Juri Linkov
  1 sibling, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2018-02-17 17:06 UTC (permalink / raw)
  To: Charles A. Roelli; +Cc: 30503

> Date: Sat, 17 Feb 2018 17:25:20 +0100
> From: charles@aurox.ch (Charles A. Roelli)
> 
> The first thing you see after M-x grep is a 1382-character line like
> this:

You mean "M-x rgrep", right?





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

* bug#30503: 27.0.50; allow hiding M-x grep command line
  2018-02-17 17:06 ` Eli Zaretskii
@ 2018-02-17 19:13   ` Charles A. Roelli
  0 siblings, 0 replies; 14+ messages in thread
From: Charles A. Roelli @ 2018-02-17 19:13 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 30503

retitle 30503 allow hiding M-x rgrep/lgrep/zrgrep command line
--

> You mean "M-x rgrep", right?

Yes (mea culpa), and in principle "lgrep" and "zrgrep" too.





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

* bug#30503: 27.0.50; allow hiding M-x grep command line
  2018-02-17 16:25 bug#30503: 27.0.50; allow hiding M-x grep command line Charles A. Roelli
  2018-02-17 17:06 ` Eli Zaretskii
@ 2018-02-20 20:54 ` Juri Linkov
  2018-02-21  3:44   ` Eli Zaretskii
  2018-02-21 20:30   ` Charles A. Roelli
  1 sibling, 2 replies; 14+ messages in thread
From: Juri Linkov @ 2018-02-20 20:54 UTC (permalink / raw)
  To: Charles A. Roelli; +Cc: 30503

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

retitle 30503 allow hiding M-x rgrep/lgrep/zrgrep command line
thanks

> The first thing you see after M-x grep is a 1382-character line like
> this:
>
> find . -type d \( -path \*/SCCS -o -path \*/RCS -o -path \*/CVS -o -path
> \*/MCVS -o -path \*/.src -o -path \*/.svn -o -path \*/.git -o -path
> \*/.hg -o -path \*/.bzr -o -path \*/_MTN -o -path \*/_darcs -o -path
> \*/\{arch\} \) -prune -o \! -type d \( -name .\#\* -o -name \*.o -o -name
> \*\~ -o -name \*.bin -o -name \*.lbin -o -name \*.so -o -name \*.a -o -name
> \*.ln -o -name \*.blg -o -name \*.bbl -o -name \*.elc -o -name
> \*.lof -o -name \*.glo -o -name \*.idx -o -name \*.lot -o -name
> \*.fmt -o -name \*.tfm -o -name \*.class -o -name \*.fas -o -name
> \*.lib -o -name \*.mem -o -name \*.x86f -o -name \*.sparcf -o -name
> \*.dfsl -o -name \*.pfsl -o -name \*.d64fsl -o -name \*.p64fsl -o -name
> \*.lx64fsl -o -name \*.lx32fsl -o -name \*.dx64fsl -o -name
> \*.dx32fsl -o -name \*.fx64fsl -o -name \*.fx32fsl -o -name
> \*.sx64fsl -o -name \*.sx32fsl -o -name \*.wx64fsl -o -name
> \*.wx32fsl -o -name \*.fasl -o -name \*.ufsl -o -name \*.fsl -o -name
> \*.dxl -o -name \*.lo -o -name \*.la -o -name \*.gmo -o
>   -name \*.mo -o -name \*.toc -o -name \*.aux -o -name \*.cp -o -name
> \*.fn -o -name \*.ky -o -name \*.pg -o -name \*.tp -o -name \*.vr -o -name
> \*.cps -o -name \*.fns -o -name \*.kys -o -name \*.pgs -o -name
> \*.tps -o -name \*.vrs -o -name \*.pyc -o -name \*.pyo \) -prune -o -type
> f \( -iname \* -o -iname .\[\!.\]\* -o -iname ..\?\* \) -exec
> grep --color -nH --null -e Emacs \{\} +
>
> Could we provide an option to hide the barrage of ignored directories
> and files?  It might also be worth adding a text button or keybinding
> to toggle their visibility interactively.

Yes, this is a real problem.  Even though I set truncate-lines to t,
often there is a need to see grep switches at the end of the
command line.  So there is a patch to hide uninteresting parts
under a button like is used to hide part of output by
elisp-last-sexp-toggle-display.  It supports rgrep, lgrep and zrgrep.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: grep-hide.patch --]
[-- Type: text/x-diff, Size: 2169 bytes --]

diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index 14e251e..34a9b2f 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -452,7 +452,13 @@ grep-mode-font-lock-keywords
      ;; "filename=linenumber=" for lines with function names in "git grep -p".
      ("^.+?\\([-=\0]\\)[0-9]+\\([-=]\\).*\n" (0 grep-context-face)
       (1 (if (eq (char-after (match-beginning 1)) ?\0)
-             `(face nil display ,(match-string 2))))))
+             `(face nil display ,(match-string 2)))))
+     ;; Hide excessive part of the command from rgrep
+     ("^find \\(\\. -type d .*\\\\)\\)"
+      (1 (rgrep-command-hide)))
+     ;; Hide excessive part of the command from lgrep
+     ("^grep \\( *--exclude.*--exclude[^ ]+\\)"
+      (1 (rgrep-command-hide))))
    "Additional things to highlight in grep output.
 This gets tacked on the end of the generated expressions.")
 
@@ -1166,6 +1173,32 @@ rgrep-default-command
                  (shell-quote-argument ")")
                  " -prune -o ")))))
 
+(defun rgrep-command-hide ()
+  (let ((map (make-sparse-keymap)))
+    (define-key map [down-mouse-2] 'mouse-set-point)
+    (define-key map [mouse-2] 'rgrep-command-show)
+    (define-key map "\C-m" 'rgrep-command-show)
+    `(face nil display "[...]" mouse-face highlight
+	   help-echo "RET, mouse-2: toggle truncated command"
+	   keymap ,map)))
+
+(defun rgrep-command-show ()
+  (interactive)
+  (when (get-text-property (point) 'display)
+    (let ((beg (or (previous-single-property-change
+                    (min (point-max) (1+ (point))) 'display)
+                   (point)))
+          (end (or (next-single-property-change
+                    (point) 'display)
+                   (point)))
+          (inhibit-modification-hooks t)
+          (inhibit-read-only t)
+	  (buffer-undo-list t)
+	  (modified (buffer-modified-p)))
+      (remove-list-of-text-properties
+       beg end '(display help-echo mouse-face help-echo keymap))
+      (set-buffer-modified-p modified))))
+
 ;;;###autoload
 (defun zrgrep (regexp &optional files dir confirm template)
   "Recursively grep for REGEXP in gzipped FILES in tree rooted at DIR.

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

* bug#30503: 27.0.50; allow hiding M-x grep command line
  2018-02-20 20:54 ` Juri Linkov
@ 2018-02-21  3:44   ` Eli Zaretskii
  2018-02-21 20:20     ` Juri Linkov
  2018-02-21 20:30   ` Charles A. Roelli
  1 sibling, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2018-02-21  3:44 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 30503, charles

> From: Juri Linkov <juri@linkov.net>
> Date: Tue, 20 Feb 2018 22:54:34 +0200
> Cc: 30503@debbugs.gnu.org
> 
> > Could we provide an option to hide the barrage of ignored directories
> > and files?  It might also be worth adding a text button or keybinding
> > to toggle their visibility interactively.
> 
> Yes, this is a real problem.  Even though I set truncate-lines to t,
> often there is a need to see grep switches at the end of the
> command line.  So there is a patch to hide uninteresting parts
> under a button like is used to hide part of output by
> elisp-last-sexp-toggle-display.  It supports rgrep, lgrep and zrgrep.

Thanks, but where's the option to hide the long list?  It looks like
this patch changes the behavior unconditionally, and makes it
strikingly different from the previous behavior.

In any case, this needs to be documented in NEWS and the manual, I
think.





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

* bug#30503: 27.0.50; allow hiding M-x grep command line
  2018-02-21  3:44   ` Eli Zaretskii
@ 2018-02-21 20:20     ` Juri Linkov
  2018-02-22  7:43       ` Eli Zaretskii
  0 siblings, 1 reply; 14+ messages in thread
From: Juri Linkov @ 2018-02-21 20:20 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 30503, charles

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

>> > Could we provide an option to hide the barrage of ignored directories
>> > and files?  It might also be worth adding a text button or keybinding
>> > to toggle their visibility interactively.
>>
>> Yes, this is a real problem.  Even though I set truncate-lines to t,
>> often there is a need to see grep switches at the end of the
>> command line.  So there is a patch to hide uninteresting parts
>> under a button like is used to hide part of output by
>> elisp-last-sexp-toggle-display.  It supports rgrep, lgrep and zrgrep.
>
> Thanks, but where's the option to hide the long list?  It looks like
> this patch changes the behavior unconditionally, and makes it
> strikingly different from the previous behavior.

Like there is the option eval-expression-print-length to disable hiding
of long output from eval-last-sexp, we could add a similar option here
as well.

> In any case, this needs to be documented in NEWS and the manual, I
> think.

Changes to NEWS are added in this patch without “---” to not forget
to document it in the manual before the release of Emacs 27.1.


[-- Attachment #2: grep-hide.2.patch --]
[-- Type: text/x-diff, Size: 3572 bytes --]

diff --git a/etc/NEWS b/etc/NEWS
index 71569c9..0ba369e7 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -158,6 +158,13 @@ by default.
 
 ** Gamegrid
 
+** grep
+
+*** rgrep, lgrep and zrgrep now hide part of the command line
+that contains a list of ignored directories and files.
+Clicking on the button with ellipsis unhides the truncated part.
+This truncation can be disabled by the new option 'rgrep-command-hide'.
+
 ** ERT
 
 +++
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index 14e251e..d249c51 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -433,6 +433,26 @@ grep-mode-line-matches
                       help-echo "Number of matches so far")
     "]"))
 
+(defcustom rgrep-command-hide t
+  "If non-nil, hide part of rgrep/lgrep/zrgrep command line.
+The hidden part contains a list of ignored directories and files.
+Clicking on the button-like ellipsis unhides the abbreviated part
+and reveals the entire command line."
+  :type 'boolean
+  :version "27.1"
+  :group 'grep)
+
+(defvar rgrep-command-hide-properties
+  (let ((ellipsis (if (char-displayable-p ?…) "[…]" "[...]"))
+        (map (make-sparse-keymap)))
+    (define-key map [down-mouse-2] 'mouse-set-point)
+    (define-key map [mouse-2] 'rgrep-command-show)
+    (define-key map "\C-m" 'rgrep-command-show)
+    `(face nil display ,ellipsis mouse-face highlight
+      help-echo "RET, mouse-2: show unabbreviated command"
+      keymap ,map))
+  "Properties of button-like ellipsis on part of rgrep command line.")
+
 (defvar grep-mode-font-lock-keywords
    '(;; Command output lines.
      (": \\(.+\\): \\(?:Permission denied\\|No such \\(?:file or directory\\|device or address\\)\\)$"
@@ -452,7 +472,13 @@ grep-mode-font-lock-keywords
      ;; "filename=linenumber=" for lines with function names in "git grep -p".
      ("^.+?\\([-=\0]\\)[0-9]+\\([-=]\\).*\n" (0 grep-context-face)
       (1 (if (eq (char-after (match-beginning 1)) ?\0)
-             `(face nil display ,(match-string 2))))))
+             `(face nil display ,(match-string 2)))))
+     ;; Hide excessive part of rgrep command
+     ("^find \\(\\. -type d .*\\\\)\\)"
+      (1 (when rgrep-command-hide rgrep-command-hide-properties)))
+     ;; Hide excessive part of lgrep command
+     ("^grep \\( *--exclude.*--exclude[^ ]+\\)"
+      (1 (when rgrep-command-hide rgrep-command-hide-properties))))
    "Additional things to highlight in grep output.
 This gets tacked on the end of the generated expressions.")
 
@@ -1166,6 +1192,24 @@ rgrep-default-command
                  (shell-quote-argument ")")
                  " -prune -o ")))))
 
+(defun rgrep-command-show ()
+  "Show the hidden part of rgrep/lgrep/zrgrep command line."
+  (interactive)
+  (when (get-text-property (point) 'display)
+    (let ((beg (or (previous-single-property-change
+                    (min (point-max) (1+ (point))) 'display)
+                   (point)))
+          (end (or (next-single-property-change
+                    (point) 'display)
+                   (point)))
+          (inhibit-modification-hooks t)
+          (inhibit-read-only t)
+	  (buffer-undo-list t)
+	  (modified (buffer-modified-p)))
+      (remove-list-of-text-properties
+       beg end '(display help-echo mouse-face help-echo keymap))
+      (set-buffer-modified-p modified))))
+
 ;;;###autoload
 (defun zrgrep (regexp &optional files dir confirm template)
   "Recursively grep for REGEXP in gzipped FILES in tree rooted at DIR.

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

* bug#30503: 27.0.50; allow hiding M-x grep command line
  2018-02-20 20:54 ` Juri Linkov
  2018-02-21  3:44   ` Eli Zaretskii
@ 2018-02-21 20:30   ` Charles A. Roelli
  1 sibling, 0 replies; 14+ messages in thread
From: Charles A. Roelli @ 2018-02-21 20:30 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 30503

> From: Juri Linkov <juri@linkov.net>
> Organization: LINKOV.NET
> Date: Tue, 20 Feb 2018 22:54:34 +0200
> 
> retitle 30503 allow hiding M-x rgrep/lgrep/zrgrep command line
> thanks
> 
> > The first thing you see after M-x grep is a 1382-character line like
> > this:
> >
> > find . -type d \( -path \*/SCCS -o -path \*/RCS -o -path \*/CVS -o -path
> > \*/MCVS -o -path \*/.src -o -path \*/.svn -o -path \*/.git -o -path
> > \*/.hg -o -path \*/.bzr -o -path \*/_MTN -o -path \*/_darcs -o -path
> > \*/\{arch\} \) -prune -o \! -type d \( -name .\#\* -o -name \*.o -o -name
> > \*\~ -o -name \*.bin -o -name \*.lbin -o -name \*.so -o -name \*.a -o -name
> > \*.ln -o -name \*.blg -o -name \*.bbl -o -name \*.elc -o -name
> > \*.lof -o -name \*.glo -o -name \*.idx -o -name \*.lot -o -name
> > \*.fmt -o -name \*.tfm -o -name \*.class -o -name \*.fas -o -name
> > \*.lib -o -name \*.mem -o -name \*.x86f -o -name \*.sparcf -o -name
> > \*.dfsl -o -name \*.pfsl -o -name \*.d64fsl -o -name \*.p64fsl -o -name
> > \*.lx64fsl -o -name \*.lx32fsl -o -name \*.dx64fsl -o -name
> > \*.dx32fsl -o -name \*.fx64fsl -o -name \*.fx32fsl -o -name
> > \*.sx64fsl -o -name \*.sx32fsl -o -name \*.wx64fsl -o -name
> > \*.wx32fsl -o -name \*.fasl -o -name \*.ufsl -o -name \*.fsl -o -name
> > \*.dxl -o -name \*.lo -o -name \*.la -o -name \*.gmo -o
> >   -name \*.mo -o -name \*.toc -o -name \*.aux -o -name \*.cp -o -name
> > \*.fn -o -name \*.ky -o -name \*.pg -o -name \*.tp -o -name \*.vr -o -name
> > \*.cps -o -name \*.fns -o -name \*.kys -o -name \*.pgs -o -name
> > \*.tps -o -name \*.vrs -o -name \*.pyc -o -name \*.pyo \) -prune -o -type
> > f \( -iname \* -o -iname .\[\!.\]\* -o -iname ..\?\* \) -exec
> > grep --color -nH --null -e Emacs \{\} +
> >
> > Could we provide an option to hide the barrage of ignored directories
> > and files?  It might also be worth adding a text button or keybinding
> > to toggle their visibility interactively.
> 
> Yes, this is a real problem.  Even though I set truncate-lines to t,
> often there is a need to see grep switches at the end of the
> command line.  So there is a patch to hide uninteresting parts
> under a button like is used to hide part of output by
> elisp-last-sexp-toggle-display.  It supports rgrep, lgrep and zrgrep.
>
> 
> diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
> index 14e251e..34a9b2f 100644
> --- a/lisp/progmodes/grep.el
> +++ b/lisp/progmodes/grep.el
> @@ -452,7 +452,13 @@ grep-mode-font-lock-keywords
>       ;; "filename=linenumber=" for lines with function names in "git grep -p".
>       ("^.+?\\([-=\0]\\)[0-9]+\\([-=]\\).*\n" (0 grep-context-face)
>        (1 (if (eq (char-after (match-beginning 1)) ?\0)
> -             `(face nil display ,(match-string 2))))))
> +             `(face nil display ,(match-string 2)))))
> +     ;; Hide excessive part of the command from rgrep
> +     ("^find \\(\\. -type d .*\\\\)\\)"
> +      (1 (rgrep-command-hide)))
> +     ;; Hide excessive part of the command from lgrep
> +     ("^grep \\( *--exclude.*--exclude[^ ]+\\)"
> +      (1 (rgrep-command-hide))))
>     "Additional things to highlight in grep output.
>  This gets tacked on the end of the generated expressions.")
>  
> @@ -1166,6 +1173,32 @@ rgrep-default-command
>                   (shell-quote-argument ")")
>                   " -prune -o ")))))
>  
> +(defun rgrep-command-hide ()
> +  (let ((map (make-sparse-keymap)))
> +    (define-key map [down-mouse-2] 'mouse-set-point)
> +    (define-key map [mouse-2] 'rgrep-command-show)
> +    (define-key map "\C-m" 'rgrep-command-show)
> +    `(face nil display "[...]" mouse-face highlight
> +	   help-echo "RET, mouse-2: toggle truncated command"
> +	   keymap ,map)))
> +
> +(defun rgrep-command-show ()
> +  (interactive)
> +  (when (get-text-property (point) 'display)
> +    (let ((beg (or (previous-single-property-change
> +                    (min (point-max) (1+ (point))) 'display)
> +                   (point)))
> +          (end (or (next-single-property-change
> +                    (point) 'display)
> +                   (point)))
> +          (inhibit-modification-hooks t)
> +          (inhibit-read-only t)
> +	  (buffer-undo-list t)
> +	  (modified (buffer-modified-p)))
> +      (remove-list-of-text-properties
> +       beg end '(display help-echo mouse-face help-echo keymap))
> +      (set-buffer-modified-p modified))))
> +
>  ;;;###autoload
>  (defun zrgrep (regexp &optional files dir confirm template)
>    "Recursively grep for REGEXP in gzipped FILES in tree rooted at DIR.

Thanks, this is a great start.

I iterated on your patch, with a few changes:

- Change naming to start with `grep' instead of `rgrep' (the position
  of the functions may still have to change within the file).
- Use `with-silent-modifications'.
- Provide a toggling command for hiding/showing the shortened command.

What still remains to be added is the doc, a possible keybinding/menu
item, and a customization variable that determines whether the hiding
is done immediately for every rgrep/lgrep/rzgrep buffer.  And I think
there's some room for error in my change to the beg/end let-bindings
in grep-toggle-shortened-command (e.g. if beg ends up being nil), so
I'll fix that eventually as well.

diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index 14e251e..6699787 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -452,7 +452,13 @@ grep-mode-font-lock-keywords
      ;; "filename=linenumber=" for lines with function names in "git grep -p".
      ("^.+?\\([-=\0]\\)[0-9]+\\([-=]\\).*\n" (0 grep-context-face)
       (1 (if (eq (char-after (match-beginning 1)) ?\0)
-             `(face nil display ,(match-string 2))))))
+             `(face nil display ,(match-string 2)))))
+     ;; Hide excessive part of the command from rgrep
+     ("^find \\(\\. -type d .*\\\\)\\)"
+      (1 (grep-shortened-command-properties)))
+     ;; Hide excessive part of the command from lgrep
+     ("^grep \\( *--exclude.*--exclude[^ ]+\\)"
+      (1 (grep-shortened-command-properties))))
    "Additional things to highlight in grep output.
 This gets tacked on the end of the generated expressions.")
 
@@ -1166,6 +1172,30 @@ rgrep-default-command
                  (shell-quote-argument ")")
                  " -prune -o ")))))
 
+(defun grep-shortened-command-properties ()
+  "Return a list of text properties applied to verbose command arguments."
+  (let ((map (make-sparse-keymap)))
+    (define-key map [down-mouse-2] 'mouse-set-point)
+    (define-key map [mouse-2] 'grep-toggle-shortened-command)
+    (define-key map "\C-m" 'grep-toggle-shortened-command)
+    `(face nil display "[...]" mouse-face highlight
+	   help-echo "RET, mouse-2: toggle shortened command"
+	   keymap ,map
+	   shortened-command t)))
+
+(defun grep-toggle-shortened-command ()
+  "Toggle the display of a shortened command in `grep-mode' buffers."
+  (interactive)
+  (with-silent-modifications
+    (let* ((beg (next-single-property-change
+		 (point-min) 'shortened-command))
+	   (end (next-single-property-change
+		 beg 'shortened-command)))
+      (if (get-text-property beg 'display)
+	  (remove-list-of-text-properties
+	   beg end '(display help-echo mouse-face help-echo keymap))
+	(add-text-properties beg end (grep-shortened-command-properties))))))
+
 ;;;###autoload
 (defun zrgrep (regexp &optional files dir confirm template)
   "Recursively grep for REGEXP in gzipped FILES in tree rooted at DIR.





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

* bug#30503: 27.0.50; allow hiding M-x grep command line
  2018-02-21 20:20     ` Juri Linkov
@ 2018-02-22  7:43       ` Eli Zaretskii
  2018-02-22 21:51         ` Juri Linkov
  0 siblings, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2018-02-22  7:43 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 30503, charles

> From: Juri Linkov <juri@linkov.net>
> Cc: charles@aurox.ch,  30503@debbugs.gnu.org
> Date: Wed, 21 Feb 2018 22:20:55 +0200
> 
> > In any case, this needs to be documented in NEWS and the manual, I
> > think.
> 
> Changes to NEWS are added in this patch without “---” to not forget
> to document it in the manual before the release of Emacs 27.1.

Thanks, but I'd prefer that we update the manual as part of this
changeset.  Leaving manuals outdated tends to create a very large job
to be done before a pretest can be released, which I find to be
sub-optimal.  It also prevents users who track the development from
finding possible mistakes in the manual, because they don't have
enough time to d that before an official release.

Would you like to make the corrections in the manual as well?





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

* bug#30503: 27.0.50; allow hiding M-x grep command line
  2018-02-22  7:43       ` Eli Zaretskii
@ 2018-02-22 21:51         ` Juri Linkov
  2018-02-23  6:55           ` Eli Zaretskii
  2018-02-25 19:50           ` Charles A. Roelli
  0 siblings, 2 replies; 14+ messages in thread
From: Juri Linkov @ 2018-02-22 21:51 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 30503, charles

>> > In any case, this needs to be documented in NEWS and the manual, I
>> > think.
>>
>> Changes to NEWS are added in this patch without “---” to not forget
>> to document it in the manual before the release of Emacs 27.1.
>
> Thanks, but I'd prefer that we update the manual as part of this
> changeset.  Leaving manuals outdated tends to create a very large job
> to be done before a pretest can be released, which I find to be
> sub-optimal.  It also prevents users who track the development from
> finding possible mistakes in the manual, because they don't have
> enough time to d that before an official release.
>
> Would you like to make the corrections in the manual as well?

Pushed to master together with the corrections in the manual.

Charles, please update your patch from master, you have many
good improvements in your previous patch.





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

* bug#30503: 27.0.50; allow hiding M-x grep command line
  2018-02-22 21:51         ` Juri Linkov
@ 2018-02-23  6:55           ` Eli Zaretskii
  2018-02-25 19:50           ` Charles A. Roelli
  1 sibling, 0 replies; 14+ messages in thread
From: Eli Zaretskii @ 2018-02-23  6:55 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 30503, charles

> From: Juri Linkov <juri@linkov.net>
> Cc: charles@aurox.ch,  30503@debbugs.gnu.org
> Date: Thu, 22 Feb 2018 23:51:57 +0200
> 
> > Thanks, but I'd prefer that we update the manual as part of this
> > changeset.  Leaving manuals outdated tends to create a very large job
> > to be done before a pretest can be released, which I find to be
> > sub-optimal.  It also prevents users who track the development from
> > finding possible mistakes in the manual, because they don't have
> > enough time to d that before an official release.
> >
> > Would you like to make the corrections in the manual as well?
> 
> Pushed to master together with the corrections in the manual.

Thanks.





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

* bug#30503: 27.0.50; allow hiding M-x grep command line
  2018-02-22 21:51         ` Juri Linkov
  2018-02-23  6:55           ` Eli Zaretskii
@ 2018-02-25 19:50           ` Charles A. Roelli
  2018-02-27 21:06             ` Juri Linkov
  1 sibling, 1 reply; 14+ messages in thread
From: Charles A. Roelli @ 2018-02-25 19:50 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 30503

> From: Juri Linkov <juri@linkov.net>
> Cc: charles@aurox.ch,  30503@debbugs.gnu.org
> Organization: LINKOV.NET
> Date: Thu, 22 Feb 2018 23:51:57 +0200
> 
> >> > In any case, this needs to be documented in NEWS and the manual, I
> >> > think.
> >>
> >> Changes to NEWS are added in this patch without “---” to not forget
> >> to document it in the manual before the release of Emacs 27.1.
> >
> > Thanks, but I'd prefer that we update the manual as part of this
> > changeset.  Leaving manuals outdated tends to create a very large job
> > to be done before a pretest can be released, which I find to be
> > sub-optimal.  It also prevents users who track the development from
> > finding possible mistakes in the manual, because they don't have
> > enough time to d that before an official release.
> >
> > Would you like to make the corrections in the manual as well?
> 
> Pushed to master together with the corrections in the manual.
> 
> Charles, please update your patch from master, you have many
> good improvements in your previous patch.

Thanks for adding this feature.  Here's the change that implements a
toggling command.

diff --git a/doc/emacs/building.texi b/doc/emacs/building.texi
index 8e2fdf1..eee6329 100644
--- a/doc/emacs/building.texi
+++ b/doc/emacs/building.texi
@@ -435,13 +435,16 @@ Grep Searching
 by various version control systems.
 
 @vindex grep-find-hide
+@findex grep-find-toggle-abbreviation
   By default, the shell commands constructed for @code{lgrep},
 @code{rgrep}, and @code{zgrep} are abbreviated for display by
 concealing the part that contains a long list of files and directories
 to ignore.  You can reveal the concealed part by clicking on the
-button with ellipsis, which represents them.  To disable this
-abbreviation of the shell commands, customize the option
-@code{grep-find-hide} to a @code{nil} value.
+button with ellipsis, which represents them.  You can also
+interactively toggle viewing the concealed part by typing @kbd{M-x
+grep-find-toggle-abbreviation}.  To disable this abbreviation of the
+shell commands, customize the option @code{grep-find-hide} to a
+@code{nil} value.
 
 @node Flymake
 @section Finding Syntax Errors On The Fly
diff --git a/etc/NEWS b/etc/NEWS
index 596adf8..166b419 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -203,6 +203,8 @@ by default.
 that contains a list of ignored directories and files.
 Clicking on the button with ellipsis unhides the truncated part.
 This truncation can be disabled by the new option 'grep-find-hide'.
+The new command 'grep-find-toggle-abbreviation' toggles the hiding
+interactively.
 
 ** ERT
 
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index 9b2c6f1..67139b4 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -437,7 +437,9 @@ grep-find-hide
   "If non-nil, hide part of rgrep/lgrep/zrgrep command line.
 The hidden part contains a list of ignored directories and files.
 Clicking on the button-like ellipsis unhides the abbreviated part
-and reveals the entire command line."
+and reveals the entire command line.  The visibility of the
+abbreviated part can also be toggled with
+`grep-find-toggle-abbreviation'."
   :type 'boolean
   :version "27.1"
   :group 'grep)
@@ -446,11 +448,11 @@ grep-find-hide-properties
   (let ((ellipsis (if (char-displayable-p ?…) "[…]" "[...]"))
         (map (make-sparse-keymap)))
     (define-key map [down-mouse-2] 'mouse-set-point)
-    (define-key map [mouse-2] 'grep-find-show)
-    (define-key map "\C-m" 'grep-find-show)
+    (define-key map [mouse-2] 'grep-find-toggle-abbreviation)
+    (define-key map "\C-m" 'grep-find-toggle-abbreviation)
     `(face nil display ,ellipsis mouse-face highlight
       help-echo "RET, mouse-2: show unabbreviated command"
-      keymap ,map))
+      keymap ,map abbreviated-command t))
   "Properties of button-like ellipsis on part of rgrep command line.")
 
 (defvar grep-mode-font-lock-keywords
@@ -476,10 +478,12 @@ grep-mode-font-lock-keywords
              `(face nil display ,(match-string 2)))))
      ;; Hide excessive part of rgrep command
      ("^find \\(\\. -type d .*\\\\)\\)"
-      (1 (when grep-find-hide grep-find-hide-properties)))
+      (1 (if grep-find-hide grep-find-hide-properties
+           '(face nil abbreviated-command t))))
      ;; Hide excessive part of lgrep command
      ("^grep \\( *--exclude.*--exclude[^ ]+\\)"
-      (1 (when grep-find-hide grep-find-hide-properties))))
+      (1 (if grep-find-hide grep-find-hide-properties
+           '(face nil abbreviated-command t)))))
    "Additional things to highlight in grep output.
 This gets tacked on the end of the generated expressions.")
 
@@ -1195,23 +1199,19 @@ rgrep-default-command
                  (shell-quote-argument ")")
                  " -prune -o ")))))
 
-(defun grep-find-show ()
-  "Show the hidden part of rgrep/lgrep/zrgrep command line."
+(defun grep-find-toggle-abbreviation ()
+  "Toggle showing the hidden part of rgrep/lgrep/zrgrep command line."
   (interactive)
-  (when (get-text-property (point) 'display)
-    (let ((beg (or (previous-single-property-change
-                    (min (point-max) (1+ (point))) 'display)
-                   (point)))
-          (end (or (next-single-property-change
-                    (point) 'display)
-                   (point)))
-          (inhibit-modification-hooks t)
-          (inhibit-read-only t)
-	  (buffer-undo-list t)
-	  (modified (buffer-modified-p)))
-      (remove-list-of-text-properties
-       beg end '(display help-echo mouse-face help-echo keymap))
-      (set-buffer-modified-p modified))))
+  (with-silent-modifications
+    (let* ((beg (next-single-property-change (point-min) 'abbreviated-command))
+           (end (when beg
+                  (next-single-property-change beg 'abbreviated-command))))
+      (if end
+          (if (get-text-property beg 'display)
+              (remove-list-of-text-properties
+               beg end '(display help-echo mouse-face help-echo keymap))
+            (add-text-properties beg end grep-find-hide-properties))
+        (user-error "No abbreviated part to hide/show")))))
 
 ;;;###autoload
 (defun zrgrep (regexp &optional files dir confirm template)





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

* bug#30503: 27.0.50; allow hiding M-x grep command line
  2018-02-25 19:50           ` Charles A. Roelli
@ 2018-02-27 21:06             ` Juri Linkov
  2018-03-04 16:11               ` Charles A. Roelli
  0 siblings, 1 reply; 14+ messages in thread
From: Juri Linkov @ 2018-02-27 21:06 UTC (permalink / raw)
  To: Charles A. Roelli; +Cc: 30503

> Thanks for adding this feature.  Here's the change that implements a
> toggling command.

Thanks.  I have only one comment about the naming: since we will now have
grep-find-toggle-abbreviation, how about renaming for symmetry
grep-find-hide to e.g. grep-find-hide-abbreviation, and
grep-find-hide-properties to e.g. grep-find-hide-abbreviation-props?

Or maybe better to have the same prefix for all functions/variables
of this feature?

grep-find-abbreviation-toggle
grep-find-abbreviation-hide
grep-find-abbreviation-hide-props





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

* bug#30503: 27.0.50; allow hiding M-x grep command line
  2018-02-27 21:06             ` Juri Linkov
@ 2018-03-04 16:11               ` Charles A. Roelli
  2018-03-11 14:00                 ` Charles A. Roelli
  0 siblings, 1 reply; 14+ messages in thread
From: Charles A. Roelli @ 2018-03-04 16:11 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 30503

> From: Juri Linkov <juri@linkov.net>
> Cc: eliz@gnu.org,  30503@debbugs.gnu.org
> Date: Tue, 27 Feb 2018 23:06:35 +0200
> 
> > Thanks for adding this feature.  Here's the change that implements a
> > toggling command.
> 
> Thanks.  I have only one comment about the naming: since we will now have
> grep-find-toggle-abbreviation, how about renaming for symmetry
> grep-find-hide to e.g. grep-find-hide-abbreviation, and
> grep-find-hide-properties to e.g. grep-find-hide-abbreviation-props?
> 
> Or maybe better to have the same prefix for all functions/variables
> of this feature?
> 
> grep-find-abbreviation-toggle
> grep-find-abbreviation-hide
> grep-find-abbreviation-hide-props

I've gone for:

grep-find-abbreviate (defcustom)
grep-find-abbreviate-properties (defvar)
grep-find-toggle-abbreviation (command)

(Most "toggle" commands seem not to end with that word, so I've
followed this convention.)

The patch follows:

diff --git a/doc/emacs/building.texi b/doc/emacs/building.texi
index 0697e1b..e1c3cea 100644
--- a/doc/emacs/building.texi
+++ b/doc/emacs/building.texi
@@ -434,14 +434,17 @@ Grep Searching
 @kbd{M-x rgrep}.  The default value includes the data directories used
 by various version control systems.
 
-@vindex grep-find-hide
+@vindex grep-find-abbreviate
+@findex grep-find-toggle-abbreviation
   By default, the shell commands constructed for @code{lgrep},
 @code{rgrep}, and @code{zgrep} are abbreviated for display by
 concealing the part that contains a long list of files and directories
 to ignore.  You can reveal the concealed part by clicking on the
-button with ellipsis, which represents them.  To disable this
-abbreviation of the shell commands, customize the option
-@code{grep-find-hide} to a @code{nil} value.
+button with ellipsis, which represents them.  You can also
+interactively toggle viewing the concealed part by typing @kbd{M-x
+grep-find-toggle-abbreviation}.  To disable this abbreviation of the
+shell commands, customize the option @code{grep-find-abbreviate} to a
+@code{nil} value.
 
 @node Flymake
 @section Finding Syntax Errors On The Fly
diff --git a/etc/NEWS b/etc/NEWS
index 08c7e7e..24064f8 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -209,8 +209,10 @@ by default.
 
 *** rgrep, lgrep and zrgrep now hide part of the command line
 that contains a list of ignored directories and files.
-Clicking on the button with ellipsis unhides the truncated part.
-This truncation can be disabled by the new option 'grep-find-hide'.
+Clicking on the button with ellipsis unhides it.
+The abbreviation can be disabled by the new option
+'grep-find-abbreviate'.  The new command
+'grep-find-toggle-abbreviation' toggles it interactively.
 
 ** ERT
 
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index 9b2c6f1..f7c90ba 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -433,24 +433,26 @@ grep-mode-line-matches
                       help-echo "Number of matches so far")
     "]"))
 
-(defcustom grep-find-hide t
+(defcustom grep-find-abbreviate t
   "If non-nil, hide part of rgrep/lgrep/zrgrep command line.
 The hidden part contains a list of ignored directories and files.
 Clicking on the button-like ellipsis unhides the abbreviated part
-and reveals the entire command line."
+and reveals the entire command line.  The visibility of the
+abbreviated part can also be toggled with
+`grep-find-toggle-abbreviation'."
   :type 'boolean
   :version "27.1"
   :group 'grep)
 
-(defvar grep-find-hide-properties
+(defvar grep-find-abbreviate-properties
   (let ((ellipsis (if (char-displayable-p ?…) "[…]" "[...]"))
         (map (make-sparse-keymap)))
     (define-key map [down-mouse-2] 'mouse-set-point)
-    (define-key map [mouse-2] 'grep-find-show)
-    (define-key map "\C-m" 'grep-find-show)
+    (define-key map [mouse-2] 'grep-find-toggle-abbreviation)
+    (define-key map "\C-m" 'grep-find-toggle-abbreviation)
     `(face nil display ,ellipsis mouse-face highlight
       help-echo "RET, mouse-2: show unabbreviated command"
-      keymap ,map))
+      keymap ,map abbreviated-command t))
   "Properties of button-like ellipsis on part of rgrep command line.")
 
 (defvar grep-mode-font-lock-keywords
@@ -476,10 +478,12 @@ grep-mode-font-lock-keywords
              `(face nil display ,(match-string 2)))))
      ;; Hide excessive part of rgrep command
      ("^find \\(\\. -type d .*\\\\)\\)"
-      (1 (when grep-find-hide grep-find-hide-properties)))
+      (1 (if grep-find-abbreviate grep-find-abbreviate-properties
+           '(face nil abbreviated-command t))))
      ;; Hide excessive part of lgrep command
      ("^grep \\( *--exclude.*--exclude[^ ]+\\)"
-      (1 (when grep-find-hide grep-find-hide-properties))))
+      (1 (if grep-find-abbreviate grep-find-abbreviate-properties
+           '(face nil abbreviated-command t)))))
    "Additional things to highlight in grep output.
 This gets tacked on the end of the generated expressions.")
 
@@ -1195,23 +1199,19 @@ rgrep-default-command
                  (shell-quote-argument ")")
                  " -prune -o ")))))
 
-(defun grep-find-show ()
-  "Show the hidden part of rgrep/lgrep/zrgrep command line."
+(defun grep-find-toggle-abbreviation ()
+  "Toggle showing the hidden part of rgrep/lgrep/zrgrep command line."
   (interactive)
-  (when (get-text-property (point) 'display)
-    (let ((beg (or (previous-single-property-change
-                    (min (point-max) (1+ (point))) 'display)
-                   (point)))
-          (end (or (next-single-property-change
-                    (point) 'display)
-                   (point)))
-          (inhibit-modification-hooks t)
-          (inhibit-read-only t)
-	  (buffer-undo-list t)
-	  (modified (buffer-modified-p)))
-      (remove-list-of-text-properties
-       beg end '(display help-echo mouse-face help-echo keymap))
-      (set-buffer-modified-p modified))))
+  (with-silent-modifications
+    (let* ((beg (next-single-property-change (point-min) 'abbreviated-command))
+           (end (when beg
+                  (next-single-property-change beg 'abbreviated-command))))
+      (if end
+          (if (get-text-property beg 'display)
+              (remove-list-of-text-properties
+               beg end '(display help-echo mouse-face help-echo keymap))
+            (add-text-properties beg end grep-find-abbreviate-properties))
+        (user-error "No abbreviated part to hide/show")))))
 
 ;;;###autoload
 (defun zrgrep (regexp &optional files dir confirm template)





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

* bug#30503: 27.0.50; allow hiding M-x grep command line
  2018-03-04 16:11               ` Charles A. Roelli
@ 2018-03-11 14:00                 ` Charles A. Roelli
  0 siblings, 0 replies; 14+ messages in thread
From: Charles A. Roelli @ 2018-03-11 14:00 UTC (permalink / raw)
  To: juri; +Cc: 30503

> Date: Sun, 04 Mar 2018 17:11:07 +0100
> From: charles@aurox.ch (Charles A. Roelli)
>
> > > Thanks for adding this feature.  Here's the change that implements a
> > > toggling command.
> > 
> > Thanks.  I have only one comment about the naming: since we will now have
> > grep-find-toggle-abbreviation, how about renaming for symmetry
> > grep-find-hide to e.g. grep-find-hide-abbreviation, and
> > grep-find-hide-properties to e.g. grep-find-hide-abbreviation-props?
> > 
> > Or maybe better to have the same prefix for all functions/variables
> > of this feature?
> > 
> > grep-find-abbreviation-toggle
> > grep-find-abbreviation-hide
> > grep-find-abbreviation-hide-props
> 
> I've gone for:
> 
> grep-find-abbreviate (defcustom)
> grep-find-abbreviate-properties (defvar)
> grep-find-toggle-abbreviation (command)
> 
> (Most "toggle" commands seem not to end with that word, so I've
> followed this convention.)
> 
> The patch follows:
> 
> diff --git a/doc/emacs/building.texi b/doc/emacs/building.texi
> index 0697e1b..e1c3cea 100644
> --- a/doc/emacs/building.texi
> +++ b/doc/emacs/building.texi
> @@ -434,14 +434,17 @@ Grep Searching
>  @kbd{M-x rgrep}.  The default value includes the data directories used
>  by various version control systems.
>  
> -@vindex grep-find-hide
> +@vindex grep-find-abbreviate
> +@findex grep-find-toggle-abbreviation
>    By default, the shell commands constructed for @code{lgrep},
>  @code{rgrep}, and @code{zgrep} are abbreviated for display by
>  concealing the part that contains a long list of files and directories
>  to ignore.  You can reveal the concealed part by clicking on the
> -button with ellipsis, which represents them.  To disable this
> -abbreviation of the shell commands, customize the option
> -@code{grep-find-hide} to a @code{nil} value.
> +button with ellipsis, which represents them.  You can also
> +interactively toggle viewing the concealed part by typing @kbd{M-x
> +grep-find-toggle-abbreviation}.  To disable this abbreviation of the
> +shell commands, customize the option @code{grep-find-abbreviate} to a
> +@code{nil} value.
>  
>  @node Flymake
>  @section Finding Syntax Errors On The Fly
> diff --git a/etc/NEWS b/etc/NEWS
> index 08c7e7e..24064f8 100644
> --- a/etc/NEWS
> +++ b/etc/NEWS
> @@ -209,8 +209,10 @@ by default.
>  
>  *** rgrep, lgrep and zrgrep now hide part of the command line
>  that contains a list of ignored directories and files.
> -Clicking on the button with ellipsis unhides the truncated part.
> -This truncation can be disabled by the new option 'grep-find-hide'.
> +Clicking on the button with ellipsis unhides it.
> +The abbreviation can be disabled by the new option
> +'grep-find-abbreviate'.  The new command
> +'grep-find-toggle-abbreviation' toggles it interactively.
>  
>  ** ERT
>  
> diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
> index 9b2c6f1..f7c90ba 100644
> --- a/lisp/progmodes/grep.el
> +++ b/lisp/progmodes/grep.el
> @@ -433,24 +433,26 @@ grep-mode-line-matches
>                        help-echo "Number of matches so far")
>      "]"))
>  
> -(defcustom grep-find-hide t
> +(defcustom grep-find-abbreviate t
>    "If non-nil, hide part of rgrep/lgrep/zrgrep command line.
>  The hidden part contains a list of ignored directories and files.
>  Clicking on the button-like ellipsis unhides the abbreviated part
> -and reveals the entire command line."
> +and reveals the entire command line.  The visibility of the
> +abbreviated part can also be toggled with
> +`grep-find-toggle-abbreviation'."
>    :type 'boolean
>    :version "27.1"
>    :group 'grep)
>  
> -(defvar grep-find-hide-properties
> +(defvar grep-find-abbreviate-properties
>    (let ((ellipsis (if (char-displayable-p ?…) "[…]" "[...]"))
>          (map (make-sparse-keymap)))
>      (define-key map [down-mouse-2] 'mouse-set-point)
> -    (define-key map [mouse-2] 'grep-find-show)
> -    (define-key map "\C-m" 'grep-find-show)
> +    (define-key map [mouse-2] 'grep-find-toggle-abbreviation)
> +    (define-key map "\C-m" 'grep-find-toggle-abbreviation)
>      `(face nil display ,ellipsis mouse-face highlight
>        help-echo "RET, mouse-2: show unabbreviated command"
> -      keymap ,map))
> +      keymap ,map abbreviated-command t))
>    "Properties of button-like ellipsis on part of rgrep command line.")
>  
>  (defvar grep-mode-font-lock-keywords
> @@ -476,10 +478,12 @@ grep-mode-font-lock-keywords
>               `(face nil display ,(match-string 2)))))
>       ;; Hide excessive part of rgrep command
>       ("^find \\(\\. -type d .*\\\\)\\)"
> -      (1 (when grep-find-hide grep-find-hide-properties)))
> +      (1 (if grep-find-abbreviate grep-find-abbreviate-properties
> +           '(face nil abbreviated-command t))))
>       ;; Hide excessive part of lgrep command
>       ("^grep \\( *--exclude.*--exclude[^ ]+\\)"
> -      (1 (when grep-find-hide grep-find-hide-properties))))
> +      (1 (if grep-find-abbreviate grep-find-abbreviate-properties
> +           '(face nil abbreviated-command t)))))
>     "Additional things to highlight in grep output.
>  This gets tacked on the end of the generated expressions.")
>  
> @@ -1195,23 +1199,19 @@ rgrep-default-command
>                   (shell-quote-argument ")")
>                   " -prune -o ")))))
>  
> -(defun grep-find-show ()
> -  "Show the hidden part of rgrep/lgrep/zrgrep command line."
> +(defun grep-find-toggle-abbreviation ()
> +  "Toggle showing the hidden part of rgrep/lgrep/zrgrep command line."
>    (interactive)
> -  (when (get-text-property (point) 'display)
> -    (let ((beg (or (previous-single-property-change
> -                    (min (point-max) (1+ (point))) 'display)
> -                   (point)))
> -          (end (or (next-single-property-change
> -                    (point) 'display)
> -                   (point)))
> -          (inhibit-modification-hooks t)
> -          (inhibit-read-only t)
> -	  (buffer-undo-list t)
> -	  (modified (buffer-modified-p)))
> -      (remove-list-of-text-properties
> -       beg end '(display help-echo mouse-face help-echo keymap))
> -      (set-buffer-modified-p modified))))
> +  (with-silent-modifications
> +    (let* ((beg (next-single-property-change (point-min) 'abbreviated-command))
> +           (end (when beg
> +                  (next-single-property-change beg 'abbreviated-command))))
> +      (if end
> +          (if (get-text-property beg 'display)
> +              (remove-list-of-text-properties
> +               beg end '(display help-echo mouse-face help-echo keymap))
> +            (add-text-properties beg end grep-find-abbreviate-properties))
> +        (user-error "No abbreviated part to hide/show")))))
>  
>  ;;;###autoload
>  (defun zrgrep (regexp &optional files dir confirm template)

I've pushed this change, along with a modification to add a menu-bar
item, and am closing the bug.





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

end of thread, other threads:[~2018-03-11 14:00 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-17 16:25 bug#30503: 27.0.50; allow hiding M-x grep command line Charles A. Roelli
2018-02-17 17:06 ` Eli Zaretskii
2018-02-17 19:13   ` Charles A. Roelli
2018-02-20 20:54 ` Juri Linkov
2018-02-21  3:44   ` Eli Zaretskii
2018-02-21 20:20     ` Juri Linkov
2018-02-22  7:43       ` Eli Zaretskii
2018-02-22 21:51         ` Juri Linkov
2018-02-23  6:55           ` Eli Zaretskii
2018-02-25 19:50           ` Charles A. Roelli
2018-02-27 21:06             ` Juri Linkov
2018-03-04 16:11               ` Charles A. Roelli
2018-03-11 14:00                 ` Charles A. Roelli
2018-02-21 20:30   ` Charles A. Roelli

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