summaryrefslogtreecommitdiff
path: root/lisp/replace.el
diff options
context:
space:
mode:
authorJuri Linkov <juri@linkov.net>2017-02-28 00:50:57 +0200
committerJuri Linkov <juri@linkov.net>2017-02-28 00:50:57 +0200
commit61881d32ad4a8407fd4a3386a5f05b9f446f58fc (patch)
treef30fcdbcc40045c2bd47b282f1b9e38a33b01f8b /lisp/replace.el
parent3bf717b05b9d8fb53e953aa56649ffc38fd6e5d1 (diff)
downloademacs-61881d32ad4a8407fd4a3386a5f05b9f446f58fc.tar.gz
emacs-61881d32ad4a8407fd4a3386a5f05b9f446f58fc.tar.bz2
emacs-61881d32ad4a8407fd4a3386a5f05b9f446f58fc.zip
Put text properties on query-replace separator string instead of "\0"
* lisp/replace.el (query-replace--split-string): Split at a substring instead of just character. (query-replace-read-from): Put text properties on the separator string instead of "\0". (Bug#25482)
Diffstat (limited to 'lisp/replace.el')
-rw-r--r--lisp/replace.el34
1 files changed, 20 insertions, 14 deletions
diff --git a/lisp/replace.el b/lisp/replace.el
index b96c883982e..0841ba11b8b 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -149,14 +149,17 @@ See `replace-regexp' and `query-replace-regexp-eval'.")
(mapconcat 'isearch-text-char-description string ""))
(defun query-replace--split-string (string)
- "Split string STRING at a character with property `separator'"
+ "Split string STRING at a substring with property `separator'."
(let* ((length (length string))
(split-pos (text-property-any 0 length 'separator t string)))
(if (not split-pos)
(substring-no-properties string)
- (cl-assert (not (text-property-any (1+ split-pos) length 'separator t string)))
(cons (substring-no-properties string 0 split-pos)
- (substring-no-properties string (1+ split-pos) length)))))
+ (substring-no-properties
+ string (or (text-property-not-all
+ (1+ split-pos) length 'separator t string)
+ length)
+ length)))))
(defun query-replace-read-from (prompt regexp-flag)
"Query and return the `from' argument of a query-replace operation.
@@ -165,17 +168,19 @@ wants to replace FROM with TO."
(if query-replace-interactive
(car (if regexp-flag regexp-search-ring search-ring))
(let* ((history-add-new-input nil)
- (separator
+ (separator-string
(when query-replace-from-to-separator
- (propertize "\0"
- 'display
- (propertize
- (if (char-displayable-p
- (string-to-char (replace-regexp-in-string
- " " "" query-replace-from-to-separator)))
- query-replace-from-to-separator
- " -> ")
- 'face 'minibuffer-prompt)
+ ;; Check if the first non-whitespace char is displayable
+ (if (char-displayable-p
+ (string-to-char (replace-regexp-in-string
+ " " "" query-replace-from-to-separator)))
+ query-replace-from-to-separator
+ " -> ")))
+ (separator
+ (when separator-string
+ (propertize separator-string
+ 'display separator-string
+ 'face 'minibuffer-prompt
'separator t)))
(minibuffer-history
(append
@@ -203,7 +208,8 @@ wants to replace FROM with TO."
(minibuffer-with-setup-hook
(lambda ()
(setq-local text-property-default-nonsticky
- (cons '(separator . t) text-property-default-nonsticky)))
+ (append '((separator . t) (face . t))
+ text-property-default-nonsticky)))
(if regexp-flag
(read-regexp prompt nil 'minibuffer-history)
(read-from-minibuffer