[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#30503: 27.0.50; allow hiding M-x grep command line
From: |
Charles A. Roelli |
Subject: |
bug#30503: 27.0.50; allow hiding M-x grep command line |
Date: |
Sun, 25 Feb 2018 20:50:47 +0100 |
> 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)
- bug#30503: 27.0.50; allow hiding M-x grep command line, Charles A. Roelli, 2018/02/17
- bug#30503: 27.0.50; allow hiding M-x grep command line, Eli Zaretskii, 2018/02/17
- bug#30503: 27.0.50; allow hiding M-x grep command line, Juri Linkov, 2018/02/20
- bug#30503: 27.0.50; allow hiding M-x grep command line, Eli Zaretskii, 2018/02/20
- bug#30503: 27.0.50; allow hiding M-x grep command line, Juri Linkov, 2018/02/21
- bug#30503: 27.0.50; allow hiding M-x grep command line, Eli Zaretskii, 2018/02/22
- bug#30503: 27.0.50; allow hiding M-x grep command line, Juri Linkov, 2018/02/22
- bug#30503: 27.0.50; allow hiding M-x grep command line, Eli Zaretskii, 2018/02/23
- bug#30503: 27.0.50; allow hiding M-x grep command line,
Charles A. Roelli <=
- bug#30503: 27.0.50; allow hiding M-x grep command line, Juri Linkov, 2018/02/27
bug#30503: 27.0.50; allow hiding M-x grep command line, Charles A. Roelli, 2018/02/21