From 4bbedd9832178fcd264de9e6210d0dadbe3e2940 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Mon, 10 May 2010 22:07:22 +0300 Subject: [PATCH] Remove nodes visited during Isearch from the Info history. * info.el (Info-isearch-initial-history) (Info-isearch-initial-history-list): New variables. (Info-isearch-start): Record initial values of Info-isearch-initial-history and Info-isearch-initial-history-list. Add Info-isearch-end to isearch-mode-end-hook. (Info-isearch-end): New function. --- lisp/ChangeLog | 10 ++++++++++ lisp/info.el | 24 +++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 8bc5a26df8f..99a0a889d53 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,13 @@ +2010-05-10 Juri Linkov + + Remove nodes visited during Isearch from the Info history. + * info.el (Info-isearch-initial-history) + (Info-isearch-initial-history-list): New variables. + (Info-isearch-start): Record initial values of + Info-isearch-initial-history and Info-isearch-initial-history-list. + Add Info-isearch-end to isearch-mode-end-hook. + (Info-isearch-end): New function. + 2010-05-10 Michael Albinus * net/tramp.el (tramp-do-file-attributes-with-stat): Add space in diff --git a/lisp/info.el b/lisp/info.el index f526ff22a0e..e76a8da146e 100644 --- a/lisp/info.el +++ b/lisp/info.el @@ -266,6 +266,8 @@ with wrapping around the current Info node." :group 'info) (defvar Info-isearch-initial-node nil) +(defvar Info-isearch-initial-history nil) +(defvar Info-isearch-initial-history-list nil) (defcustom Info-mode-hook ;; Try to obey obsolete Info-fontify settings. @@ -1914,7 +1916,27 @@ If DIRECTION is `backward', search in the reverse direction." (setq Info-isearch-initial-node ;; Don't stop at initial node for nonincremental search. ;; Otherwise this variable is set after first search failure. - (and isearch-nonincremental Info-current-node))) + (and isearch-nonincremental Info-current-node)) + (setq Info-isearch-initial-history Info-history + Info-isearch-initial-history-list Info-history-list) + (add-hook 'isearch-mode-end-hook 'Info-isearch-end nil t)) + +(defun Info-isearch-end () + ;; Remove intermediate nodes (visited while searching) + ;; from the history. Add only the last node (where Isearch ended). + (if (> (length Info-history) + (length Info-isearch-initial-history)) + (setq Info-history + (nthcdr (- (length Info-history) + (length Info-isearch-initial-history) + 1) + Info-history))) + (if (> (length Info-history-list) + (length Info-isearch-initial-history-list)) + (setq Info-history-list + (cons (car Info-history-list) + Info-isearch-initial-history-list))) + (remove-hook 'isearch-mode-end-hook 'Info-isearch-end t)) (defun Info-isearch-filter (beg-found found) "Test whether the current search hit is a visible useful text. -- 2.11.4.GIT