Commit c0b877ba authored by Juri Linkov's avatar Juri Linkov
Browse files

* 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
parent 5c0fbcfc
2014-11-18 Juri Linkov <juri@linkov.net>
* 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
2014-11-18 Juri Linkov <juri@linkov.net>
* bindings.el (minibuffer-local-map): Rebind [down] from
......
......@@ -67,11 +67,16 @@ That becomes the \"string to replace\".")
to the minibuffer that reads the string to replace, or invoke replacements
from Isearch by using a key sequence like `C-s C-s M-%'." "24.3")
(defvar query-replace-from-to-separator
(propertize "\0"
'display (propertize " \u2192 " 'face 'minibuffer-prompt)
'separator t)
"String that separates FROM and TO in the history of replacement pairs.")
(defcustom query-replace-from-to-separator
(propertize
(or (ignore-errors
(if (char-displayable-p ?\u2192) " \u2192 " " -> "))
" -> ")
'face 'minibuffer-prompt)
"String that separates FROM and TO in the history of replacement pairs."
:group 'matching
:type 'sexp
:version "25.1")
(defcustom query-replace-from-history-variable 'query-replace-history
"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
wants to replace FROM with TO."
(if query-replace-interactive
(car (if regexp-flag regexp-search-ring search-ring))
(custom-reevaluate-setting 'query-replace-from-to-separator)
(let* ((history-add-new-input nil)
(separator
(when query-replace-from-to-separator
(propertize "\0"
'display query-replace-from-to-separator
'separator t)))
(query-replace-from-to-history
(append
(when query-replace-from-to-separator
(when separator
(mapcar (lambda (from-to)
(concat (query-replace-descr (car from-to))
query-replace-from-to-separator
separator
(query-replace-descr (cdr from-to))))
query-replace-defaults))
(symbol-value query-replace-from-history-variable)))
(minibuffer-allow-text-properties t) ; separator uses text-properties
(prompt
(if (and query-replace-defaults query-replace-from-to-separator)
(if (and query-replace-defaults separator)
(format "%s (default %s): " prompt (car query-replace-from-to-history))
(format "%s: " prompt)))
(from
......@@ -166,7 +177,7 @@ wants to replace FROM with TO."
(cons (caar query-replace-defaults)
(query-replace-compile-replacement
(cdar query-replace-defaults) regexp-flag))
(let* ((to (if (and (string-match query-replace-from-to-separator from)
(let* ((to (if (and (string-match separator from)
(get-text-property (match-beginning 0) 'separator from))
(query-replace-compile-replacement
(substring-no-properties from (match-end 0)) regexp-flag)))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment