From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: `session-jump-to-last-change' and org-mode Date: Thu, 17 Mar 2011 08:02:28 +0100 Message-ID: References: Mime-Version: 1.0 (Apple Message framework v1082) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Return-path: Received: from [140.186.70.92] (port=40156 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q07EA-000624-K9 for emacs-orgmode@gnu.org; Thu, 17 Mar 2011 03:02:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q07E9-0001by-7X for emacs-orgmode@gnu.org; Thu, 17 Mar 2011 03:02:34 -0400 Received: from mail-wy0-f169.google.com ([74.125.82.169]:44634) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q07E9-0001bu-24 for emacs-orgmode@gnu.org; Thu, 17 Mar 2011 03:02:33 -0400 Received: by wyf19 with SMTP id 19so2715432wyf.0 for ; Thu, 17 Mar 2011 00:02:32 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Le Wang Cc: Orgmode Mailing List On 17.3.2011, at 07:20, Le Wang wrote: > On Thu, Mar 17, 2011 at 12:27 AM, Le Wang 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. >=20 > Is there a org-goto-char type of function that always goes to that = location in the buffer, expanding sections along the way? >=20 > I've solved it by advising goto-char like so: >=20 > (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)) > =20 > 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=20 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=