aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2014-11-18 23:59:14 +0200
committerJuri Linkov2014-11-18 23:59:14 +0200
commitc0b877ba35f5b1d4fc63e8472d6021fba0c8395a (patch)
tree206e0deb96d77600aaca65fafaf629da804b79c1
parent5c0fbcfc8aa6ee13fbd4ea1516f25c804bebcf8c (diff)
downloademacs-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
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/replace.el29
2 files changed, 32 insertions, 9 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 6a6ff73b365..ba01694c5dd 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,17 @@
12014-11-18 Juri Linkov <juri@linkov.net> 12014-11-18 Juri Linkov <juri@linkov.net>
2 2
3 * replace.el (query-replace-from-to-separator): Turn defvar into
4 defcustom. Wrap char-displayable-p in ignore-errors because an
5 attempt to autoload char-displayable-p fails during pre-loading.
6 Move (propertize "\0" ... 'separator t) out of customizable part
7 to query-replace-read-from.
8 (query-replace-read-from): Call custom-reevaluate-setting on
9 query-replace-from-to-separator to reevaluate the separator
10 depending on the return value of char-displayable-p.
11 http://lists.gnu.org/archive/html/emacs-devel/2014-11/msg00466.html
12
132014-11-18 Juri Linkov <juri@linkov.net>
14
3 * bindings.el (minibuffer-local-map): Rebind [down] from 15 * bindings.el (minibuffer-local-map): Rebind [down] from
4 next-history-element to next-line-or-history-element, and [up] 16 next-history-element to next-line-or-history-element, and [up]
5 from previous-history-element to previous-line-or-history-element. 17 from previous-history-element to previous-line-or-history-element.
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\".")
67to the minibuffer that reads the string to replace, or invoke replacements 67to the minibuffer that reads the string to replace, or invoke replacements
68from Isearch by using a key sequence like `C-s C-s M-%'." "24.3") 68from 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
137wants to replace FROM with TO." 142wants 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)))