emacs-devel
[Top][All Lists]
Advanced

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

RE: Calling occur from within isearch


From: Drew Adams
Subject: RE: Calling occur from within isearch
Date: Wed, 21 Nov 2007 12:07:25 -0800

> Sometimes I think it would be good to call occur from within isearch.
> Anyone else that thinks it would be good to be able to do so?

Yes. I've done that for some time, using this code by Alex Schroeder
(http://www.emacswiki.org/cgi-bin/wiki/AlexSchroederConfigInit):

(defun isearch-occur ()
  "Invoke `occur' from within isearch."
  (interactive)
  (let ((case-fold-search isearch-case-fold-search))
    (occur (if isearch-regexp
               isearch-string
             (regexp-quote isearch-string)))))

(define-key isearch-mode-map (kbd "C-o") 'isearch-occur)

(defun my-occur (&optional arg)
  "Switch to *Occur* buffer, or run `occur'.
Without a prefix argument, switch to the buffer.
With a universal prefix argument, run occur again.
With a numeric prefix argument, run occur with NLINES
set to that number."
  (interactive "P")
  (if (and (not arg) (get-buffer "*Occur*"))
      (switch-to-buffer "*Occur*")
    (occur (read-from-minibuffer "Regexp: ")
           (if (listp arg) 0 arg))))





reply via email to

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