/[emacs]/emacs/lisp/replace.el
ViewVC logotype

Diff of /emacs/lisp/replace.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.152 by rms, Thu Jul 18 15:00:56 2002 UTC revision 1.153 by sds, Thu Jul 25 19:31:25 2002 UTC
# Line 360  end of the buffer." Line 360  end of the buffer."
360              ;; Now end is first char preserved by the new match.              ;; Now end is first char preserved by the new match.
361              (if (< start end)              (if (< start end)
362                  (delete-region start end))))                  (delete-region start end))))
363            
364          (setq start (save-excursion (forward-line 1) (point)))          (setq start (save-excursion (forward-line 1) (point)))
365          ;; If the match was empty, avoid matching again at same place.          ;; If the match was empty, avoid matching again at same place.
366          (and (< (point) rend)          (and (< (point) rend)
# Line 452  end of the buffer." Line 452  end of the buffer."
452      (define-key map "\C-o" 'occur-mode-display-occurrence)      (define-key map "\C-o" 'occur-mode-display-occurrence)
453      (define-key map "\M-n" 'occur-next)      (define-key map "\M-n" 'occur-next)
454      (define-key map "\M-p" 'occur-prev)      (define-key map "\M-p" 'occur-prev)
455        (define-key map "r" 'occur-rename-buffer)
456        (define-key map "c" 'clone-buffer)
457      (define-key map "g" 'revert-buffer)      (define-key map "g" 'revert-buffer)
458      (define-key map "q" 'delete-window)      (define-key map "q" 'quit-window)
459        (define-key map "z" 'kill-this-buffer)
460      map)      map)
461    "Keymap for `occur-mode'.")    "Keymap for `occur-mode'.")
462    
# Line 554  Alternatively, click \\[occur-mode-mouse Line 557  Alternatively, click \\[occur-mode-mouse
557    (if (not n) (setq n 1))    (if (not n) (setq n 1))
558    (let ((r))    (let ((r))
559      (while (> n 0)      (while (> n 0)
560        
561        (setq r (get-text-property (point) 'occur-point))        (setq r (get-text-property (point) 'occur-point))
562        (if r (forward-char -1))        (if r (forward-char -1))
563          
564        (setq r (previous-single-property-change (point) 'occur-point))        (setq r (previous-single-property-change (point) 'occur-point))
565        (if r        (if r
566            (goto-char (- r 1))            (goto-char (- r 1))
567          (error "No earlier matches"))          (error "No earlier matches"))
568          
569        (setq n (1- n)))))        (setq n (1- n)))))
570    
571  (defcustom list-matching-lines-default-context-lines 0  (defcustom list-matching-lines-default-context-lines 0
# Line 623  If the value is nil, don't highlight the Line 626  If the value is nil, don't highlight the
626          (when current-prefix-arg          (when current-prefix-arg
627            (prefix-numeric-value current-prefix-arg))))            (prefix-numeric-value current-prefix-arg))))
628    
629    (defun occur-rename-buffer (&optional unique-p)
630      "Rename the current *Occur* buffer to *Occur: original-buffer-name*.
631    Here `original-buffer-name' is the buffer name were occur was originally run.
632    When given the prefix argument, the renaming will not clobber the existing
633    buffer(s) of that name, but use `generate-new-buffer-name' instead.
634    You can add this to `occur-mode-hook' if you always want a separate *Occur*
635    buffer for each buffer where you invoke `occur'."
636      (interactive "P")
637      (with-current-buffer
638          (if (eq major-mode 'occur-mode) (current-buffer) (get-buffer "*Occur*"))
639        (rename-buffer (concat "*Occur: "
640                               (mapconcat #'buffer-name
641                                          (car (cddr occur-revert-arguments)) "/")
642                               "*")
643                       unique-p)))
644    
645  (defun occur (regexp &optional nlines)  (defun occur (regexp &optional nlines)
646    "Show all lines in the current buffer containing a match for REGEXP.    "Show all lines in the current buffer containing a match for REGEXP.
647    
# Line 948  type them." Line 967  type them."
967            (aset data 2 (if (consp next) next (aref data 3))))))            (aset data 2 (if (consp next) next (aref data 3))))))
968    (car (aref data 2)))    (car (aref data 2)))
969    
970  (defun perform-replace (from-string replacements  (defun perform-replace (from-string replacements
971                          query-flag regexp-flag delimited-flag                          query-flag regexp-flag delimited-flag
972                          &optional repeat-count map start end)                          &optional repeat-count map start end)
973    "Subroutine of `query-replace'.  Its complexity handles interactive queries.    "Subroutine of `query-replace'.  Its complexity handles interactive queries.
# Line 1173  make, or the user didn't cancel the call Line 1192  make, or the user didn't cancel the call
1192                           (if (and regexp-flag nonempty-match)                           (if (and regexp-flag nonempty-match)
1193                               (setq match-again (and (looking-at search-string)                               (setq match-again (and (looking-at search-string)
1194                                                      (match-data)))))                                                      (match-data)))))
1195                          
1196                          ;; Edit replacement.                          ;; Edit replacement.
1197                          ((eq def 'edit-replacement)                          ((eq def 'edit-replacement)
1198                           (setq next-replacement                           (setq next-replacement
# Line 1182  make, or the user didn't cancel the call Line 1201  make, or the user didn't cancel the call
1201                           (or replaced                           (or replaced
1202                               (replace-match next-replacement nocasify literal))                               (replace-match next-replacement nocasify literal))
1203                           (setq done t))                           (setq done t))
1204                          
1205                          ((eq def 'delete-and-edit)                          ((eq def 'delete-and-edit)
1206                           (delete-region (match-beginning 0) (match-end 0))                           (delete-region (match-beginning 0) (match-end 0))
1207                           (set-match-data                           (set-match-data
# Line 1212  make, or the user didn't cancel the call Line 1231  make, or the user didn't cancel the call
1231        ;; beyond the last replacement.  Undo that.        ;; beyond the last replacement.  Undo that.
1232        (when (and regexp-flag (not match-again) (> replace-count 0))        (when (and regexp-flag (not match-again) (> replace-count 0))
1233          (backward-char 1))          (backward-char 1))
1234          
1235        (replace-dehighlight))        (replace-dehighlight))
1236      (or unread-command-events      (or unread-command-events
1237          (message "Replaced %d occurrence%s"          (message "Replaced %d occurrence%s"

Legend:
Removed from v.1.152  
changed lines
  Added in v.1.153

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26