From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#30503: 27.0.50; allow hiding M-x grep command line Date: Wed, 21 Feb 2018 22:20:55 +0200 Organization: LINKOV.NET Message-ID: <87vaeq3yfc.fsf@mail.linkov.net> References: <87sh9vs7p1.fsf@mail.linkov.net> <83k1v76m6r.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1519245142 12979 195.159.176.226 (21 Feb 2018 20:32:22 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 21 Feb 2018 20:32:22 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) Cc: 30503@debbugs.gnu.org, charles@aurox.ch To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Feb 21 21:32:18 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eob3o-00030L-GJ for geb-bug-gnu-emacs@m.gmane.org; Wed, 21 Feb 2018 21:32:16 +0100 Original-Received: from localhost ([::1]:34693 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eob5q-0002GD-O6 for geb-bug-gnu-emacs@m.gmane.org; Wed, 21 Feb 2018 15:34:22 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44139) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eob4e-00028E-Qn for bug-gnu-emacs@gnu.org; Wed, 21 Feb 2018 15:34:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eob3a-0008Q2-P7 for bug-gnu-emacs@gnu.org; Wed, 21 Feb 2018 15:33:08 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:47034) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eob3a-0008PD-Fy for bug-gnu-emacs@gnu.org; Wed, 21 Feb 2018 15:32:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eob3a-0001OG-3s for bug-gnu-emacs@gnu.org; Wed, 21 Feb 2018 15:32:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 21 Feb 2018 20:32:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 30503 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 30503-submit@debbugs.gnu.org id=B30503.15192451015306 (code B ref 30503); Wed, 21 Feb 2018 20:32:02 +0000 Original-Received: (at 30503) by debbugs.gnu.org; 21 Feb 2018 20:31:41 +0000 Original-Received: from localhost ([127.0.0.1]:54929 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eob3F-0001NW-FC for submit@debbugs.gnu.org; Wed, 21 Feb 2018 15:31:41 -0500 Original-Received: from sub3.mail.dreamhost.com ([69.163.253.7]:42300 helo=homiemail-a100.g.dreamhost.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eob3B-0001NF-RC for 30503@debbugs.gnu.org; Wed, 21 Feb 2018 15:31:38 -0500 Original-Received: from homiemail-a100.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a100.g.dreamhost.com (Postfix) with ESMTP id D22E631A075; Wed, 21 Feb 2018 12:31:36 -0800 (PST) Original-Received: from localhost.linkov.net (m91-129-98-215.cust.tele2.ee [91.129.98.215]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by homiemail-a100.g.dreamhost.com (Postfix) with ESMTPSA id 82E0C31A070; Wed, 21 Feb 2018 12:31:35 -0800 (PST) In-Reply-To: <83k1v76m6r.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 21 Feb 2018 05:44:44 +0200") X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -0.0 (/) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:143573 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable >> > Could we provide an option to hide the barrage of ignored directorie= s >> > and files? It might also be worth adding a text button or keybindin= g >> > 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 =E2=80=9C---=E2=80=9D to = not forget to document it in the manual before the release of Emacs 27.1. --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename=grep-hide.2.patch Content-Transfer-Encoding: quoted-printable diff --git a/etc/NEWS b/etc/NEWS index 71569c9..0ba369e7 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -158,6 +158,13 @@ by default. =20 ** Gamegrid =20 +** 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 =20 +++ 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") "]")) =20 +(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 ?=E2=80=A6) "[=E2=80=A6]" "[..= .]")) + (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 directo= ry\\|device or address\\)\\)$" @@ -452,7 +472,13 @@ grep-mode-font-lock-keywords ;; "filename=3Dlinenumber=3D" for lines with function names in "git= grep -p". ("^.+?\\([-=3D\0]\\)[0-9]+\\([-=3D]\\).*\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.") =20 @@ -1166,6 +1192,24 @@ rgrep-default-command (shell-quote-argument ")") " -prune -o "))))) =20 +(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. --=-=-=--