emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Bug: Infinite loop when org-entry-put is called in buffer not in org-mode [6.33trans]
@ 2009-11-25  8:05 David Maus
  2009-11-26  7:42 ` Carsten Dominik
  0 siblings, 1 reply; 4+ messages in thread
From: David Maus @ 2009-11-25  8:05 UTC (permalink / raw)
  To: emacs-orgmode


Remember to cover the basics, that is, what you expected to happen and
what in fact did happen.  You don't know how to make a good report?  See

     http://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org-mode mailing list.
------------------------------------------------------------------------

When `org-entry-put' is called in a buffer that is not in org-mode
Emacs enters an infinite loop.

Use this simple function

,----
|    (defun dmj/debug ()
|      "Call me within a buffer not in org-mode and I will hang."
|      (interactive)
|      (org-entry-put (point) "Prop" "Val"))
`----

Create a new buffer in fundamental mode and enter a headline manually:

*test*
,----
| * Headline
`----
   
Now call dmj/debug interactivly (M-x dmj/debug <RET>) and Emacs hangs.

Regards,

  -- David

Emacs  : GNU Emacs 23.1.50.1 (i486-pc-linux-gnu, GTK+ Version 2.18.3)
 of 2009-11-15 on elegiac, modified by Debian
Package: Org-mode version 6.33trans

current state:
==============
(setq
 org-export-latex-default-class "scrartcl"
 org-clock-in-switch-to-state "STARTED"
 org-todo-keyword-faces '(("TODO" :foreground "red" :weight bold) ("STARTED" :foreground "orange red" :weight bold)
			  ("DONE" :foreground "light green") ("MAYBE" :foreground "tomato")
			  ("WAITING" :foreground "tan2" :weight bold) ("CANCELLED" :foreground "firebrick"))
 org-expiry-insert-created-only-if-todo t
 org-agenda-custom-commands '(("r" "Refile New Notes and Tasks" tags "LEVEL=1+REFILE"
			       ((org-agenda-todo-ignore-with-date nil)))
			      ("s" "Started Tasks" todo "STARTED"
			       ((org-agenda-todo-ignore-scheduled nil) (org-agenda-todo-ignore-deadlines nil)
				(org-agenda-todo-ignore-with-date nil))
			       )
			      )
 org-agenda-files '("/home/david/Org/XXX")
 org-blocker-hook '(org-block-todo-from-children-or-siblings-or-parent)
 org-agenda-tags-column -120
 org-checklist-export-function 'org-export-as-ascii
 org-completion-use-ido t
 org-expiry-created-property-name "Created"
 org-after-todo-state-change-hook '(org-clock-out-if-current org-expiry-insert-created org-checklist)
 org-expiry-expiry-timestamp-active nil
 org-agenda-todo-ignore-scheduled t
 org-todo-state-tags-triggers '((todo ("NOTE")) ("" ("NOTE" . t)))
 org-log-redeadline 'time
 org-expiry-created-timestamp-active nil
 org-export-preprocess-hook '(org-export-blocks-preprocess)
 org-tags-exclude-from-inheritance '("NOTE" "ATTACH" "APPT")
 org-tab-first-hook '(org-hide-block-toggle-maybe)
 org-src-mode-hook '(org-src-mode-configure-edit-buffer)
 org-confirm-shell-link-function 'yes-or-no-p
 org-todo-keywords '((sequence "TODO(t)" "STARTED(s)" "|" "DONE(D@)")
		     (sequence "MAYBE(m)" "WAITING(w@/!)" "|" "CANCELLED(C@)"))
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-directory "~/Org"
 org-log-reschedule 'time
 org-insert-heading-hook '(org-expiry-insert-created)
 org-after-tags-change-hook '(org-expiry-insert-created)
 org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-hide-drawers org-cycle-show-empty-lines
		  org-optimize-window-after-visibility-change)
 org-publish-project-alist '(("private-dynamic" :base-directory "~/Org/www" :base-extension "org" :publishing-directory
			      "~/www/private" :publishing-function (org-publish-org-to-html) :recursive t :author
			      "David Maus" :email "maus.david@gmail.com")
			     ("private-static" :base-directory "~/Org/www" :base-extension "css" :publishing-directory
			      "~/www/private" :publishing-function org-publish-attachment :recursive t)
			     ("private" :components ("private-dynamic" "private-static")))
 org-mode-hook '(#[nil "\300\301\302\303\304$\207" [org-add-hook change-major-mode-hook org-show-block-all append local] 5])
 org-refile-targets '((org-agenda-files :maxlevel . 3))
 org-confirm-elisp-link-function 'yes-or-no-p
 org-refile-use-outline-path 'file
 org-expiry-wait "+3m"
 org-log-into-drawer "LOGBOOK"
 org-agenda-todo-ignore-with-date t
 org-enforce-todo-dependencies t
 org-insert-heading-respect-content t
 org-occur-hook '(org-first-headline-recenter)
 org-from-is-user-regexp "\\<David Maus\\>"
 org-tags-column -120
 org-remember-templates '(("todo" 116 "* TODO %^{Description} %^G\n  :PROPERTIES:\n  :Created: %U\n  :Ref: %a\n  :END:"
			   "refile.org" bottom nil)
			  ("appt" 97
			   "* %^{Description} :APPT:%^G\n  %^T\n  :PROPERTIES:\n  :Created: %U\n  :Ref: %a\n  :END:"
			   "refile.org" bottom nil)
			  ("note" 110 "* %^{Description} %^G:NOTE:\n  :PROPERTIES:\n  :Created: %U\n  :Ref:  %a\n  :END:"
			   "refile.org" bottom nil)
			  ("mail" 109
			   "* TODO %^{Action} %:fromaddress: %:subject %^G\n  :PROPERTIES:\n  :Created: %U\n  :Ref: [[wl:%5B%:message-id%5D~/.elmo/namazu#%:message-id][%:message-id]]\n  :END:\n"
			   "refile.org" bottom (wl-summary-mode))
			  ("link" 108
			   "* %c :LINK:%^G\n  :PROPERTIES:\n  :Created: %U\n  :Ref: %:link\n  :END:\n  %:initial%!"
			   "refile.org" bottom nil)
			  )
 org-expiry-expiry-property-name "Expiry"
 org-expiry-handler-function 'org-toggle-archive-tag
 )
-- 
OpenPGP... 0x316F4BE4670716FD
Jabber.... dmjena@jabber.org
Email..... maus.david@gmail.com
ICQ....... 241051416

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

* Re: Bug: Infinite loop when org-entry-put is called in buffer not in org-mode [6.33trans]
  2009-11-25  8:05 Bug: Infinite loop when org-entry-put is called in buffer not in org-mode [6.33trans] David Maus
@ 2009-11-26  7:42 ` Carsten Dominik
  2009-11-26 22:04   ` David Maus
  0 siblings, 1 reply; 4+ messages in thread
From: Carsten Dominik @ 2009-11-26  7:42 UTC (permalink / raw)
  To: David Maus; +Cc: emacs-orgmode


On Nov 25, 2009, at 9:05 AM, David Maus wrote:

>
> Remember to cover the basics, that is, what you expected to happen and
> what in fact did happen.  You don't know how to make a good report?   
> See
>
>     http://orgmode.org/manual/Feedback.html#Feedback
>
> Your bug report will be posted to the Org-mode mailing list.
> ------------------------------------------------------------------------
>
> When `org-entry-put' is called in a buffer that is not in org-mode
> Emacs enters an infinite loop.
>
> Use this simple function
>
> ,----
> |    (defun dmj/debug ()
> |      "Call me within a buffer not in org-mode and I will hang."
> |      (interactive)
> |      (org-entry-put (point) "Prop" "Val"))
> `----
>
> Create a new buffer in fundamental mode and enter a headline manually:
>
> *test*
> ,----
> | * Headline
> `----
>
> Now call dmj/debug interactivly (M-x dmj/debug <RET>) and Emacs hangs.

Hi David,

you cannot reasonably expect that org-mode functions should work
in other modes.  And you cannot expect these functions to check
the mode all the time.

I don't know what you are up to here.  But maybe the function
`org-run-as-in-org-mode' offers a way out?

- Carsten

>
> Regards,
>
>  -- David
>
> Emacs  : GNU Emacs 23.1.50.1 (i486-pc-linux-gnu, GTK+ Version 2.18.3)
> of 2009-11-15 on elegiac, modified by Debian
> Package: Org-mode version 6.33trans
>
> current state:
> ==============
> (setq
> org-export-latex-default-class "scrartcl"
> org-clock-in-switch-to-state "STARTED"
> org-todo-keyword-faces '(("TODO" :foreground "red" :weight bold)  
> ("STARTED" :foreground "orange red" :weight bold)
> 			  ("DONE" :foreground "light green") ("MAYBE" :foreground "tomato")
> 			  ("WAITING" :foreground "tan2" :weight bold)  
> ("CANCELLED" :foreground "firebrick"))
> org-expiry-insert-created-only-if-todo t
> org-agenda-custom-commands '(("r" "Refile New Notes and Tasks" tags  
> "LEVEL=1+REFILE"
> 			       ((org-agenda-todo-ignore-with-date nil)))
> 			      ("s" "Started Tasks" todo "STARTED"
> 			       ((org-agenda-todo-ignore-scheduled nil) (org-agenda-todo- 
> ignore-deadlines nil)
> 				(org-agenda-todo-ignore-with-date nil))
> 			       )
> 			      )
> org-agenda-files '("/home/david/Org/XXX")
> org-blocker-hook '(org-block-todo-from-children-or-siblings-or-parent)
> org-agenda-tags-column -120
> org-checklist-export-function 'org-export-as-ascii
> org-completion-use-ido t
> org-expiry-created-property-name "Created"
> org-after-todo-state-change-hook '(org-clock-out-if-current org- 
> expiry-insert-created org-checklist)
> org-expiry-expiry-timestamp-active nil
> org-agenda-todo-ignore-scheduled t
> org-todo-state-tags-triggers '((todo ("NOTE")) ("" ("NOTE" . t)))
> org-log-redeadline 'time
> org-expiry-created-timestamp-active nil
> org-export-preprocess-hook '(org-export-blocks-preprocess)
> org-tags-exclude-from-inheritance '("NOTE" "ATTACH" "APPT")
> org-tab-first-hook '(org-hide-block-toggle-maybe)
> org-src-mode-hook '(org-src-mode-configure-edit-buffer)
> org-confirm-shell-link-function 'yes-or-no-p
> org-todo-keywords '((sequence "TODO(t)" "STARTED(s)" "|" "DONE(D@)")
> 		     (sequence "MAYBE(m)" "WAITING(w@/!)" "|" "CANCELLED(C@)"))
> org-agenda-before-write-hook '(org-agenda-add-entry-text)
> org-directory "~/Org"
> org-log-reschedule 'time
> org-insert-heading-hook '(org-expiry-insert-created)
> org-after-tags-change-hook '(org-expiry-insert-created)
> org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-hide- 
> drawers org-cycle-show-empty-lines
> 		  org-optimize-window-after-visibility-change)
> org-publish-project-alist '(("private-dynamic" :base-directory "~/ 
> Org/www" :base-extension "org" :publishing-directory
> 			      "~/www/private" :publishing-function (org-publish-org-to- 
> html) :recursive t :author
> 			      "David Maus" :email "maus.david@gmail.com")
> 			     ("private-static" :base-directory "~/Org/www" :base- 
> extension "css" :publishing-directory
> 			      "~/www/private" :publishing-function org-publish- 
> attachment :recursive t)
> 			     ("private" :components ("private-dynamic" "private-static")))
> org-mode-hook '(#[nil "\300\301\302\303\304$\207" [org-add-hook  
> change-major-mode-hook org-show-block-all append local] 5])
> org-refile-targets '((org-agenda-files :maxlevel . 3))
> org-confirm-elisp-link-function 'yes-or-no-p
> org-refile-use-outline-path 'file
> org-expiry-wait "+3m"
> org-log-into-drawer "LOGBOOK"
> org-agenda-todo-ignore-with-date t
> org-enforce-todo-dependencies t
> org-insert-heading-respect-content t
> org-occur-hook '(org-first-headline-recenter)
> org-from-is-user-regexp "\\<David Maus\\>"
> org-tags-column -120
> org-remember-templates '(("todo" 116 "* TODO %^{Description} %^G 
> \n  :PROPERTIES:\n  :Created: %U\n  :Ref: %a\n  :END:"
> 			   "refile.org" bottom nil)
> 			  ("appt" 97
> 			   "* %^{Description} :APPT:%^G\n  %^T\n  :PROPERTIES: 
> \n  :Created: %U\n  :Ref: %a\n  :END:"
> 			   "refile.org" bottom nil)
> 			  ("note" 110 "* %^{Description} %^G:NOTE:\n  :PROPERTIES: 
> \n  :Created: %U\n  :Ref:  %a\n  :END:"
> 			   "refile.org" bottom nil)
> 			  ("mail" 109
> 			   "* TODO %^{Action} %:fromaddress: %:subject %^G\n  :PROPERTIES: 
> \n  :Created: %U\n  :Ref: [[wl:%5B%:message-id%5D~/.elmo/namazu# 
> %:message-id][%:message-id]]\n  :END:\n"
> 			   "refile.org" bottom (wl-summary-mode))
> 			  ("link" 108
> 			   "* %c :LINK:%^G\n  :PROPERTIES:\n  :Created: %U\n  :Ref: %:link 
> \n  :END:\n  %:initial%!"
> 			   "refile.org" bottom nil)
> 			  )
> org-expiry-expiry-property-name "Expiry"
> org-expiry-handler-function 'org-toggle-archive-tag
> )
> -- 
> OpenPGP... 0x316F4BE4670716FD
> Jabber.... dmjena@jabber.org
> Email..... maus.david@gmail.com
> ICQ....... 241051416
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please 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: Bug: Infinite loop when org-entry-put is called in buffer not in org-mode [6.33trans]
  2009-11-26  7:42 ` Carsten Dominik
@ 2009-11-26 22:04   ` David Maus
  2009-11-27  7:31     ` Carsten Dominik
  0 siblings, 1 reply; 4+ messages in thread
From: David Maus @ 2009-11-26 22:04 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode

Hi Carsten,

At Thu, 26 Nov 2009 08:42:09 +0100,
Carsten Dominik wrote:
> Hi David,
> 
> you cannot reasonably expect that org-mode functions should work
> in other modes.  And you cannot expect these functions to check
> the mode all the time.
> 
> I don't know what you are up to here.  But maybe the function
> `org-run-as-in-org-mode' offers a way out?

I stumpled on this infinite loop by accident and simply avoid it by
make my function refuse to work on a buffer not in org-mode.

However, I decided it worth a bugreport as I didn't know the reason
for this and assumed org-mode may enter this loop by itself if the
right conditions are met.

After debugging the loop it turns out that the loop occurs in
`org-insert-property-drawer' because `org-keyword-time-regexp' is
buffer local only (calculated when entering org-mode) and defaults to
nil, so when `org-insert-property-drawer' tries to skip SCHEDULED,
DEADLINE etc. lines it tries this by while-re-search-forwarding[1]
with the regexp "^[ \t]*" -- that is what throws Emacs in this loop
(for whatever reason -- I hope I am going to find out).

So the question is: Is it in anyway possible that
`org-keyword-time-regexp' is (re-set to) nil in regular orgmode
operation? 

As far as I could see: No, so it should not effect the normal
operations of org-mode.

Regards,

  -- David

[1] i.e.: (while (re-search-forward "^[ \t]*")) causes Emacs to
loop. That means "not beeing in orgmode" not even a sine qua non for
this loop.

-- 
OpenPGP... 0x316F4BE4670716FD
Jabber.... dmjena@jabber.org
Email..... maus.david@gmail.com
ICQ....... 241051416

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

* Re: Bug: Infinite loop when org-entry-put is called in buffer not in org-mode [6.33trans]
  2009-11-26 22:04   ` David Maus
@ 2009-11-27  7:31     ` Carsten Dominik
  0 siblings, 0 replies; 4+ messages in thread
From: Carsten Dominik @ 2009-11-27  7:31 UTC (permalink / raw)
  To: David Maus; +Cc: emacs-orgmode


On Nov 26, 2009, at 11:04 PM, David Maus wrote:

> Hi Carsten,
>
> At Thu, 26 Nov 2009 08:42:09 +0100,
> Carsten Dominik wrote:
>> Hi David,
>>
>> you cannot reasonably expect that org-mode functions should work
>> in other modes.  And you cannot expect these functions to check
>> the mode all the time.
>>
>> I don't know what you are up to here.  But maybe the function
>> `org-run-as-in-org-mode' offers a way out?
>
> I stumpled on this infinite loop by accident and simply avoid it by
> make my function refuse to work on a buffer not in org-mode.

That is exactly the right course of action.

>
> However, I decided it worth a bugreport as I didn't know the reason
> for this and assumed org-mode may enter this loop by itself if the
> right conditions are met.

No, this variable (see below) is always set in Org buffers.

>
> After debugging the loop it turns out that the loop occurs in
> `org-insert-property-drawer' because `org-keyword-time-regexp' is
> buffer local only (calculated when entering org-mode) and defaults to
> nil, so when `org-insert-property-drawer' tries to skip SCHEDULED,
> DEADLINE etc. lines it tries this by while-re-search-forwarding[1]
> with the regexp "^[ \t]*" -- that is what throws Emacs in this loop
> (for whatever reason -- I hope I am going to find out).
>
> So the question is: Is it in anyway possible that
> `org-keyword-time-regexp' is (re-set to) nil in regular orgmode
> operation?

I could do that, but just the same I would have to do that for
many different other variables which only work inside org-mode.

- Carsten

>
> As far as I could see: No, so it should not effect the normal
> operations of org-mode.
>
> Regards,
>
>  -- David
>
> [1] i.e.: (while (re-search-forward "^[ \t]*")) causes Emacs to
> loop. That means "not beeing in orgmode" not even a sine qua non for
> this loop.
>
> -- 
> OpenPGP... 0x316F4BE4670716FD
> Jabber.... dmjena@jabber.org
> Email..... maus.david@gmail.com
> ICQ....... 241051416

- Carsten

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

end of thread, other threads:[~2009-11-27  8:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-25  8:05 Bug: Infinite loop when org-entry-put is called in buffer not in org-mode [6.33trans] David Maus
2009-11-26  7:42 ` Carsten Dominik
2009-11-26 22:04   ` David Maus
2009-11-27  7:31     ` 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).