diff options
| -rw-r--r-- | doc/emacs/building.texi | 6 | ||||
| -rw-r--r-- | etc/NEWS | 7 | ||||
| -rw-r--r-- | lisp/progmodes/grep.el | 49 |
3 files changed, 60 insertions, 2 deletions
diff --git a/doc/emacs/building.texi b/doc/emacs/building.texi index b6b664ddb39..91705711b84 100644 --- a/doc/emacs/building.texi +++ b/doc/emacs/building.texi | |||
| @@ -434,6 +434,12 @@ the variable @code{grep-files-aliases}. | |||
| 434 | @kbd{M-x rgrep}. The default value includes the data directories used | 434 | @kbd{M-x rgrep}. The default value includes the data directories used |
| 435 | by various version control systems. | 435 | by various version control systems. |
| 436 | 436 | ||
| 437 | @vindex grep-find-hide | ||
| 438 | The boolean option @code{grep-find-hide} controls shortening of the | ||
| 439 | displayed command line by hiding the part containing ignored | ||
| 440 | directories and files. The hidden part can be revealed by clicking on | ||
| 441 | the button with ellipsis. | ||
| 442 | |||
| 437 | @node Flymake | 443 | @node Flymake |
| 438 | @section Finding Syntax Errors On The Fly | 444 | @section Finding Syntax Errors On The Fly |
| 439 | @cindex checking syntax | 445 | @cindex checking syntax |
| @@ -182,6 +182,13 @@ by default. | |||
| 182 | 182 | ||
| 183 | ** Gamegrid | 183 | ** Gamegrid |
| 184 | 184 | ||
| 185 | ** grep | ||
| 186 | |||
| 187 | *** rgrep, lgrep and zrgrep now hide part of the command line | ||
| 188 | that contains a list of ignored directories and files. | ||
| 189 | Clicking on the button with ellipsis unhides the truncated part. | ||
| 190 | This truncation can be disabled by the new option 'grep-find-hide'. | ||
| 191 | |||
| 185 | ** ERT | 192 | ** ERT |
| 186 | 193 | ||
| 187 | +++ | 194 | +++ |
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el index 755c9c73d37..9b2c6f112c6 100644 --- a/lisp/progmodes/grep.el +++ b/lisp/progmodes/grep.el | |||
| @@ -433,6 +433,26 @@ See `compilation-error-regexp-alist' for format details.") | |||
| 433 | help-echo "Number of matches so far") | 433 | help-echo "Number of matches so far") |
| 434 | "]")) | 434 | "]")) |
| 435 | 435 | ||
| 436 | (defcustom grep-find-hide t | ||
| 437 | "If non-nil, hide part of rgrep/lgrep/zrgrep command line. | ||
| 438 | The hidden part contains a list of ignored directories and files. | ||
| 439 | Clicking on the button-like ellipsis unhides the abbreviated part | ||
| 440 | and reveals the entire command line." | ||
| 441 | :type 'boolean | ||
| 442 | :version "27.1" | ||
| 443 | :group 'grep) | ||
| 444 | |||
| 445 | (defvar grep-find-hide-properties | ||
| 446 | (let ((ellipsis (if (char-displayable-p ?…) "[…]" "[...]")) | ||
| 447 | (map (make-sparse-keymap))) | ||
| 448 | (define-key map [down-mouse-2] 'mouse-set-point) | ||
| 449 | (define-key map [mouse-2] 'grep-find-show) | ||
| 450 | (define-key map "\C-m" 'grep-find-show) | ||
| 451 | `(face nil display ,ellipsis mouse-face highlight | ||
| 452 | help-echo "RET, mouse-2: show unabbreviated command" | ||
| 453 | keymap ,map)) | ||
| 454 | "Properties of button-like ellipsis on part of rgrep command line.") | ||
| 455 | |||
| 436 | (defvar grep-mode-font-lock-keywords | 456 | (defvar grep-mode-font-lock-keywords |
| 437 | '(;; Command output lines. | 457 | '(;; Command output lines. |
| 438 | (": \\(.+\\): \\(?:Permission denied\\|No such \\(?:file or directory\\|device or address\\)\\)$" | 458 | (": \\(.+\\): \\(?:Permission denied\\|No such \\(?:file or directory\\|device or address\\)\\)$" |
| @@ -450,9 +470,16 @@ See `compilation-error-regexp-alist' for format details.") | |||
| 450 | (2 grep-error-face nil t)) | 470 | (2 grep-error-face nil t)) |
| 451 | ;; "filename-linenumber-" format is used for context lines in GNU grep, | 471 | ;; "filename-linenumber-" format is used for context lines in GNU grep, |
| 452 | ;; "filename=linenumber=" for lines with function names in "git grep -p". | 472 | ;; "filename=linenumber=" for lines with function names in "git grep -p". |
| 453 | ("^.+?\\([-=\0]\\)[0-9]+\\([-=]\\).*\n" (0 grep-context-face) | 473 | ("^.+?\\([-=\0]\\)[0-9]+\\([-=]\\).*\n" |
| 474 | (0 grep-context-face) | ||
| 454 | (1 (if (eq (char-after (match-beginning 1)) ?\0) | 475 | (1 (if (eq (char-after (match-beginning 1)) ?\0) |
| 455 | `(face nil display ,(match-string 2)))))) | 476 | `(face nil display ,(match-string 2))))) |
| 477 | ;; Hide excessive part of rgrep command | ||
| 478 | ("^find \\(\\. -type d .*\\\\)\\)" | ||
| 479 | (1 (when grep-find-hide grep-find-hide-properties))) | ||
| 480 | ;; Hide excessive part of lgrep command | ||
| 481 | ("^grep \\( *--exclude.*--exclude[^ ]+\\)" | ||
| 482 | (1 (when grep-find-hide grep-find-hide-properties)))) | ||
| 456 | "Additional things to highlight in grep output. | 483 | "Additional things to highlight in grep output. |
| 457 | This gets tacked on the end of the generated expressions.") | 484 | This gets tacked on the end of the generated expressions.") |
| 458 | 485 | ||
| @@ -1168,6 +1195,24 @@ to specify a command to run." | |||
| 1168 | (shell-quote-argument ")") | 1195 | (shell-quote-argument ")") |
| 1169 | " -prune -o "))))) | 1196 | " -prune -o "))))) |
| 1170 | 1197 | ||
| 1198 | (defun grep-find-show () | ||
| 1199 | "Show the hidden part of rgrep/lgrep/zrgrep command line." | ||
| 1200 | (interactive) | ||
| 1201 | (when (get-text-property (point) 'display) | ||
| 1202 | (let ((beg (or (previous-single-property-change | ||
| 1203 | (min (point-max) (1+ (point))) 'display) | ||
| 1204 | (point))) | ||
| 1205 | (end (or (next-single-property-change | ||
| 1206 | (point) 'display) | ||
| 1207 | (point))) | ||
| 1208 | (inhibit-modification-hooks t) | ||
| 1209 | (inhibit-read-only t) | ||
| 1210 | (buffer-undo-list t) | ||
| 1211 | (modified (buffer-modified-p))) | ||
| 1212 | (remove-list-of-text-properties | ||
| 1213 | beg end '(display help-echo mouse-face help-echo keymap)) | ||
| 1214 | (set-buffer-modified-p modified)))) | ||
| 1215 | |||
| 1171 | ;;;###autoload | 1216 | ;;;###autoload |
| 1172 | (defun zrgrep (regexp &optional files dir confirm template) | 1217 | (defun zrgrep (regexp &optional files dir confirm template) |
| 1173 | "Recursively grep for REGEXP in gzipped FILES in tree rooted at DIR. | 1218 | "Recursively grep for REGEXP in gzipped FILES in tree rooted at DIR. |