unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: emacs-devel@gnu.org
Subject: Info-isearch-skip-history
Date: Fri, 07 May 2010 21:19:12 +0300	[thread overview]
Message-ID: <87ocgr90mm.fsf@mail.jurta.org> (raw)

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	other threads:[~2010-05-07 18:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-07 18:19 Juri Linkov [this message]
2010-05-08 15:59 ` Info-isearch-skip-history Stefan Monnier
2010-05-10 19:12   ` Info-isearch-skip-history Juri Linkov
2010-05-11  1:12     ` Info-isearch-skip-history Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ocgr90mm.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).