emacs-devel
[Top][All Lists]
Advanced

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

Info-isearch-skip-history


From: Juri Linkov
Subject: Info-isearch-skip-history
Date: Fri, 07 May 2010 21:19:12 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (x86_64-pc-linux-gnu)

Isearch in Info encumbers the Info history with unnecessary nodes
visited while searching.  This new option allows to add only the
last node to the history:

=== modified file 'lisp/info.el'
--- lisp/info.el        2010-05-05 21:56:15 +0000
+++ lisp/info.el        2010-05-07 18:18:01 +0000
@@ -265,7 +265,18 @@ (defcustom Info-isearch-search t
   :type 'boolean
   :group 'info)
 
+(defcustom Info-isearch-skip-history nil
+  "If non-nil, Isearch in Info doesn't add intermediate nodes to the history.
+During Isearch Info visits nodes with matches.  All nodes visited while
+searching are recorded in the Info history.  However, when this variable is
+non-nil, only the last node (where Isearch ended) is added to the history."
+  :version "24.1"
+  :type 'boolean
+  :group 'info)
+
 (defvar Info-isearch-initial-node nil)
+(defvar Info-isearch-orig-history nil)
+(defvar Info-isearch-orig-history-list nil)
 
 (defcustom Info-mode-hook
   ;; Try to obey obsolete Info-fontify settings.
@@ -1914,7 +1925,27 @@ (defun Info-isearch-start ()
   (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))
+  (when Info-isearch-skip-history
+    (setq Info-isearch-orig-history      Info-history
+         Info-isearch-orig-history-list Info-history-list)
+    (add-hook 'isearch-mode-end-hook 'Info-isearch-end nil t)))
+
+(defun Info-isearch-end ()
+  (when Info-isearch-skip-history
+    (if (> (length Info-history)
+          (length Info-isearch-orig-history))
+       (setq Info-history
+             (nthcdr (- (length Info-history)
+                        (length Info-isearch-orig-history)
+                        1)
+                     Info-history)))
+    (if (> (length Info-history-list)
+          (length Info-isearch-orig-history-list))
+       (setq Info-history-list
+             (cons (car Info-history-list)
+                   Info-isearch-orig-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.

-- 
Juri Linkov
http://www.jurta.org/emacs/




reply via email to

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