unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org
Subject: Re: History for query replace pairs
Date: Mon, 10 Nov 2014 01:12:08 +0200	[thread overview]
Message-ID: <8761eovuif.fsf@mail.jurta.org> (raw)
In-Reply-To: <jwvfvdsja96.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Sun, 09 Nov 2014 17:14:08 -0500")

> 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	other threads:[~2014-11-09 23:12 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-08 20:20 History for query replace pairs Tom
2014-08-08 20:28 ` Drew Adams
2014-08-08 23:38 ` Juri Linkov
2014-08-09  5:35   ` Herring, Davis
2014-08-10  1:18   ` Josh
2014-08-10  5:59     ` Tom
2014-08-11 18:34       ` Tom
2014-10-04 21:45         ` Ted Zlatanov
2014-10-04 23:36           ` Juri Linkov
2014-10-05  1:52             ` Yuri Khan
2014-10-05 21:54               ` Juri Linkov
2014-10-05  7:09             ` Andreas Schwab
2014-10-05  1:52           ` Stefan Monnier
2014-10-05  5:59           ` Tom
2014-10-06  0:46             ` Ted Zlatanov
2014-10-06 20:17               ` Tom
2014-10-06 22:35               ` Juri Linkov
2014-10-07 22:11                 ` Juri Linkov
2014-10-14 17:14                   ` Stefan Monnier
2014-10-14 19:02                     ` Juri Linkov
2014-10-14 19:13                       ` Alan Mackenzie
2014-10-14 19:44                         ` Juri Linkov
2014-10-14 20:15                           ` Alan Mackenzie
2014-10-14 20:16                           ` Drew Adams
2014-10-14 20:28                             ` Juri Linkov
2014-10-14 21:19                               ` Drew Adams
2014-10-14 20:05                         ` Andreas Schwab
2014-10-14 20:09                           ` Alan Mackenzie
2014-10-14 20:23                             ` Andreas Schwab
2014-10-21 18:23                       ` Stefan Monnier
2014-10-21 22:53                         ` Juri Linkov
2014-10-22 12:58                           ` Stefan Monnier
2014-10-23  9:06                             ` Artur Malabarba
2014-10-25 20:57                               ` Juri Linkov
2014-10-26  1:12                                 ` Artur Malabarba
2014-10-26  2:31                                   ` Stefan Monnier
2014-10-26  6:58                                   ` Andreas Schwab
2014-10-25 20:52                             ` Juri Linkov
2014-10-26  2:29                               ` Stefan Monnier
2014-10-26 23:27                                 ` Juri Linkov
2014-11-03 13:30                               ` Ted Zlatanov
2014-11-03 23:46                                 ` Juri Linkov
2014-11-04  0:59                                   ` Ted Zlatanov
2014-11-04 23:09                                     ` Juri Linkov
2014-11-05  1:55                                       ` Stefan Monnier
2014-11-05 23:20                                         ` Juri Linkov
2014-11-06  2:35                                           ` Stefan Monnier
2014-11-07 23:34                                             ` Juri Linkov
2014-11-08  0:59                                               ` Ted Zlatanov
2014-11-08  8:46                                                 ` Eli Zaretskii
2014-11-08 10:29                                                   ` Juri Linkov
2014-11-08 11:24                                                     ` Eli Zaretskii
2014-11-08 15:28                                                       ` Stefan Monnier
2014-11-08 17:29                                                         ` Eli Zaretskii
2014-11-08 22:52                                                         ` Juri Linkov
2014-11-09  2:01                                                           ` Stefan Monnier
2014-11-09 16:15                                                             ` Eli Zaretskii
2014-11-09 17:11                                                               ` Juri Linkov
2014-11-09 22:14                                                                 ` Stefan Monnier
2014-11-09 23:12                                                                   ` Juri Linkov [this message]
2014-11-09 22:10                                                               ` Stefan Monnier
2014-11-09  2:29                                                           ` Paul Eggert
2014-11-09 17:15                                                             ` Juri Linkov
2014-11-08 22:51                                                       ` Juri Linkov
2014-11-09 17:29                                                         ` Eli Zaretskii
2014-11-08 10:15                                                 ` Juri Linkov
2014-11-08  8:25                                               ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8761eovuif.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).