emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: History for query replace pairs


From: Juri Linkov
Subject: Re: History for query replace pairs
Date: Mon, 10 Nov 2014 01:12:08 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu)

> The (not (equal (car preloaded-file-list) "replace")) test makes
> no sense.  Why don't we want to call char-displayable-p while
> pre-loading replace?  Shouldn't we instead test (fboundp 'char-displayable-p)
> or simply wrap the code in ignore-errors (if the problem is that
> char-displayable-p fails when run without a real frame at hand, which
> might also happen in daemon mode)?

I already tried (fboundp 'char-displayable-p) earlier but it
returns t while pre-loading because the problem was caused
by an attempt to autoload char-displayable-p.

Now I tried ignore-errors, and there are no problems with it:

=== modified file 'lisp/replace.el'
--- lisp/replace.el     2014-11-07 23:33:41 +0000
+++ lisp/replace.el     2014-11-09 22:58:25 +0000
@@ -67,11 +67,16 @@ (make-obsolete-variable 'query-replace-i
 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 @@ (defun query-replace-read-from (prompt r
 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 @@ (defun query-replace-read-from (prompt r
          (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)))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]