all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: "Clément Pit-Claudel" <cpitclaudel@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: Isearch interaction model
Date: Fri, 09 Mar 2018 00:55:17 +0200	[thread overview]
Message-ID: <87y3j29nze.fsf@mail.linkov.net> (raw)
In-Reply-To: <43455926-bd9b-37ee-2364-ac855781f463@gmail.com> ("Clément Pit-Claudel"'s message of "Sat, 3 Mar 2018 18:46:31 -0500")

[-- Attachment #1: Type: text/plain, Size: 482 bytes --]

>> because text properties on strings can't be saved
>> in the desktop file or by other history saving libraries.
>
> Couldn't we change that instead?

It seems text properties is the least bad of all other alternatives
that are not backward compatible and don't allow adding support for
search parameters to query-replace such as requested in bug#22479,
so with text properties this seems to be a better way, and adding
support to desktop for text properties is not unachievable:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: isearch-text-properties.patch --]
[-- Type: text/x-diff, Size: 6812 bytes --]

diff --git a/lisp/desktop.el b/lisp/desktop.el
index 8bd4465..a7e549f 100644
--- a/lisp/desktop.el
+++ b/lisp/desktop.el
@@ -852,10 +852,7 @@ desktop--v2s
     ((or (numberp value) (null value) (eq t value) (keywordp value))
      (cons 'may value))
     ((stringp value)
-     (let ((copy (copy-sequence value)))
-       (set-text-properties 0 (length copy) nil copy)
-       ;; Get rid of text properties because we cannot read them.
-       (cons 'may copy)))
+     (cons 'may value))
     ((symbolp value)
      (cons 'must value))
     ((vectorp value)
diff --git a/lisp/isearch.el b/lisp/isearch.el
index 4f5f494..0699868 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -1119,7 +1119,9 @@ isearch-done
 
   (if (and (> (length isearch-string) 0) (not nopush))
       ;; Update the ring data.
-      (isearch-update-ring isearch-string isearch-regexp))
+      (isearch-update-ring isearch-string isearch-regexp
+                           `(regexp-function ,isearch-regexp-function
+                             case-fold-search ,isearch-case-fold-search)))
 
   (let ((isearch-mode-end-hook-quit (and nopush (not edit))))
     (run-hooks 'isearch-mode-end-hook))
@@ -1135,12 +1137,12 @@ isearch-done
 
   (and (not edit) isearch-recursive-edit (exit-recursive-edit)))
 
-(defun isearch-update-ring (string &optional regexp)
+(defun isearch-update-ring (string &optional regexp properties)
   "Add STRING to the beginning of the search ring.
 REGEXP if non-nil says use the regexp search ring."
   (add-to-history
    (if regexp 'regexp-search-ring 'search-ring)
-   string
+   (if properties (apply 'propertize string properties) string)
    (if regexp regexp-search-ring-max search-ring-max)))
 
 ;; Switching buffers should first terminate isearch-mode.
@@ -1850,7 +1852,11 @@ isearch-query-replace
 	;; `exit-recursive-edit' in `isearch-done' that terminates
 	;; the execution of this command when it is non-nil.
 	;; We call `exit-recursive-edit' explicitly at the end below.
-	(isearch-recursive-edit nil))
+	(isearch-recursive-edit nil)
+        (isearch-string-propertized
+         (propertize isearch-string
+		     'isearch-regexp-function isearch-regexp-function
+		     'isearch-case-fold-search isearch-case-fold-search)))
     (isearch-done nil t)
     (isearch-clean-overlays)
     (if (and isearch-other-end
@@ -1863,12 +1869,12 @@ isearch-query-replace
 			 (< (mark) (point))))))
         (goto-char isearch-other-end))
     (set query-replace-from-history-variable
-         (cons isearch-string
+         (cons isearch-string-propertized
                (symbol-value query-replace-from-history-variable)))
     (perform-replace
-     isearch-string
+     isearch-string-propertized
      (query-replace-read-to
-      isearch-string
+      isearch-string-propertized
       (concat "Query replace"
               (isearch--describe-regexp-mode (or delimited isearch-regexp-function) t)
 	      (if backward " backward" "")
@@ -2572,7 +2578,13 @@ isearch-ring-adjust1
 		      length)))
       (setq isearch-string (nth yank-pointer ring)
 	    isearch-message (mapconcat 'isearch-text-char-description
-				       isearch-string "")))))
+				       isearch-string ""))
+      (when (memq 'regexp-function (text-properties-at 0 isearch-string))
+        (setq isearch-regexp-function
+              (get-text-property 0 'regexp-function isearch-string)))
+      (when (memq 'case-fold-search (text-properties-at 0 isearch-string))
+        (setq isearch-case-fold-search
+              (get-text-property 0 'case-fold-search isearch-string))))))
 
 (defun isearch-ring-adjust (advance)
   ;; Helper for isearch-ring-advance and isearch-ring-retreat
@@ -2788,11 +2800,15 @@ isearch-search-fun
 
 (defun isearch--lax-regexp-function-p ()
   "Non-nil if next regexp-function call should be lax."
+  ;; FIXME: maybe simpler to use this:
+  ;; (or (memq this-command '(isearch-printing-char isearch-del-char)) isearch-yank-flag)
   (not (or isearch-nonincremental
            (null (car isearch-cmds))
            (eq (length isearch-string)
                (length (isearch--state-string
-                        (car isearch-cmds)))))))
+                        (car isearch-cmds))))
+           ;; Search string comes from the history with text properties
+           (memq 'regexp-function (text-properties-at 0 isearch-string)))))
 
 (defun isearch-search-fun-default ()
   "Return default functions to use for the search."
diff --git a/lisp/replace.el b/lisp/replace.el
index c28c9b3..ac37bd7 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -301,7 +301,9 @@ query-replace-read-args
 	 (to (if (consp from) (prog1 (cdr from) (setq from (car from)))
 	       (query-replace-read-to from prompt regexp-flag))))
     (list from to
-	  (and current-prefix-arg (not (eq current-prefix-arg '-)))
+	  (or (and current-prefix-arg (not (eq current-prefix-arg '-)))
+              (and (memq 'isearch-regexp-function (text-properties-at 0 from))
+                   (get-text-property 0 'isearch-regexp-function from)))
 	  (and current-prefix-arg (eq current-prefix-arg '-)))))
 
 (defun query-replace (from-string to-string &optional delimited start end backward region-noncontiguous-p)
@@ -2361,8 +2363,17 @@ perform-replace
          (message
           (if query-flag
               (apply 'propertize
-                     (substitute-command-keys
-                      "Query replacing %s with %s: (\\<query-replace-map>\\[help] for help) ")
+                     (concat "Query replacing "
+                             (if backward "backward " "")
+                             (if delimited-flag
+                                 (or (and (symbolp delimited-flag)
+                                          (get delimited-flag
+                                               'isearch-message-prefix))
+                                     "word ") "")
+                             (if regexp-flag "regexp " "")
+                             "%s with %s: "
+                             (substitute-command-keys
+                              "(\\<query-replace-map>\\[help] for help) "))
                      minibuffer-prompt-properties))))
 
     ;; Unless a single contiguous chunk is selected, operate on multiple chunks.
@@ -2580,13 +2591,13 @@ perform-replace
 			 (with-output-to-temp-buffer "*Help*"
 			   (princ
 			    (concat "Query replacing "
+				    (if backward "backward " "")
 				    (if delimited-flag
 					(or (and (symbolp delimited-flag)
 						 (get delimited-flag
                                                       'isearch-message-prefix))
 					    "word ") "")
 				    (if regexp-flag "regexp " "")
-				    (if backward "backward " "")
 				    from-string " with "
 				    next-replacement ".\n\n"
 				    (substitute-command-keys

  parent reply	other threads:[~2018-03-08 22:55 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-22 19:10 Let's make C-M-w in isearch yank symbol, not delete character Daniel Colascione
2018-02-23  0:44 ` John Wiegley
2018-02-25 20:55 ` Juri Linkov
2018-02-25 21:12   ` H. Dieter Wilhelm
2018-02-25 21:43   ` Daniel Colascione
2018-03-01 22:39     ` Isearch interaction model (was: Let's make C-M-w in isearch yank symbol, not delete character) Juri Linkov
2018-03-02  0:12       ` Isearch interaction model Daniel Colascione
2018-03-02  0:19         ` Davis Herring
2018-03-02  0:26           ` dancol
2018-03-03 22:50             ` Juri Linkov
2018-03-03 23:46               ` Clément Pit-Claudel
2018-03-04 21:42                 ` Juri Linkov
2018-03-08 22:55                 ` Juri Linkov [this message]
2018-03-04 15:39               ` Eli Zaretskii
2018-03-04 17:13                 ` Daniel Colascione
2018-03-04 17:26                   ` Clément Pit-Claudel
2018-03-04 21:58                     ` Juri Linkov
2018-03-04 22:03                     ` Daniel Colascione
2018-03-05  3:33                       ` Eli Zaretskii
2018-03-05 21:33                       ` Juri Linkov
2018-03-04 21:50                   ` Juri Linkov
2018-03-06 21:47           ` Juri Linkov
2018-03-06 22:22             ` dancol
2018-03-07 22:30               ` Juri Linkov
2018-03-07 22:55                 ` dancol
2018-03-08 22:41                   ` Juri Linkov
2018-03-09 11:01                     ` Daniel Colascione
2018-03-10 21:20                       ` Juri Linkov
2018-03-10 21:36                         ` Daniel Colascione
2018-03-11 21:58                           ` Juri Linkov
2018-03-12  3:29                             ` Eli Zaretskii
2018-03-12  8:23                             ` Daniel Colascione
2018-03-12  9:29                               ` Yuri Khan
2018-03-02 16:01       ` Isearch interaction model (was: Let's make C-M-w in isearch yank symbol, not delete character) Richard Stallman
2018-02-26  3:26   ` Let's make C-M-w in isearch yank symbol, not delete character Eli Zaretskii
2018-02-27 21:28     ` Juri Linkov
2018-02-28  3:40       ` Eli Zaretskii
2018-03-01 22:32         ` Juri Linkov
2018-03-02  8:17           ` Eli Zaretskii
2018-03-03 22:34             ` Juri Linkov
2018-03-04 15:47               ` Eli Zaretskii
2018-03-04 21:36                 ` Juri Linkov
2018-03-05  3:31                   ` Eli Zaretskii
2018-03-05 15:59                     ` Eli Zaretskii
2018-03-05 21:25                       ` Juri Linkov
2018-03-06  3:28                         ` Eli Zaretskii
2018-03-06 22:07                           ` Juri Linkov
2018-03-10 11:59                             ` Eli Zaretskii
2018-03-10 18:34                             ` John Shahid
2018-03-10 21:15                               ` Juri Linkov
2018-03-11  2:37                                 ` Stefan Monnier
2018-03-11 21:52                                   ` Juri Linkov
2018-03-12 17:38                                     ` John Shahid
2018-03-12 18:24                                     ` Alan Mackenzie
2018-03-12 21:19                                       ` Juri Linkov
2018-03-12 21:36                                         ` Juri Linkov
2018-03-11  3:38                                 ` Eli Zaretskii
2018-03-11 14:32                                 ` Herring, Davis

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

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

  git send-email \
    --in-reply-to=87y3j29nze.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=cpitclaudel@gmail.com \
    --cc=emacs-devel@gnu.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.