[-- Attachment #1: Type: text/plain, Size: 413 bytes --] Hi, One of my favorite key cords is C-xC-/, which is bound to `session-jump-to-last-change' from session.el ( http://emacs-session.sourceforge.net/). If I'm editing a large file, it allows me to revisit all the locations that I've "touched". However, when the related section is folded in org-mode, the point only moves to the heading. How hard would it be to have the section automatically expanded? -- Le [-- Attachment #2: Type: text/html, Size: 526 bytes --]
You can defadvice it to do org-reveal in org buffers. Or wrap it. -- AIDS 2.0 is here now: http://thekafkapandemic.blogspot.com/2010/12/welcome-to-kafka-pandemic-two-forces_9182.html I support the Whittemore-Peterson Institute (WPI) === I want to see the original (pre-hold) Lo et al. 2010 NIH/FDA/Harvard MRV paper.
[-- Attachment #1: Type: text/plain, Size: 770 bytes --] 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? On Thu, Mar 17, 2011 at 12:13 AM, Samuel Wales <samologist@gmail.com> wrote: > You can defadvice it to do org-reveal in org buffers. > > Or wrap it. > > -- > AIDS 2.0 is here now: > > http://thekafkapandemic.blogspot.com/2010/12/welcome-to-kafka-pandemic-two-forces_9182.html > I support the Whittemore-Peterson Institute (WPI) > === > I want to see the original (pre-hold) Lo et al. 2010 NIH/FDA/Harvard MRV > paper. > -- Le [-- Attachment #2: Type: text/html, Size: 1232 bytes --]
[-- Attachment #1: Type: text/plain, Size: 720 bytes --] 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? -- Le [-- Attachment #2: Type: text/html, Size: 1053 bytes --]
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
[-- Attachment #1: Type: text/plain, Size: 425 bytes --] On Thu, Mar 17, 2011 at 3:02 PM, Carsten Dominik <carsten.dominik@gmail.com>wrote: > (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))) > Thanks Carsten! That's xactly what I wanted. I'll coordinate with session's author to get this change integrated. -- Le [-- Attachment #2: Type: text/html, Size: 744 bytes --]
Le Wang <l26wang@gmail.com> wrote:
> On Thu, Mar 17, 2011 at 3:02 PM, Carsten Dominik <carsten.dominik@gmail.com> wrote:
>
> (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)))
>
> Thanks Carsten! That's xactly what I wanted. I'll coordinate with session's author to get this
> change integrated.
>
Why would you need to coordinate with the session author about advising
a function? It's your own personal advice and you can do whatever you
want. Of course, as Carsten pointed out, there is good advice and there
is bad advice, and you should only give good advice. But you are not
requesting any changes to the session code. You just stick the advice in
your .emacs and that's that.
Am I missing something?
Nick
[-- Attachment #1: Type: text/plain, Size: 643 bytes --] On Thu, Mar 17, 2011 at 10:27 PM, Nick Dokos <nicholas.dokos@hp.com> wrote: > Why would you need to coordinate with the session author about advising > a function? It's your own personal advice and you can do whatever you > want. Of course, as Carsten pointed out, there is good advice and there > is bad advice, and you should only give good advice. But you are not > requesting any changes to the session code. You just stick the advice in > your .emacs and that's that. > > Am I missing something? The defadvice is a hack until session can be changed to not need it. I assume I won't be the only one to ever find this useful. -- Le [-- Attachment #2: Type: text/html, Size: 945 bytes --]
Le Wang <l26wang@gmail.com> writes:
> On Thu, Mar 17, 2011 at 10:27 PM, Nick Dokos <nicholas.dokos@hp.com> wrote:
>
>> Why would you need to coordinate with the session author about advising
>> a function? It's your own personal advice and you can do whatever you
>> want. Of course, as Carsten pointed out, there is good advice and there
>> is bad advice, and you should only give good advice. But you are not
>> requesting any changes to the session code. You just stick the advice in
>> your .emacs and that's that.
>>
>> Am I missing something?
>
>
> The defadvice is a hack until session can be changed to not need it. I
> assume I won't be the only one to ever find this useful.
Sure but I don't think it makes sense to customise the behaviour of
/session/ for /org/ specific issues? The session code should be kept as
general as possible, I would suggest.
--
: Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.50.1
: using Org-mode version 7.5 (release_7.5.77.g74268.dirty)
On 17.3.2011, at 19:30, Eric S Fraga wrote: > Le Wang <l26wang@gmail.com> writes: > >> On Thu, Mar 17, 2011 at 10:27 PM, Nick Dokos <nicholas.dokos@hp.com> wrote: >> >>> Why would you need to coordinate with the session author about advising >>> a function? It's your own personal advice and you can do whatever you >>> want. Of course, as Carsten pointed out, there is good advice and there >>> is bad advice, and you should only give good advice. But you are not >>> requesting any changes to the session code. You just stick the advice in >>> your .emacs and that's that. >>> >>> Am I missing something? >> >> >> The defadvice is a hack until session can be changed to not need it. I >> assume I won't be the only one to ever find this useful. > > Sure but I don't think it makes sense to customise the behaviour of > /session/ for /org/ specific issues? The session code should be kept as > general as possible, I would suggest. A good solution would be for session to provide a hook that we can use. - Carsten > > -- > : Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.50.1 > : using Org-mode version 7.5 (release_7.5.77.g74268.dirty) >
On Fri, Mar 18, 2011 at 4:13 AM, Carsten Dominik <carsten.dominik@gmail.com> wrote: > A good solution would be for session to provide a hook that we can use. Christoph has submitted version 2.3a of session http://sourceforge.net/projects/emacs-session/files/session/ The required hook has been added, maybe someone who knows org-mode can add it to the appropriate file? From my .emacs: (add-hook 'session-after-jump-to-last-change-hook (lambda () (when (and (eq major-mode 'org-mode) (outline-invisible-p)) (org-reveal)))) -- Le