diff options
| author | Juri Linkov | 2014-11-18 23:59:14 +0200 |
|---|---|---|
| committer | Juri Linkov | 2014-11-18 23:59:14 +0200 |
| commit | c0b877ba35f5b1d4fc63e8472d6021fba0c8395a (patch) | |
| tree | 206e0deb96d77600aaca65fafaf629da804b79c1 /lisp/replace.el | |
| parent | 5c0fbcfc8aa6ee13fbd4ea1516f25c804bebcf8c (diff) | |
| download | emacs-c0b877ba35f5b1d4fc63e8472d6021fba0c8395a.tar.gz emacs-c0b877ba35f5b1d4fc63e8472d6021fba0c8395a.zip | |
* lisp/replace.el (query-replace-from-to-separator): Turn defvar into defcustom.
Wrap char-displayable-p in ignore-errors because an attempt
to autoload char-displayable-p fails during pre-loading.
Move (propertize "\0" ... 'separator t) out of customizable part
to query-replace-read-from.
(query-replace-read-from): Call custom-reevaluate-setting on
query-replace-from-to-separator to reevaluate the separator
depending on the return value of char-displayable-p.
http://lists.gnu.org/archive/html/emacs-devel/2014-11/msg00466.html
Diffstat (limited to 'lisp/replace.el')
| -rw-r--r-- | lisp/replace.el | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/lisp/replace.el b/lisp/replace.el index c7fbcb5d99c..2c7ad19ea3b 100644 --- a/lisp/replace.el +++ b/lisp/replace.el | |||
| @@ -67,11 +67,16 @@ That becomes the \"string to replace\".") | |||
| 67 | to the minibuffer that reads the string to replace, or invoke replacements | 67 | to the minibuffer that reads the string to replace, or invoke replacements |
| 68 | from Isearch by using a key sequence like `C-s C-s M-%'." "24.3") | 68 | from Isearch by using a key sequence like `C-s C-s M-%'." "24.3") |
| 69 | 69 | ||
| 70 | (defvar query-replace-from-to-separator | 70 | (defcustom query-replace-from-to-separator |
| 71 | (propertize "\0" | 71 | (propertize |
| 72 | 'display (propertize " \u2192 " 'face 'minibuffer-prompt) | 72 | (or (ignore-errors |
| 73 | 'separator t) | 73 | (if (char-displayable-p ?\u2192) " \u2192 " " -> ")) |
| 74 | "String that separates FROM and TO in the history of replacement pairs.") | 74 | " -> ") |
| 75 | 'face 'minibuffer-prompt) | ||
| 76 | "String that separates FROM and TO in the history of replacement pairs." | ||
| 77 | :group 'matching | ||
| 78 | :type 'sexp | ||
| 79 | :version "25.1") | ||
| 75 | 80 | ||
| 76 | (defcustom query-replace-from-history-variable 'query-replace-history | 81 | (defcustom query-replace-from-history-variable 'query-replace-history |
| 77 | "History list to use for the FROM argument of `query-replace' commands. | 82 | "History list to use for the FROM argument of `query-replace' commands. |
| @@ -137,19 +142,25 @@ The return value can also be a pair (FROM . TO) indicating that the user | |||
| 137 | wants to replace FROM with TO." | 142 | wants to replace FROM with TO." |
| 138 | (if query-replace-interactive | 143 | (if query-replace-interactive |
| 139 | (car (if regexp-flag regexp-search-ring search-ring)) | 144 | (car (if regexp-flag regexp-search-ring search-ring)) |
| 145 | (custom-reevaluate-setting 'query-replace-from-to-separator) | ||
| 140 | (let* ((history-add-new-input nil) | 146 | (let* ((history-add-new-input nil) |
| 147 | (separator | ||
| 148 | (when query-replace-from-to-separator | ||
| 149 | (propertize "\0" | ||
| 150 | 'display query-replace-from-to-separator | ||
| 151 | 'separator t))) | ||
| 141 | (query-replace-from-to-history | 152 | (query-replace-from-to-history |
| 142 | (append | 153 | (append |
| 143 | (when query-replace-from-to-separator | 154 | (when separator |
| 144 | (mapcar (lambda (from-to) | 155 | (mapcar (lambda (from-to) |
| 145 | (concat (query-replace-descr (car from-to)) | 156 | (concat (query-replace-descr (car from-to)) |
| 146 | query-replace-from-to-separator | 157 | separator |
| 147 | (query-replace-descr (cdr from-to)))) | 158 | (query-replace-descr (cdr from-to)))) |
| 148 | query-replace-defaults)) | 159 | query-replace-defaults)) |
| 149 | (symbol-value query-replace-from-history-variable))) | 160 | (symbol-value query-replace-from-history-variable))) |
| 150 | (minibuffer-allow-text-properties t) ; separator uses text-properties | 161 | (minibuffer-allow-text-properties t) ; separator uses text-properties |
| 151 | (prompt | 162 | (prompt |
| 152 | (if (and query-replace-defaults query-replace-from-to-separator) | 163 | (if (and query-replace-defaults separator) |
| 153 | (format "%s (default %s): " prompt (car query-replace-from-to-history)) | 164 | (format "%s (default %s): " prompt (car query-replace-from-to-history)) |
| 154 | (format "%s: " prompt))) | 165 | (format "%s: " prompt))) |
| 155 | (from | 166 | (from |
| @@ -166,7 +177,7 @@ wants to replace FROM with TO." | |||
| 166 | (cons (caar query-replace-defaults) | 177 | (cons (caar query-replace-defaults) |
| 167 | (query-replace-compile-replacement | 178 | (query-replace-compile-replacement |
| 168 | (cdar query-replace-defaults) regexp-flag)) | 179 | (cdar query-replace-defaults) regexp-flag)) |
| 169 | (let* ((to (if (and (string-match query-replace-from-to-separator from) | 180 | (let* ((to (if (and (string-match separator from) |
| 170 | (get-text-property (match-beginning 0) 'separator from)) | 181 | (get-text-property (match-beginning 0) 'separator from)) |
| 171 | (query-replace-compile-replacement | 182 | (query-replace-compile-replacement |
| 172 | (substring-no-properties from (match-end 0)) regexp-flag))) | 183 | (substring-no-properties from (match-end 0)) regexp-flag))) |