emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] `session-jump-to-last-change' and org-mode


From: Carsten Dominik
Subject: Re: [O] `session-jump-to-last-change' and org-mode
Date: Thu, 17 Mar 2011 08:02:28 +0100

On 17.3.2011, at 07:20, Le Wang wrote:

> On Thu, Mar 17, 2011 at 12:27 AM, Le Wang <address@hidden> wrote:
> Yes, I didn't know about `org-reveal'.  That could work.  But how do I figure 
> out if I need to expand the heading?  The last change could be to a folded 
> heading itself, in which case, it shouldn't be expanded.
> 
> Is there a org-goto-char type of function that always goes to that location 
> in the buffer, expanding sections along the way?
> 
> I've solved it by advising goto-char like so:
> 
> (defadvice goto-char (around org-expand activate compile)
>   (if (eq major-mode 'org-mode)
>       (progn
>         ad-do-it
>         (org-reveal)
>         ad-do-it)
>     ad-do-it))
>  
> Can anyone see any problems with advising such a fundamental function?

Yes, this is certainly a very bad idea.  goto-char is used many times in lisp 
programs, also in Org, so executing normal Org functions will be slowed down 
and reveal parts that should not be revealed.

Instead you should be advising session-jump-to-last-change itself.
If you do not want to expand a full entry if the change was in 
a headline, you can check for invisibility:


(defadvice session-jump-to-last-change (after org-expand activate compile)
  "Reveal hidden point after jumping."
  (when (and (eq major-mode 'org-mode)
             (outline-invisible-p))
    (org-reveal)))

HTH

- Carsten


reply via email to

[Prev in Thread] Current Thread [Next in Thread]