;;; replace.el --- replace commands for Emacs
-;; Copyright (C) 1985, 1986, 1987, 1992, 1994, 1996, 1997, 2000, 2001, 2002,
-;; 2003, 2004, 2005 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1986, 1987, 1992, 1994, 1996, 1997, 2000, 2001,
+;; 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
;; Maintainer: FSF
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
;;; Commentary:
(defun query-replace-descr (string)
(mapconcat 'isearch-text-char-description string ""))
-(defun query-replace-read-from (string regexp-flag)
+(defun query-replace-read-from (prompt regexp-flag)
"Query and return the `from' argument of a query-replace operation.
The return value can also be a pair (FROM . TO) indicating that the user
wants to replace FROM with TO."
query-replace-from-history-variable))))
(read-from-minibuffer
(if (and lastto lastfrom)
- (format "%s (default %s -> %s): " string
+ (format "%s (default %s -> %s): " prompt
(query-replace-descr lastfrom)
(query-replace-descr lastto))
- (format "%s: " string))
+ (format "%s: " prompt))
nil nil nil
query-replace-from-history-variable
nil t t))))
to))
-(defun query-replace-read-to (from string regexp-flag)
+(defun query-replace-read-to (from prompt regexp-flag)
"Query and return the `to' argument of a query-replace operation."
(query-replace-compile-replacement
(save-excursion
(read-from-minibuffer
- (format "%s %s with: " string (query-replace-descr from))
+ (format "%s %s with: " prompt (query-replace-descr from))
nil nil nil
query-replace-to-history-variable from t t))
regexp-flag))
-(defun query-replace-read-args (string regexp-flag &optional noerror)
+(defun query-replace-read-args (prompt regexp-flag &optional noerror)
(unless noerror
(barf-if-buffer-read-only))
- (let* ((from (query-replace-read-from string regexp-flag))
+ (let* ((from (query-replace-read-from prompt regexp-flag))
(to (if (consp from) (prog1 (cdr from) (setq from (car from)))
- (query-replace-read-to from string regexp-flag))))
+ (query-replace-read-to from prompt regexp-flag))))
(list from to current-prefix-arg)))
(defun query-replace (from-string to-string &optional delimited start end)
:group 'matching)
(defcustom occur-hook nil
- "Hook run when `occur' is called."
+ "Hook run by Occur when there are any matches."
:type 'hook
:group 'matching)
'((((class color) (min-colors 88) (background light))
:background "Tan")
(((class color) (min-colors 88) (background dark))
- :background "RoyalBlue4")
+ :background "RoyalBlue3")
(((class color) (min-colors 8))
:background "blue" :foreground "white")
(((type tty) (class mono))
(input
(read-from-minibuffer
(if default
- (format "List lines matching regexp (default `%s'): "
+ (format "List lines matching regexp (default %s): "
(query-replace-descr default))
"List lines matching regexp: ")
nil
(when current-prefix-arg
(prefix-numeric-value current-prefix-arg))))
-(defun occur-rename-buffer (&optional unique-p)
+(defun occur-rename-buffer (&optional unique-p interactive-p)
"Rename the current *Occur* buffer to *Occur: original-buffer-name*.
-Here `original-buffer-name' is the buffer name were occur was originally run.
-When given the prefix argument, the renaming will not clobber the existing
-buffer(s) of that name, but use `generate-new-buffer-name' instead.
-You can add this to `occur-hook' if you always want a separate *Occur*
-buffer for each buffer where you invoke `occur'."
- (interactive "P")
+Here `original-buffer-name' is the buffer name were Occur was originally run.
+When given the prefix argument, or called non-interactively, the renaming
+will not clobber the existing buffer(s) of that name, but use
+`generate-new-buffer-name' instead. You can add this to `occur-hook'
+if you always want a separate *Occur* buffer for each buffer where you
+invoke `occur'."
+ (interactive "P\np")
(with-current-buffer
(if (eq major-mode 'occur-mode) (current-buffer) (get-buffer "*Occur*"))
(rename-buffer (concat "*Occur: "
(mapconcat #'buffer-name
(car (cddr occur-revert-arguments)) "/")
"*")
- unique-p)))
+ (or unique-p (not interactive-p)))))
(defun occur (regexp &optional nlines)
"Show all lines in the current buffer containing a match for REGEXP.
(if (= count 1) "" "es")
regexp))
(setq occur-revert-arguments (list regexp nlines bufs))
- (if (> count 0)
- (progn
- (display-buffer occur-buf)
- (setq next-error-last-buffer occur-buf))
- (kill-buffer occur-buf)))
- (setq buffer-read-only t)
- (set-buffer-modified-p nil)
- (run-hooks 'occur-hook)))))
+ (if (= count 0)
+ (kill-buffer occur-buf)
+ (display-buffer occur-buf)
+ (setq next-error-last-buffer occur-buf)
+ (setq buffer-read-only t)
+ (set-buffer-modified-p nil)
+ (run-hooks 'occur-hook)))))))
(defun occur-engine-add-prefix (lines)
(mapcar
title-face prefix-face match-face keep-props)
(with-current-buffer out-buf
(let ((globalcount 0)
+ ;; Don't generate undo entries for creation of the initial contents.
+ (buffer-undo-list t)
(coding nil))
;; Map over all the buffers
(dolist (buf buffers)
(let* ((out-line
(concat
;; Using 7 digits aligns tabs properly.
- (apply #'propertize (format "%7d:" lines)
+ (apply #'propertize (format "%7d" lines)
(append
(when prefix-face
`(font-lock-face prefix-face))
- '(occur-prefix t)))
+ `(occur-prefix t mouse-face highlight
+ occur-target ,marker follow-link t
+ help-echo "mouse-2: go to this occurrence")))
+ ":"
;; We don't put `mouse-face' on the newline,
;; because that loses. And don't put it
;; on context lines to reduce flicker.
- (propertize curstring 'mouse-face 'highlight)
+ (propertize curstring 'mouse-face 'highlight
+ 'occur-target marker
+ 'follow-link t
+ 'help-echo
+ "mouse-2: go to this occurrence")
"\n"))
(data
(if (= nlines 0)
(let ((beg (point))
(end (progn (insert data) (point))))
(unless (= nlines 0)
- (insert "-------\n"))
- (add-text-properties
- beg end
- `(occur-target ,marker help-echo "mouse-2: go to this occurrence")))))
+ (insert "-------\n")))))
(goto-char endpt))
(if endpt
(progn