From: charles@aurox.ch (Charles A. Roelli)
To: juri@linkov.net
Cc: 30503@debbugs.gnu.org
Subject: bug#30503: 27.0.50; allow hiding M-x grep command line
Date: Sun, 11 Mar 2018 15:00:13 +0100 [thread overview]
Message-ID: <m2tvtmhfv6.fsf@aurox.ch> (raw)
In-Reply-To: <m28tb7izxg.fsf@aurox.ch> (charles@aurox.ch)
> 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.
next prev parent reply other threads:[~2018-03-11 14:00 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2018-02-21 20:30 ` Charles A. Roelli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2tvtmhfv6.fsf@aurox.ch \
--to=charles@aurox.ch \
--cc=30503@debbugs.gnu.org \
--cc=juri@linkov.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.