From: Juri Linkov <juri@linkov.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 30503@debbugs.gnu.org, charles@aurox.ch
Subject: bug#30503: 27.0.50; allow hiding M-x grep command line
Date: Wed, 21 Feb 2018 22:20:55 +0200 [thread overview]
Message-ID: <87vaeq3yfc.fsf@mail.linkov.net> (raw)
In-Reply-To: <83k1v76m6r.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 21 Feb 2018 05:44:44 +0200")
[-- 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.
next prev parent reply other threads:[~2018-02-21 20:20 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 [this message]
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
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=87vaeq3yfc.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=30503@debbugs.gnu.org \
--cc=charles@aurox.ch \
--cc=eliz@gnu.org \
/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.