diff options
| author | Stefan Monnier | 2004-07-05 22:50:46 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2004-07-05 22:50:46 +0000 |
| commit | 5291cbca50f116e0848623668ab3dc8cc1ff1cbe (patch) | |
| tree | 32c49658053565118f188ec31a815a419f041519 | |
| parent | 00c8fbf6f62bda11658ea2a8ce324736d5062d8a (diff) | |
| download | emacs-5291cbca50f116e0848623668ab3dc8cc1ff1cbe.tar.gz emacs-5291cbca50f116e0848623668ab3dc8cc1ff1cbe.zip | |
(query-replace-interactive, query-replace-read-args):
Remove the `initial' special value.
(query-replace-regexp-eval, map-query-replace-regexp): Simplify.
(occur-engine): Remove unused var `matchend'.
| -rw-r--r-- | lisp/replace.el | 47 |
1 files changed, 17 insertions, 30 deletions
diff --git a/lisp/replace.el b/lisp/replace.el index 4c381c658e5..2d3e1f40a31 100644 --- a/lisp/replace.el +++ b/lisp/replace.el | |||
| @@ -36,15 +36,9 @@ | |||
| 36 | 36 | ||
| 37 | (defvar query-replace-history nil) | 37 | (defvar query-replace-history nil) |
| 38 | 38 | ||
| 39 | (defcustom query-replace-interactive nil | 39 | (defvar query-replace-interactive nil |
| 40 | "Non-nil means `query-replace' uses the last search string. | 40 | "Non-nil means `query-replace' uses the last search string. |
| 41 | That becomes the \"string to replace\". | 41 | That becomes the \"string to replace\".") |
| 42 | If value is `initial', the last search string is inserted into | ||
| 43 | the minibuffer as an initial value for \"string to replace\"." | ||
| 44 | :type '(choice (const :tag "Off" nil) | ||
| 45 | (const :tag "Initial content" initial) | ||
| 46 | (other :tag "Use default value" t)) | ||
| 47 | :group 'matching) | ||
| 48 | 42 | ||
| 49 | (defcustom query-replace-from-history-variable 'query-replace-history | 43 | (defcustom query-replace-from-history-variable 'query-replace-history |
| 50 | "History list to use for the FROM argument of `query-replace' commands. | 44 | "History list to use for the FROM argument of `query-replace' commands. |
| @@ -74,8 +68,7 @@ strings or patterns." | |||
| 74 | (unless noerror | 68 | (unless noerror |
| 75 | (barf-if-buffer-read-only)) | 69 | (barf-if-buffer-read-only)) |
| 76 | (let (from to) | 70 | (let (from to) |
| 77 | (if (and query-replace-interactive | 71 | (if query-replace-interactive |
| 78 | (not (eq query-replace-interactive 'initial))) | ||
| 79 | (setq from (car (if regexp-flag regexp-search-ring search-ring))) | 72 | (setq from (car (if regexp-flag regexp-search-ring search-ring))) |
| 80 | ;; 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 |
| 81 | ;; a region in order to specify the minibuffer input. | 74 | ;; a region in order to specify the minibuffer input. |
| @@ -83,9 +76,7 @@ strings or patterns." | |||
| 83 | (save-excursion | 76 | (save-excursion |
| 84 | (setq from (read-from-minibuffer | 77 | (setq from (read-from-minibuffer |
| 85 | (format "%s: " string) | 78 | (format "%s: " string) |
| 86 | (if (eq query-replace-interactive 'initial) | 79 | nil nil nil |
| 87 | (car (if regexp-flag regexp-search-ring search-ring))) | ||
| 88 | nil nil | ||
| 89 | query-replace-from-history-variable | 80 | query-replace-from-history-variable |
| 90 | nil t))) | 81 | nil t))) |
| 91 | ;; Warn if user types \n or \t, but don't reject the input. | 82 | ;; Warn if user types \n or \t, but don't reject the input. |
| @@ -269,16 +260,15 @@ Third arg DELIMITED (prefix arg if interactive), if non-nil, means replace | |||
| 269 | only matches that are surrounded by word boundaries. | 260 | only matches that are surrounded by word boundaries. |
| 270 | Fourth and fifth arg START and END specify the region to operate on." | 261 | Fourth and fifth arg START and END specify the region to operate on." |
| 271 | (interactive | 262 | (interactive |
| 272 | (let (from to) | 263 | (let* ((from (if query-replace-interactive |
| 273 | (if query-replace-interactive | 264 | (car regexp-search-ring) |
| 274 | (setq from (car regexp-search-ring)) | 265 | (read-from-minibuffer "Query replace regexp: " |
| 275 | (setq from (read-from-minibuffer "Query replace regexp: " | 266 | nil nil nil |
| 276 | nil nil nil | 267 | query-replace-from-history-variable |
| 277 | query-replace-from-history-variable | 268 | nil t))) |
| 278 | nil t))) | 269 | (to (list (read-from-minibuffer |
| 279 | (setq to (list (read-from-minibuffer | 270 | (format "Query replace regexp %s with eval: " from) |
| 280 | (format "Query replace regexp %s with eval: " from) | 271 | nil nil t query-replace-to-history-variable from t)))) |
| 281 | nil nil t query-replace-to-history-variable from t))) | ||
| 282 | ;; We make TO a list because replace-match-string-symbols requires one, | 272 | ;; We make TO a list because replace-match-string-symbols requires one, |
| 283 | ;; and the user might enter a single token. | 273 | ;; and the user might enter a single token. |
| 284 | (replace-match-string-symbols to) | 274 | (replace-match-string-symbols to) |
| @@ -311,17 +301,16 @@ A prefix argument N says to use each replacement string N times | |||
| 311 | before rotating to the next. | 301 | before rotating to the next. |
| 312 | Fourth and fifth arg START and END specify the region to operate on." | 302 | Fourth and fifth arg START and END specify the region to operate on." |
| 313 | (interactive | 303 | (interactive |
| 314 | (let (from to) | 304 | (let* ((from (if query-replace-interactive |
| 315 | (setq from (if query-replace-interactive | ||
| 316 | (car regexp-search-ring) | 305 | (car regexp-search-ring) |
| 317 | (read-from-minibuffer "Map query replace (regexp): " | 306 | (read-from-minibuffer "Map query replace (regexp): " |
| 318 | nil nil nil | 307 | nil nil nil |
| 319 | 'query-replace-history nil t))) | 308 | 'query-replace-history nil t))) |
| 320 | (setq to (read-from-minibuffer | 309 | (to (read-from-minibuffer |
| 321 | (format "Query replace %s with (space-separated strings): " | 310 | (format "Query replace %s with (space-separated strings): " |
| 322 | from) | 311 | from) |
| 323 | nil nil nil | 312 | nil nil nil |
| 324 | 'query-replace-history from t)) | 313 | 'query-replace-history from t))) |
| 325 | (list from to | 314 | (list from to |
| 326 | (and current-prefix-arg | 315 | (and current-prefix-arg |
| 327 | (prefix-numeric-value current-prefix-arg)) | 316 | (prefix-numeric-value current-prefix-arg)) |
| @@ -925,7 +914,6 @@ See also `multi-occur'." | |||
| 925 | (let ((matches 0) ;; count of matched lines | 914 | (let ((matches 0) ;; count of matched lines |
| 926 | (lines 1) ;; line count | 915 | (lines 1) ;; line count |
| 927 | (matchbeg 0) | 916 | (matchbeg 0) |
| 928 | (matchend 0) | ||
| 929 | (origpt nil) | 917 | (origpt nil) |
| 930 | (begpt nil) | 918 | (begpt nil) |
| 931 | (endpt nil) | 919 | (endpt nil) |
| @@ -945,8 +933,7 @@ See also `multi-occur'." | |||
| 945 | (setq origpt (point)) | 933 | (setq origpt (point)) |
| 946 | (when (setq endpt (re-search-forward regexp nil t)) | 934 | (when (setq endpt (re-search-forward regexp nil t)) |
| 947 | (setq matches (1+ matches)) ;; increment match count | 935 | (setq matches (1+ matches)) ;; increment match count |
| 948 | (setq matchbeg (match-beginning 0) | 936 | (setq matchbeg (match-beginning 0)) |
| 949 | matchend (match-end 0)) | ||
| 950 | (setq begpt (save-excursion | 937 | (setq begpt (save-excursion |
| 951 | (goto-char matchbeg) | 938 | (goto-char matchbeg) |
| 952 | (line-beginning-position))) | 939 | (line-beginning-position))) |