From: Juri Linkov Date: Tue, 18 Nov 2014 21:59:14 +0000 (+0200) Subject: * lisp/replace.el (query-replace-from-to-separator): Turn defvar into defcustom. X-Git-Tag: emacs-25.0.90~2635^2~421 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c0b877ba35f5b1d4fc63e8472d6021fba0c8395a;p=emacs.git * 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 --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 6a6ff73b365..ba01694c5dd 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,15 @@ +2014-11-18 Juri Linkov + + * 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 * bindings.el (minibuffer-local-map): Rebind [down] from 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\".") 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)))