Re: [Orgmode] Re: Showing hidden subtree automatically if point is hidden when the buffer is opened

2009-07-28 Thread Bastien
Bastien b...@gnu.org writes:

 User spamfilteracco...@gmail.com writes:

 I added the timer, because I didn't know in which order the hooks
 are run. If org-mode hook runs first and then saveplace's hook
 which restores point then the above code has no effect.

 saveplace adds the hook at the end of the hooks list, by calling
 add-hook like this:

   (add-hook 'find-file-hook 'save-place-find-file-hook t)
^

 The `t' means put this hook at the end.

 So your org-mode hook will be safely called *before* saveplace's.

Sorry, I mixed up the logic here -- the following hook is okay:

--8---cut here---start-8---
(add-hook 'org-mode-hook
  (lambda ()
(when (outline-invisible-p)
  (save-excursion
(outline-previous-visible-heading 1)
(org-show-subtree
  t)  ;; this makes sure this hook is run last
--8---cut here---end---8---

If you load this *after* loading the saveplace hook then it should 
be okay.  Thanks to Nick Dokos for shaking my brain on this :)

-- 
 Bastien


___
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


[Orgmode] Re: Showing hidden subtree automatically if point is hidden when the buffer is opened

2009-07-28 Thread User
Bastien bastienguerry at googlemail.com writes:
 
 If you load this *after* loading the saveplace hook then it should 
 be okay.  Thanks to Nick Dokos for shaking my brain on this :)
 

Well, wasn't my original solution with the null timer much nicer?
You didn't have to worry about making sure you put org-mode hook
last and that it loads after saveplace hook.

Now the user has to pay attention to where he sets
up the org-mode hook, instead of simply pasting the code
anywhere in .emacs. :-o I tend to favor solutions which avoid
such potential problems. :)




___
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


Nick Dokos: Re: [Orgmode] Re: Showing hidden subtree automatically if point is hidden when the buffer is opened

2009-07-28 Thread Nick Dokos
[forgot to copy the list - again...]

--- Forwarded Message

Date:Tue, 28 Jul 2009 14:54:38 -0400
From:Nick Dokos nicholas.do...@hp.com
To:  User spamfilteracco...@gmail.com
cc:  nicholas.do...@hp.com
Subject: Re: [Orgmode] Re: Showing hidden subtree automatically if point is hid
  den when the buffer is opened 

User spamfilteracco...@gmail.com wrote:

 Bastien bastienguerry at googlemail.com writes:
  
  If you load this *after* loading the saveplace hook then it should 
  be okay.  Thanks to Nick Dokos for shaking my brain on this :)
  
 
 Well, wasn't my original solution with the null timer much nicer?

No.

 You didn't have to worry about making sure you put org-mode hook
 last and that it loads after saveplace hook.

Yes, you can be a little lazy in setting it up and then pay the
performance price for ever after.

 
 Now the user has to pay attention to where he sets
 up the org-mode hook, instead of simply pasting the code
 anywhere in .emacs. :-o I tend to favor solutions which avoid
 such potential problems. :)
 

If they don't cost anything, yes. But I'm not sure I want an idle
timer running all the time just to detect the (rare) occasions
when I want to fold a tree.

Thanks,
Nick




--- End of Forwarded Message



___
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


Re: [Orgmode] Re: Showing hidden subtree automatically if point is hidden when the buffer is opened

2009-07-28 Thread Nick Dokos
PT (emacs user) spamfilteracco...@gmail.com wrote:

 On Tue, Jul 28, 2009 at 8:54 PM, Nick Dokosnicholas.do...@hp.com wrote:
 
  If they don't cost anything, yes. But I'm not sure I want an idle
  timer running all the time just to detect the (rare) occasions
  when I want to fold a tree.
 
 You misunderstand how it works. The idle timer doesn't run all the time.
 It's started when the org buffer is opened, it does its thing and then
 it stops running and it is disposed .
 
 It's a one-shot timer. Doesn't cost anything.
 

Oh, right: I didn't notice the REPEAT arg in the doc.

I still think that getting the configuration right in the first place
is better, but I guess you have reduced it to an aesthetic choice.

Thanks,
Nick





___
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


Re: [Orgmode] Re: Showing hidden subtree automatically if point is hidden when the buffer is opened

2009-07-28 Thread Bastien
User spamfilteracco...@gmail.com writes:

 Bastien bastienguerry at googlemail.com writes:
 
 If you load this *after* loading the saveplace hook then it should 
 be okay.  Thanks to Nick Dokos for shaking my brain on this :)

 Well, wasn't my original solution with the null timer much nicer?
 You didn't have to worry about making sure you put org-mode hook
 last and that it loads after saveplace hook.

Yes, but it's not straightforward to understand.  

To me, running a task when Emacs is idle for 0 seconds is very similar
to run immediately - that's why I didn't understand why you'd put this
first.

Why not checking if this run-with-idle-timer trick is necessary?  My
understanding is that org-mode hooks will be called *after* saveplace
restores the point.

(I just want to avoid unnecessary tricks for people who use Worg as a
place to learn things.)

 I tend to favor solutions which avoid such potential problems. :)

If it ain't broken, don't fix it ;)

-- 
 Bastien


___
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


Re: [Orgmode] Re: Showing hidden subtree automatically if point is hidden when the buffer is opened

2009-07-28 Thread Bastien
User spamfilteracco...@gmail.com writes:

 I added the timer, because I didn't know in which order the hooks
 are run. If org-mode hook runs first and then saveplace's hook
 which restores point then the above code has no effect.

saveplace adds the hook at the end of the hooks list, by calling
add-hook like this:

  (add-hook 'find-file-hook 'save-place-find-file-hook t)
   ^

The `t' means put this hook at the end.

So your org-mode hook will be safely called *before* saveplace's.

-- 
 Bastien


___
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