aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/replace.el
diff options
context:
space:
mode:
authorMiles Bader2007-12-06 09:51:45 +0000
committerMiles Bader2007-12-06 09:51:45 +0000
commit0bd508417142ff377f34aec8dcec9438d9175c2c (patch)
tree4d60fe09e5cebf7d79766b11e9cda8cc1c9dbb9b /lisp/replace.el
parent98fe991da804a42f53f6a5e84cd5eab18a82e181 (diff)
parent9fb1ba8090da3528de56158a79bd3527d31c7f2f (diff)
downloademacs-0bd508417142ff377f34aec8dcec9438d9175c2c.tar.gz
emacs-0bd508417142ff377f34aec8dcec9438d9175c2c.zip
Merge from emacs--devo--0
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-294
Diffstat (limited to 'lisp/replace.el')
-rw-r--r--lisp/replace.el94
1 files changed, 69 insertions, 25 deletions
diff --git a/lisp/replace.el b/lisp/replace.el
index 7876f9bb47c..34fdd5fe3df 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -372,11 +372,9 @@ using `search-forward-regexp' and `replace-match' is preferred." "22.1")
372 372
373(defun map-query-replace-regexp (regexp to-strings &optional n start end) 373(defun map-query-replace-regexp (regexp to-strings &optional n start end)
374 "Replace some matches for REGEXP with various strings, in rotation. 374 "Replace some matches for REGEXP with various strings, in rotation.
375The second argument TO-STRINGS contains the replacement strings, 375The second argument TO-STRINGS contains the replacement strings, separated
376separated by spaces. Third arg DELIMITED (prefix arg if interactive), 376by spaces. This command works like `query-replace-regexp' except that
377if non-nil, means replace only matches surrounded by word boundaries. 377each successive replacement uses the next successive replacement string,
378This command works like `query-replace-regexp' except that each
379successive replacement uses the next successive replacement string,
380wrapping around from the last such string to the first. 378wrapping around from the last such string to the first.
381 379
382In Transient Mark mode, if the mark is active, operate on the contents 380In Transient Mark mode, if the mark is active, operate on the contents
@@ -533,9 +531,20 @@ which will run faster and will not set the mark or print anything."
533 "Read arguments for `keep-lines' and friends. 531 "Read arguments for `keep-lines' and friends.
534Prompt for a regexp with PROMPT. 532Prompt for a regexp with PROMPT.
535Value is a list, (REGEXP)." 533Value is a list, (REGEXP)."
536 (list (read-from-minibuffer prompt nil nil nil 534 (let* ((default (list
537 'regexp-history nil t) 535 (regexp-quote
538 nil nil t)) 536 (or (funcall (or find-tag-default-function
537 (get major-mode 'find-tag-default-function)
538 'find-tag-default))
539 ""))
540 (car regexp-search-ring)
541 (regexp-quote (or (car search-ring) ""))
542 (car (symbol-value
543 query-replace-from-history-variable))))
544 (default (delete-dups (delq nil (delete "" default)))))
545 (list (read-from-minibuffer prompt nil nil nil
546 'regexp-history default t)
547 nil nil t)))
539 548
540(defun keep-lines (regexp &optional rstart rend interactive) 549(defun keep-lines (regexp &optional rstart rend interactive)
541 "Delete all lines except those containing matches for REGEXP. 550 "Delete all lines except those containing matches for REGEXP.
@@ -725,6 +734,35 @@ a previously found match."
725 (define-key map "q" 'quit-window) 734 (define-key map "q" 'quit-window)
726 (define-key map "z" 'kill-this-buffer) 735 (define-key map "z" 'kill-this-buffer)
727 (define-key map "\C-c\C-f" 'next-error-follow-minor-mode) 736 (define-key map "\C-c\C-f" 'next-error-follow-minor-mode)
737 (define-key map [menu-bar] (make-sparse-keymap))
738 (define-key map [menu-bar occur]
739 (cons "Occur" map))
740 (define-key map [next-error-follow-minor-mode]
741 (menu-bar-make-mm-toggle next-error-follow-minor-mode
742 "Auto Occurrence Display"
743 "Display another occurrence when moving the cursor"))
744 (define-key map [separator-1] '("--"))
745 (define-key map [kill-this-buffer]
746 '("Kill occur buffer" . kill-this-buffer))
747 (define-key map [quit-window]
748 '("Quit occur window" . quit-window))
749 (define-key map [revert-buffer]
750 '("Revert occur buffer" . revert-buffer))
751 (define-key map [clone-buffer]
752 '("Clone occur buffer" . clone-buffer))
753 (define-key map [occur-rename-buffer]
754 '("Rename occur buffer" . occur-rename-buffer))
755 (define-key map [separator-2] '("--"))
756 (define-key map [occur-mode-goto-occurrence-other-window]
757 '("Go To Occurrence Other Window" . occur-mode-goto-occurrence-other-window))
758 (define-key map [occur-mode-goto-occurrence]
759 '("Go To Occurrence" . occur-mode-goto-occurrence))
760 (define-key map [occur-mode-display-occurrence]
761 '("Display Occurrence" . occur-mode-display-occurrence))
762 (define-key map [occur-next]
763 '("Move to next match" . occur-next))
764 (define-key map [occur-prev]
765 '("Move to previous match" . occur-prev))
728 map) 766 map)
729 "Keymap for `occur-mode'.") 767 "Keymap for `occur-mode'.")
730 768
@@ -938,23 +976,29 @@ which means to discard all text properties."
938 (nreverse result)))) 976 (nreverse result))))
939 977
940(defun occur-read-primary-args () 978(defun occur-read-primary-args ()
941 (list (let* ((default (car regexp-history)) 979 (let* ((default
942 (input 980 (list (and transient-mark-mode mark-active
943 (read-from-minibuffer 981 (regexp-quote
944 (if default 982 (buffer-substring-no-properties
945 (format "List lines matching regexp (default %s): " 983 (region-beginning) (region-end))))
946 (query-replace-descr default)) 984 (regexp-quote
947 "List lines matching regexp: ") 985 (or (funcall
948 nil 986 (or find-tag-default-function
949 nil 987 (get major-mode 'find-tag-default-function)
950 nil 988 'find-tag-default))
951 'regexp-history 989 ""))
952 default))) 990 (car regexp-search-ring)
953 (if (equal input "") 991 (regexp-quote (or (car search-ring) ""))
954 default 992 (car (symbol-value
955 input)) 993 query-replace-from-history-variable))))
956 (when current-prefix-arg 994 (default (delete-dups (delq nil (delete "" default))))
957 (prefix-numeric-value current-prefix-arg)))) 995 (input
996 (read-from-minibuffer
997 "List lines matching regexp: "
998 nil nil nil 'regexp-history default)))
999 (list input
1000 (when current-prefix-arg
1001 (prefix-numeric-value current-prefix-arg)))))
958 1002
959(defun occur-rename-buffer (&optional unique-p interactive-p) 1003(defun occur-rename-buffer (&optional unique-p interactive-p)
960 "Rename the current *Occur* buffer to *Occur: original-buffer-name*. 1004 "Rename the current *Occur* buffer to *Occur: original-buffer-name*.