From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lee Hinman Subject: possible bug in org-goto-local-search-headings Date: Thu, 12 Nov 2009 13:04:02 -0600 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N8ez2-0005m7-BW for emacs-orgmode@gnu.org; Thu, 12 Nov 2009 14:05:28 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N8eyx-0005ld-AQ for emacs-orgmode@gnu.org; Thu, 12 Nov 2009 14:05:28 -0500 Received: from [199.232.76.173] (port=51802 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N8eyx-0005la-5l for emacs-orgmode@gnu.org; Thu, 12 Nov 2009 14:05:23 -0500 Received: from mail-bw0-f215.google.com ([209.85.218.215]:41277) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N8eyw-0007Ad-Ns for emacs-orgmode@gnu.org; Thu, 12 Nov 2009 14:05:22 -0500 Received: by bwz7 with SMTP id 7so2607466bwz.26 for ; Thu, 12 Nov 2009 11:05:21 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org I noticed some interesting behavior with the org-goto-local-search-headings function in Emacs 23.1.1. If you call the function before doing an incremental search, searching forward fails. If you call it after doing an incremental search the function will search forward. A quick look at the code showed that it only does a forward search if isearch-forward is defined. This is both a variable and a function in isearch.el, and the variable isearch-forward is set to nil until you do a search. The following patch against the current orgmode removes the dependency on isearch-forward and will now search forward first, if it doesn't find anything will search backward from the original point. I *think* this is the behavior that was intended. diff --git a/lisp/org.el b/lisp/org.el index dd34816..1e9aad3 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -5801,8 +5801,7 @@ or nil." (defun org-goto-local-search-headings (string bound noerror) "Search and make sure that any matches are in headlines." (catch 'return - (while (if isearch-forward - (search-forward string bound noerror) + (while (or (search-forward string bound t) (search-backward string bound noerror)) (when (let ((context (mapcar 'car (save-match-data (org-context))))) (and (member :headline context) -- Lee Hinman