emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Add lgrep/rgrep commands to Edit > Search submenu


From: Kim F. Storm
Subject: Re: Add lgrep/rgrep commands to Edit > Search submenu
Date: Sun, 25 Jan 2009 20:22:19 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

Chong Yidong <address@hidden> writes:

> address@hidden (Kim F. Storm) writes:
>
>> IMO, lgrep and rgrep are much better suited as menu commands,
>> and they would logically fit very well on
>>  Edit > Search > Search Files... 
>>  Edit > Search > Search Files Recurse...
>>
>> We may remove the standard grep from Tools - or keep it as
>> a more advanced/low-level interface.
>
> Conceptually, the grep commands are not a good fit for the Edit menu.
> The Edit menu contains commands that act on the current buffer; the
> Tools menu contains commands that do fancier stuff like operating on
> multiple files.  So, even though Isearch and Grep are both "search
> commands", I don't think it's good to consolidate them on the menu bar.

Then, why is "search tagged files" on Edit > Search ?

I want to search for abc - starting in the current buffer, so I use
Edit > Search > ...  - and then realize that I would like to search
through other buffer or files - so I again use Edit > Search > ...
and find nothing useful.

I find lgrep / rgrep rather useful as an editing tool -- but parhaps
that is because I have the "replace grep match" add-on which I find is
one of the most efficient extensions to emacs (it was rejected last time
I proposed this - so I'm not going to propose it again).


;;; grep-x.el -- search and replace interface using grep output.

(defun grep-goto-error-no-select ()
  "Display currently grep match in other window."
  (interactive)
  (save-selected-window
    (compile-goto-error)))

(defvar grep-last-replace-string nil)

(defun grep-replace-match-internal ()
  (when compilation-highlight-overlay
    (let ((start (overlay-start compilation-highlight-overlay)))
      (goto-char start)
      (undo-boundary)
      (save-match-data
        (search-forward (buffer-substring-no-properties start (overlay-end 
compilation-highlight-overlay)))
        (replace-match grep-last-replace-string))
      (move-overlay compilation-highlight-overlay start (point)))))

(defun grep-replace-match (string)
  "Replace current grep match with string STRING."
  (interactive "sReplace with: ")
  (save-selected-window
    (setq grep-last-replace-string string)
    (let ((next-error-highlight
           (if (numberp next-error-highlight) next-error-highlight 0.01))
          (next-error-hook '(grep-replace-match-internal)))
      (compile-goto-error))))

(defun grep-repeat-replace-match ()
  "Replace current grep match with last match replace string."
  (interactive)
  (if (not grep-last-replace-string)
      (call-interactively 'grep-replace-match)
    (grep-replace-match grep-last-replace-string)))



(define-key grep-mode-map "o" 'grep-goto-error-no-select)
(define-key grep-mode-map "/" 'grep-replace-match)
(define-key grep-mode-map "." 'grep-repeat-replace-match)

(provide 'grep-x)

-- 
Kim F. Storm <address@hidden> http://www.cua.dk





reply via email to

[Prev in Thread] Current Thread [Next in Thread]