Browse Source

Support searching in backward headlines with isearch.

Carsten Dominik 16 years ago
parent
commit
1e79189212
2 changed files with 12 additions and 4 deletions
  1. 6 0
      lisp/ChangeLog
  2. 6 4
      lisp/org.el

+ 6 - 0
lisp/ChangeLog

@@ -1,3 +1,9 @@
+2008-09-03  Carsten Dominik  <dominik@science.uva.nl>
+
+	* org.el (org-goto-local-search-headings): Renamed from
+	`org-goto-local-search-forward-headings'.  Added the possibility
+	to search backwards.
+
 2008-09-02  Carsten Dominik  <dominik@science.uva.nl>
 
 	* org-export-latex.el (org-export-latex): New customization

+ 6 - 4
lisp/org.el

@@ -4351,7 +4351,7 @@ or nil."
   (let ((isearch-mode-map org-goto-local-auto-isearch-map)
 	(isearch-hide-immediately nil)
 	(isearch-search-fun-function
-	 (lambda () 'org-goto-local-search-forward-headings))
+	 (lambda () 'org-goto-local-search-headings))
 	(org-goto-selected-point org-goto-exit-command))
     (save-excursion
       (save-window-excursion
@@ -4392,10 +4392,12 @@ or nil."
 (define-key org-goto-local-auto-isearch-map "\C-i" 'isearch-other-control-char)
 (define-key org-goto-local-auto-isearch-map "\C-m" 'isearch-other-control-char)
 
-(defun org-goto-local-search-forward-headings (string bound noerror)
-  "Search and make sure that anu matches are in headlines."
+(defun org-goto-local-search-headings (string bound noerror)
+  "Search and make sure that any matches are in headlines."
   (catch 'return
-    (while (search-forward string bound noerror)
+    (while (if isearch-forward
+               (search-forward string bound noerror)
+             (search-backward string bound noerror))
       (when (let ((context (mapcar 'car (save-match-data (org-context)))))
 	      (and (member :headline context)
 		   (not (member :tags context))))