/[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.120.4.2 by schwab, Mon Feb 18 20:31:31 2002 UTC revision 1.120.4.3 by lektu, Wed Oct 16 06:27:56 2002 UTC
# Line 336  end of the buffer." Line 336  end of the buffer."
336              ;; Now end is first char preserved by the new match.              ;; Now end is first char preserved by the new match.
337              (if (< start end)              (if (< start end)
338                  (delete-region start end))))                  (delete-region start end))))
339            
340          (setq start (save-excursion (forward-line 1) (point)))          (setq start (save-excursion (forward-line 1) (point)))
341          ;; If the match was empty, avoid matching again at same place.          ;; If the match was empty, avoid matching again at same place.
342          (and (< (point) rend)          (and (< (point) rend)
# Line 511  Alternatively, click \\[occur-mode-mouse Line 511  Alternatively, click \\[occur-mode-mouse
511    (if (not n) (setq n 1))    (if (not n) (setq n 1))
512    (let ((r))    (let ((r))
513      (while (> n 0)      (while (> n 0)
514        
515        (setq r (get-text-property (point) 'occur-point))        (setq r (get-text-property (point) 'occur-point))
516        (if r (forward-char -1))        (if r (forward-char -1))
517          
518        (setq r (previous-single-property-change (point) 'occur-point))        (setq r (previous-single-property-change (point) 'occur-point))
519        (if r        (if r
520            (goto-char (- r 1))            (goto-char (- r 1))
521          (error "No earlier matches"))          (error "No earlier matches"))
522          
523        (setq n (1- n)))))        (setq n (1- n)))))
524    
525  (defcustom list-matching-lines-default-context-lines 0  (defcustom list-matching-lines-default-context-lines 0
# Line 699  the matching is case-sensitive." Line 699  the matching is case-sensitive."
699                                           (bolp)))                                           (bolp)))
700                                       1 0)))                                       1 0)))
701                    (set-marker text-end (point))                    (set-marker text-end (point))
702                      
703                    ;; Highlight text that was matched.                    ;; Highlight text that was matched.
704                    (if list-matching-lines-face                    (if list-matching-lines-face
705                        (put-text-property                        (put-text-property
# Line 713  the matching is case-sensitive." Line 713  the matching is case-sensitive."
713                     (+ (marker-position text-beg) match-beg match-len)                     (+ (marker-position text-beg) match-beg match-len)
714                     (+ (marker-position text-beg) match-beg match-len 1)                     (+ (marker-position text-beg) match-beg match-len 1)
715                     'occur-point t)                     'occur-point t)
716                      
717                    ;; Now go back to the start of the matching text                    ;; Now go back to the start of the matching text
718                    ;; adding the space and colon to the start of each line.                    ;; adding the space and colon to the start of each line.
719                    (goto-char insertion-start)                    (goto-char insertion-start)
# Line 746  the matching is case-sensitive." Line 746  the matching is case-sensitive."
746                      (insert empty ?:)                      (insert empty ?:)
747                      (forward-line 1)                      (forward-line 1)
748                      (setq tem (1+ tem)))                      (setq tem (1+ tem)))
749                      
750                    ;; Add text properties.  The `occur' prop is used to                    ;; Add text properties.  The `occur' prop is used to
751                    ;; store the marker of the matching text in the                    ;; store the marker of the matching text in the
752                    ;; source buffer.                    ;; source buffer.
753                    (add-text-properties                    (add-text-properties
754                     (marker-position text-beg) (- (marker-position text-end) 1)                     (marker-position text-beg) (- (marker-position text-end) 1)
755                     '(mouse-face highlight                     '(mouse-face highlight
756                       help-echo "mouse-2: go to this occurence"))                       help-echo "mouse-2: go to this occurrence"))
757                    (put-text-property (marker-position text-beg)                    (put-text-property (marker-position text-beg)
758                                       (marker-position text-end)                                       (marker-position text-end)
759                                       'occur occur-marker)                                       'occur occur-marker)
# Line 870  type them." Line 870  type them."
870            (aset data 2 (if (consp next) next (aref data 3))))))            (aset data 2 (if (consp next) next (aref data 3))))))
871    (car (aref data 2)))    (car (aref data 2)))
872    
873  (defun perform-replace (from-string replacements  (defun perform-replace (from-string replacements
874                          query-flag regexp-flag delimited-flag                          query-flag regexp-flag delimited-flag
875                          &optional repeat-count map start end)                          &optional repeat-count map start end)
876    "Subroutine of `query-replace'.  Its complexity handles interactive queries.    "Subroutine of `query-replace'.  Its complexity handles interactive queries.
# Line 1086  see the documentation of `replace-match' Line 1086  see the documentation of `replace-match'
1086                         (if (and regexp-flag nonempty-match)                         (if (and regexp-flag nonempty-match)
1087                             (setq match-again (and (looking-at search-string)                             (setq match-again (and (looking-at search-string)
1088                                                    (match-data)))))                                                    (match-data)))))
1089                          
1090                        ;; Edit replacement.                        ;; Edit replacement.
1091                        ((eq def 'edit-replacement)                        ((eq def 'edit-replacement)
1092                         (setq next-replacement                         (setq next-replacement
# Line 1095  see the documentation of `replace-match' Line 1095  see the documentation of `replace-match'
1095                         (or replaced                         (or replaced
1096                             (replace-match next-replacement nocasify literal))                             (replace-match next-replacement nocasify literal))
1097                         (setq done t))                         (setq done t))
1098                          
1099                        ((eq def 'delete-and-edit)                        ((eq def 'delete-and-edit)
1100                         (delete-region (match-beginning 0) (match-end 0))                         (delete-region (match-beginning 0) (match-end 0))
1101                         (set-match-data                         (set-match-data
# Line 1125  see the documentation of `replace-match' Line 1125  see the documentation of `replace-match'
1125        ;; beyond the last replacement.  Undo that.        ;; beyond the last replacement.  Undo that.
1126        (when (and regexp-flag (not match-again) (> replace-count 0))        (when (and regexp-flag (not match-again) (> replace-count 0))
1127          (backward-char 1))          (backward-char 1))
1128          
1129        (replace-dehighlight))        (replace-dehighlight))
1130      (or unread-command-events      (or unread-command-events
1131          (message "Replaced %d occurrence%s"          (message "Replaced %d occurrence%s"

Legend:
Removed from v.1.120.4.2  
changed lines
  Added in v.1.120.4.3

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