[Top][All Lists]

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

bug#14742: 24.3.50; enhancement request: be able to prepend stuff from b

From: Juri Linkov
Subject: bug#14742: 24.3.50; enhancement request: be able to prepend stuff from buffer when search backward
Date: Sun, 30 Jun 2013 00:50:36 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu)

>> and since then I have not had problems with it.  So what could
>> be done is to move this code from `isearch-other-meta-char'
>> to `isearch-yank-string' and `isearch-del-char' for more
>> general functionality by adding a new argument `BACK' to them
>> (or could you propose a better name for the argument).
> I take your word for it wrt the implementation.  After I see it,
> I might have a suggestion wrt the name (maybe BACKWARD, as that
> seems to be the term used in our search names).

It's easy to find a name for the new arg of `isearch-yank-string'.
By default, it appends a string to the end of the search string,
so a new arg for opposite meaning could have the name `prepend'
to prepend a string to the beginning of the search string.

But what could be a name for the new arg of `isearch-del-char'?
By default, it deletes a substring from the end of the search string.
And with a non-nil new arg it will delete a substring from the
beginning of the search string.  What about the name `behead'
suggested in

=== modified file 'lisp/isearch.el'
--- lisp/isearch.el     2013-06-13 22:08:45 +0000
+++ lisp/isearch.el     2013-06-29 21:50:03 +0000
@@ -1839,7 +1839,7 @@ (defun isearch-delete-char ()
-(defun isearch-del-char (&optional arg)
+(defun isearch-del-char (&optional arg behead)
   "Delete character from end of search string and search again.
 Unlike `isearch-delete-char', it only deletes the last character,
 but doesn't cancel the effect of other isearch command.
@@ -1847,9 +1847,13 @@ (defun isearch-del-char (&optional arg)
   (interactive "p")
   (if (= 0 (length isearch-string))
-    (setq isearch-string (substring isearch-string 0
-                                   (- (min (or arg 1)
-                                           (length isearch-string))))
+    (setq isearch-string (if behead
+                            (substring isearch-string
+                                       (min (or arg 1)
+                                            (length isearch-string)))
+                          (substring isearch-string 0
+                                     (- (min (or arg 1)
+                                             (length isearch-string)))))
           isearch-message (mapconcat 'isearch-text-char-description
                                      isearch-string "")))
   ;; Use the isearch-other-end as new starting point to be able
@@ -1858,17 +1862,23 @@ (defun isearch-del-char (&optional arg)
-(defun isearch-yank-string (string)
+(defun isearch-yank-string (string &optional prepend)
   "Pull STRING into search string."
   ;; Downcase the string if not supposed to case-fold yanked strings.
   (if (and isearch-case-fold-search
           (eq 'not-yanks search-upper-case))
       (setq string (downcase string)))
   (if isearch-regexp (setq string (regexp-quote string)))
-  (setq isearch-string (concat isearch-string string)
+  (setq isearch-string (if prepend
+                          (concat string isearch-string)
+                        (concat isearch-string string))
        (concat isearch-message
                (mapconcat 'isearch-text-char-description

reply via email to

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