]> git.eshelyaron.com Git - emacs.git/commitdiff
"C-s M-p" brings the tip of the search ring.
authorJuri Linkov <juri@jurta.org>
Wed, 24 Aug 2011 09:40:58 +0000 (12:40 +0300)
committerJuri Linkov <juri@jurta.org>
Wed, 24 Aug 2011 09:40:58 +0000 (12:40 +0300)
* lisp/isearch.el (isearch-ring-adjust1): Start visiting previous
search strings from the index 0 (-1 + 1) instead of 1 (0 + 1).
(isearch-repeat, isearch-edit-string): Call `isearch-ring-adjust1'
for empty search string (when the last search string is reused
automatically) to adjust the isearch ring to the last element and
prepare the correct index for further M-p commands.

Fixes: debbugs:9185
lisp/ChangeLog
lisp/isearch.el

index 2a33661c9c5cf40a61e8bc8284eb321b2a0f1a03..6716a879a766ca7a00f5b93a934e2508d0676120 100644 (file)
@@ -1,3 +1,12 @@
+2011-08-24  Juri Linkov  <juri@jurta.org>
+
+       * isearch.el (isearch-ring-adjust1): Start visiting previous
+       search strings from the index 0 (-1 + 1) instead of 1 (0 + 1).
+       (isearch-repeat, isearch-edit-string): Call `isearch-ring-adjust1'
+       for empty search string (when the last search string is reused
+       automatically) to adjust the isearch ring to the last element and
+       prepare the correct index for further M-p commands (bug#9185).
+
 2011-08-24  Kenichi Handa  <handa@m17n.org>
 
        * international/ucs-normalize.el: If decomposition property of
index 1942641fae93040e99cba9ac74e7ec2372c4326f..7fcc31f188f844815bc1e8dca23e670990e1ce3f 100644 (file)
@@ -1191,19 +1191,17 @@ If first char entered is \\[isearch-yank-word-or-char], then do word search inst
                  isearch-word isearch-new-word))
 
          ;; Empty isearch-string means use default.
-         (if (= 0 (length isearch-string))
-             (setq isearch-string (or (car (if isearch-regexp
-                                               regexp-search-ring
-                                             search-ring))
-                                      "")
-
-                   isearch-message
-                   (mapconcat 'isearch-text-char-description
-                              isearch-string ""))
-           ;; This used to set the last search string,
-           ;; but I think it is not right to do that here.
-           ;; Only the string actually used should be saved.
-           ))
+         (when (= 0 (length isearch-string))
+           (setq isearch-string (or (car (if isearch-regexp
+                                             regexp-search-ring
+                                           search-ring))
+                                    "")
+
+                 isearch-message
+                 (mapconcat 'isearch-text-char-description
+                            isearch-string ""))
+           ;; After taking the last element, adjust ring to previous one.
+           (isearch-ring-adjust1 nil)))
 
        ;; This used to push the state as of before this C-s, but it adds
        ;; an inconsistent state where part of variables are from the
@@ -1290,7 +1288,9 @@ Use `isearch-exit' to quit without signaling."
                  isearch-message
                  (mapconcat 'isearch-text-char-description
                             isearch-string "")
-                 isearch-case-fold-search isearch-last-case-fold-search))
+                 isearch-case-fold-search isearch-last-case-fold-search)
+           ;; After taking the last element, adjust ring to previous one.
+           (isearch-ring-adjust1 nil))
        ;; If already have what to search for, repeat it.
        (or isearch-success
            (progn
@@ -2071,7 +2071,7 @@ Isearch mode."
        ()
       (set yank-pointer-name
           (setq yank-pointer
-                (mod (+ (or yank-pointer 0)
+                (mod (+ (or yank-pointer (if advance 0 -1))
                         (if advance -1 1))
                      length)))
       (setq isearch-string (nth yank-pointer ring)