diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el index 14e251e..34a9b2f 100644 --- a/lisp/progmodes/grep.el +++ b/lisp/progmodes/grep.el @@ -452,7 +452,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 the command from rgrep + ("^find \\(\\. -type d .*\\\\)\\)" + (1 (rgrep-command-hide))) + ;; Hide excessive part of the command from lgrep + ("^grep \\( *--exclude.*--exclude[^ ]+\\)" + (1 (rgrep-command-hide)))) "Additional things to highlight in grep output. This gets tacked on the end of the generated expressions.") @@ -1166,6 +1173,32 @@ rgrep-default-command (shell-quote-argument ")") " -prune -o "))))) +(defun rgrep-command-hide () + (let ((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 "[...]" mouse-face highlight + help-echo "RET, mouse-2: toggle truncated command" + keymap ,map))) + +(defun rgrep-command-show () + (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.