emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* `session-jump-to-last-change' and org-mode
@ 2011-03-16 15:18 Le Wang
  2011-03-16 16:13 ` Samuel Wales
  0 siblings, 1 reply; 11+ messages in thread
From: Le Wang @ 2011-03-16 15:18 UTC (permalink / raw)
  To: Orgmode Mailing List

[-- 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 --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: `session-jump-to-last-change' and org-mode
  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
  0 siblings, 1 reply; 11+ messages in thread
From: Samuel Wales @ 2011-03-16 16:13 UTC (permalink / raw)
  To: Le Wang; +Cc: Orgmode Mailing List

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.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: `session-jump-to-last-change' and org-mode
  2011-03-16 16:13 ` Samuel Wales
@ 2011-03-16 16:27   ` Le Wang
  2011-03-17  6:20     ` Le Wang
  0 siblings, 1 reply; 11+ messages in thread
From: Le Wang @ 2011-03-16 16:27 UTC (permalink / raw)
  To: Samuel Wales; +Cc: Orgmode Mailing List

[-- 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 --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: `session-jump-to-last-change' and org-mode
  2011-03-16 16:27   ` Le Wang
@ 2011-03-17  6:20     ` Le Wang
  2011-03-17  7:02       ` Carsten Dominik
  0 siblings, 1 reply; 11+ messages in thread
From: Le Wang @ 2011-03-17  6:20 UTC (permalink / raw)
  To: Samuel Wales; +Cc: Orgmode Mailing List

[-- 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 --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: `session-jump-to-last-change' and org-mode
  2011-03-17  6:20     ` Le Wang
@ 2011-03-17  7:02       ` Carsten Dominik
  2011-03-17  8:53         ` Le Wang
  0 siblings, 1 reply; 11+ messages in thread
From: Carsten Dominik @ 2011-03-17  7:02 UTC (permalink / raw)
  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 <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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: `session-jump-to-last-change' and org-mode
  2011-03-17  7:02       ` Carsten Dominik
@ 2011-03-17  8:53         ` Le Wang
  2011-03-17 14:27           ` Nick Dokos
  0 siblings, 1 reply; 11+ messages in thread
From: Le Wang @ 2011-03-17  8:53 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: Orgmode Mailing List

[-- 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 --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: `session-jump-to-last-change' and org-mode
  2011-03-17  8:53         ` Le Wang
@ 2011-03-17 14:27           ` Nick Dokos
  2011-03-17 14:54             ` Le Wang
  0 siblings, 1 reply; 11+ messages in thread
From: Nick Dokos @ 2011-03-17 14:27 UTC (permalink / raw)
  To: Le Wang; +Cc: nicholas.dokos, Orgmode Mailing List, Carsten Dominik

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: `session-jump-to-last-change' and org-mode
  2011-03-17 14:27           ` Nick Dokos
@ 2011-03-17 14:54             ` Le Wang
  2011-03-17 18:30               ` Eric S Fraga
  0 siblings, 1 reply; 11+ messages in thread
From: Le Wang @ 2011-03-17 14:54 UTC (permalink / raw)
  To: nicholas.dokos; +Cc: Orgmode Mailing List

[-- 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 --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: `session-jump-to-last-change' and org-mode
  2011-03-17 14:54             ` Le Wang
@ 2011-03-17 18:30               ` Eric S Fraga
  2011-03-17 20:13                 ` Carsten Dominik
  0 siblings, 1 reply; 11+ messages in thread
From: Eric S Fraga @ 2011-03-17 18:30 UTC (permalink / raw)
  To: Le Wang; +Cc: nicholas.dokos, Orgmode Mailing List

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)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: `session-jump-to-last-change' and org-mode
  2011-03-17 18:30               ` Eric S Fraga
@ 2011-03-17 20:13                 ` Carsten Dominik
  2011-04-13  1:59                   ` Le Wang
  0 siblings, 1 reply; 11+ messages in thread
From: Carsten Dominik @ 2011-03-17 20:13 UTC (permalink / raw)
  To: Eric S Fraga; +Cc: nicholas.dokos, Orgmode Mailing List, Le Wang


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)
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: `session-jump-to-last-change' and org-mode
  2011-03-17 20:13                 ` Carsten Dominik
@ 2011-04-13  1:59                   ` Le Wang
  0 siblings, 0 replies; 11+ messages in thread
From: Le Wang @ 2011-04-13  1:59 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: Orgmode Mailing List

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2011-04-13  1:59 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

Code repositories for project(s) associated with this 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).