]> code.delx.au - gnu-emacs/commitdiff
* lisp/replace.el (query-replace-from-to-separator): Turn defvar into defcustom.
authorJuri Linkov <juri@linkov.net>
Tue, 18 Nov 2014 21:59:14 +0000 (23:59 +0200)
committerJuri Linkov <juri@linkov.net>
Tue, 18 Nov 2014 21:59:14 +0000 (23:59 +0200)
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

lisp/ChangeLog
lisp/replace.el

index 6a6ff73b365fb54bc70d3ed261ce73ac29dc210f..ba01694c5dd933dfb3711b9e0d5ce93b4b3b1040 100644 (file)
@@ -1,3 +1,15 @@
+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
index c7fbcb5d99c52054b6eee38e2168448b5eab52a8..2c7ad19ea3b94a4f1987e6236a89fd405a1d5f0b 100644 (file)
@@ -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)))