emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Carsten Dominik <carsten.dominik@gmail.com>
To: Le Wang <l26wang@gmail.com>
Cc: Orgmode Mailing List <emacs-orgmode@gnu.org>
Subject: Re: `session-jump-to-last-change' and org-mode
Date: Thu, 17 Mar 2011 08:02:28 +0100	[thread overview]
Message-ID: <B95E706E-A403-4897-8225-BC979BDD65DB@gmail.com> (raw)
In-Reply-To: <AANLkTi=Zf0JwWx7uMYc57iqm0Q+5VoU_rzGgGSfVcvBy@mail.gmail.com>


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

> On Thu, Mar 17, 2011 at 12:27 AM, Le Wang <l26wang@gmail.com> 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	other threads:[~2011-03-17  7:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-16 15:18 `session-jump-to-last-change' and org-mode Le Wang
2011-03-16 16:13 ` Samuel Wales
2011-03-16 16:27   ` Le Wang
2011-03-17  6:20     ` Le Wang
2011-03-17  7:02       ` Carsten Dominik [this message]
2011-03-17  8:53         ` Le Wang
2011-03-17 14:27           ` Nick Dokos
2011-03-17 14:54             ` Le Wang
2011-03-17 18:30               ` Eric S Fraga
2011-03-17 20:13                 ` Carsten Dominik
2011-04-13  1:59                   ` Le Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=B95E706E-A403-4897-8225-BC979BDD65DB@gmail.com \
    --to=carsten.dominik@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=l26wang@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).