/[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.181 by monnier, Mon Jul 5 22:50:46 2004 UTC revision 1.182 by monnier, Mon Jul 5 23:12:28 2004 UTC
# Line 64  strings or patterns." Line 64  strings or patterns."
64    :group 'matching    :group 'matching
65    :version "21.4")    :version "21.4")
66    
67  (defun query-replace-read-args (string regexp-flag &optional noerror)  (defun query-replace-read-from (string regexp-flag)
68    (unless noerror    "Query and return the `from' argument of a query-replace operation."
69      (barf-if-buffer-read-only))    (if query-replace-interactive
70    (let (from to)        (car (if regexp-flag regexp-search-ring search-ring))
71      (if query-replace-interactive      (let* ((from
72          (setq from (car (if regexp-flag regexp-search-ring search-ring)))              ;; The save-excursion here is in case the user marks and copies
73        ;; The save-excursion here is in case the user marks and copies              ;; a region in order to specify the minibuffer input.
74        ;; a region in order to specify the minibuffer input.              ;; That should not clobber the region for the query-replace itself.
75        ;; That should not clobber the region for the query-replace itself.              (save-excursion
76        (save-excursion                (read-from-minibuffer
77          (setq from (read-from-minibuffer                 (format "%s: " string)
78                      (format "%s: " string)                 nil nil nil
79                      nil nil nil                 query-replace-from-history-variable
80                      query-replace-from-history-variable                 nil t))))
                     nil t)))  
81        ;; Warn if user types \n or \t, but don't reject the input.        ;; Warn if user types \n or \t, but don't reject the input.
82        (and regexp-flag        (and regexp-flag
83             (string-match "\\(\\`\\|[^\\]\\)\\(\\\\\\\\\\)*\\(\\\\[nt]\\)" from)             (string-match "\\(\\`\\|[^\\]\\)\\(\\\\\\\\\\)*\\(\\\\[nt]\\)" from)
# Line 88  strings or patterns." Line 87  strings or patterns."
87                 (message "Note: `\\n' here doesn't match a newline; to do that, type C-q C-j instead"))                 (message "Note: `\\n' here doesn't match a newline; to do that, type C-q C-j instead"))
88                ((string= match "\\t")                ((string= match "\\t")
89                 (message "Note: `\\t' here doesn't match a tab; to do that, just type TAB")))                 (message "Note: `\\t' here doesn't match a tab; to do that, just type TAB")))
90               (sit-for 2))))               (sit-for 2)))
91          from)))
92    
93      (save-excursion  (defun query-replace-read-to (from string regexp-flag)
94        (setq to (read-from-minibuffer    "Query and return the `from' argument of a query-replace operation."
95                  (format "%s %s with: " string from)    (let ((to (save-excursion
96                  nil nil nil                (read-from-minibuffer
97                  query-replace-to-history-variable from t)))                 (format "%s %s with: " string from)
98                   nil nil nil
99                   query-replace-to-history-variable from t))))
100      (when (and regexp-flag      (when (and regexp-flag
101                 (string-match "\\(\\`\\|[^\\]\\)\\(\\\\\\\\\\)*\\\\[,#]" to))                 (string-match "\\(\\`\\|[^\\]\\)\\(\\\\\\\\\\)*\\\\[,#]" to))
102        (let (pos list char)        (let (pos list char)
# Line 129  strings or patterns." Line 131  strings or patterns."
131                       (if (> (length to) 1)                       (if (> (length to) 1)
132                           (cons 'concat to)                           (cons 'concat to)
133                         (car to)))))                         (car to)))))
134        to))
135    
136    (defun query-replace-read-args (string regexp-flag &optional noerror)
137      (unless noerror
138        (barf-if-buffer-read-only))
139      (let* ((from (query-replace-read-from string regexp-flag))
140             (to (query-replace-read-to from string regexp-flag)))
141      (list from to current-prefix-arg)))      (list from to current-prefix-arg)))
142    
143  (defun query-replace (from-string to-string &optional delimited start end)  (defun query-replace (from-string to-string &optional delimited start end)

Legend:
Removed from v.1.181  
changed lines
  Added in v.1.182

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