emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* possible bug in org-goto-local-search-headings
@ 2009-11-12 19:04 Lee Hinman
  2009-11-12 23:51 ` Carsten Dominik
  0 siblings, 1 reply; 4+ messages in thread
From: Lee Hinman @ 2009-11-12 19:04 UTC (permalink / raw)
  To: emacs-orgmode

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: possible bug in org-goto-local-search-headings
  2009-11-12 19:04 possible bug in org-goto-local-search-headings Lee Hinman
@ 2009-11-12 23:51 ` Carsten Dominik
  2009-11-13  0:24   ` Lee Hinman
  0 siblings, 1 reply; 4+ messages in thread
From: Carsten Dominik @ 2009-11-12 23:51 UTC (permalink / raw)
  To: Lee Hinman; +Cc: emacs-orgmode

Hi Lee,

I do not understand.

Why would you call this function?  It is being called by the
internals of isearch, and when that happens, isearch.el is obviously  
loaded.

What am I missing here?

- Carsten

On Nov 12, 2009, at 8:04 PM, Lee Hinman wrote:

> 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
>
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

- Carsten

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: possible bug in org-goto-local-search-headings
  2009-11-12 23:51 ` Carsten Dominik
@ 2009-11-13  0:24   ` Lee Hinman
  2009-11-13 22:30     ` Carsten Dominik
  0 siblings, 1 reply; 4+ messages in thread
From: Lee Hinman @ 2009-11-13  0:24 UTC (permalink / raw)
  To: emacs-orgmode

Carsten,

I admit I could be using the function inappropriately.  Please let me
know if am.

I have a little function I wrote to help me maintain a journal, I didn't
like the formatting I got using remember.  Here is the function.

(defun lee-journal-entry ()
  "Create a new journal entry for today or append to existing month."
  (interactive)
  (switch-to-buffer (find-file lee-journal-file))
  (widen)
  (let ((today (format-time-string "%Y.%m")))
    (unless (org-goto-local-search-headings today nil t)
      ((lambda ()
	 (beginning-of-buffer)
	 (org-insert-heading)
	 (insert today))))
    (show-children)
    (end-of-line)
    (insert "\n")
    (org-insert-heading)
    (org-do-demote)
    (org-insert-time-stamp (current-time))
    (insert " ")))

So I'm using org-goto-local-search-heading to find the correct heading
to start my new journal entry in.

--
Lee



Carsten Dominik <carsten.dominik@gmail.com> writes:

> Hi Lee,
>
> I do not understand.
>
> Why would you call this function?  It is being called by the
> internals of isearch, and when that happens, isearch.el is obviously
> loaded.
>
> What am I missing here?
>
> - Carsten
>
> On Nov 12, 2009, at 8:04 PM, Lee Hinman wrote:
>
>> 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
>>
>>
>>
>> _______________________________________________
>> Emacs-orgmode mailing list
>> Remember: use `Reply All' to send replies to the list.
>> Emacs-orgmode@gnu.org
>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>
> - Carsten
>
>
>

-- 
Lee Hinman
hinman@gmail.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: possible bug in org-goto-local-search-headings
  2009-11-13  0:24   ` Lee Hinman
@ 2009-11-13 22:30     ` Carsten Dominik
  0 siblings, 0 replies; 4+ messages in thread
From: Carsten Dominik @ 2009-11-13 22:30 UTC (permalink / raw)
  To: Lee Hinman; +Cc: emacs-orgmode


On Nov 13, 2009, at 1:24 AM, Lee Hinman wrote:

> Carsten,
>
> I admit I could be using the function inappropriately.  Please let me
> know if am.
>
> I have a little function I wrote to help me maintain a journal, I  
> didn't
> like the formatting I got using remember.  Here is the function.
>
> (defun lee-journal-entry ()
>  "Create a new journal entry for today or append to existing month."
>  (interactive)
>  (switch-to-buffer (find-file lee-journal-file))
>  (widen)
>  (let ((today (format-time-string "%Y.%m")))
>    (unless (org-goto-local-search-headings today nil t)
>      ((lambda ()
> 	 (beginning-of-buffer)
> 	 (org-insert-heading)
> 	 (insert today))))
>    (show-children)
>    (end-of-line)
>    (insert "\n")
>    (org-insert-heading)
>    (org-do-demote)
>    (org-insert-time-stamp (current-time))
>    (insert " ")))
>
> So I'm using org-goto-local-search-heading to find the correct heading
> to start my new journal entry in.

Hi Lee,

it is OK to call such a function, but then you need to provide the  
correct
environment.  In this case, it is probably enough to add

   (isearch-forward t)

to the let bindings in the function.

- Carsten

>
> --
> Lee
>
>
>
> Carsten Dominik <carsten.dominik@gmail.com> writes:
>
>> Hi Lee,
>>
>> I do not understand.
>>
>> Why would you call this function?  It is being called by the
>> internals of isearch, and when that happens, isearch.el is obviously
>> loaded.
>>
>> What am I missing here?
>>
>> - Carsten
>>
>> On Nov 12, 2009, at 8:04 PM, Lee Hinman wrote:
>>
>>> 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
>>>
>>>
>>>
>>> _______________________________________________
>>> Emacs-orgmode mailing list
>>> Remember: use `Reply All' to send replies to the list.
>>> Emacs-orgmode@gnu.org
>>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>>
>> - Carsten
>>
>>
>>
>
> -- 
> Lee Hinman
> hinman@gmail.com
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

- Carsten

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-11-13 22:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-12 19:04 possible bug in org-goto-local-search-headings Lee Hinman
2009-11-12 23:51 ` Carsten Dominik
2009-11-13  0:24   ` Lee Hinman
2009-11-13 22:30     ` Carsten Dominik

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.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).