summaryrefslogtreecommitdiff
path: root/lisp/isearch.el
diff options
context:
space:
mode:
authorJuri Linkov <juri@jurta.org>2011-08-24 12:40:58 +0300
committerJuri Linkov <juri@jurta.org>2011-08-24 12:40:58 +0300
commit11dcdbb283eb9efddf73939d3c3d12404731833f (patch)
tree1a3b0f7e6ebed11057f00ed563247810f546e52a /lisp/isearch.el
parentf67cdd7f258347b3fe21fa3c8bfc335decad02d6 (diff)
downloademacs-11dcdbb283eb9efddf73939d3c3d12404731833f.tar.gz
"C-s M-p" brings the tip of the search ring.
* 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
Diffstat (limited to 'lisp/isearch.el')
-rw-r--r--lisp/isearch.el30
1 files changed, 15 insertions, 15 deletions
diff --git a/lisp/isearch.el b/lisp/isearch.el
index 1942641fae9..7fcc31f188f 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -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)