emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* save-excursion fails to restore point
@ 2009-06-09 20:56 Samuel Wales
  2009-06-10  7:03 ` Carsten Dominik
  0 siblings, 1 reply; 3+ messages in thread
From: Samuel Wales @ 2009-06-09 20:56 UTC (permalink / raw)
  To: emacs-orgmode

Here is a minimal test case:

(save-excursion
  (outline-up-heading 1 'invisible-ok)
  (org-sort-entries-or-items nil ?a))

What happens is that point stays on the parent headline.

What I expect is for save-excursion to save point no
differently from just saving point and doing goto-char.

Also:

When I change a todo state and then sort entries manually
using my sort function, everything works.  But when I do so
from org-after-todo-state-change-hook, point gets placed on
the parent headline.  Point gets changed right after the
save-excursion in org-todo (3rd paren from last).

Reproducible?

RMS in the reply to
http://www.archivum.info/bug-gnu-emacs@gnu.org/2006-01/msg00053.html
seems to say that it is inevitable.

Is there a way for org to work around this?

If not, it is a warning to the wise.

-- 
Myalgic encephalomyelitis denialism is causing death and severe suffering,
worse than MS.  Conflicts of interest are destroying research.  /You/ can
get the disease at any time permanently.  Do science and justice matter to
you?  http://www.meactionuk.org.uk/What_Is_ME_What_Is_CFS.htm

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

* Re: save-excursion fails to restore point
  2009-06-09 20:56 save-excursion fails to restore point Samuel Wales
@ 2009-06-10  7:03 ` Carsten Dominik
  2009-06-10 16:11   ` Samuel Wales
  0 siblings, 1 reply; 3+ messages in thread
From: Carsten Dominik @ 2009-06-10  7:03 UTC (permalink / raw)
  To: Samuel Wales; +Cc: emacs-orgmode


On Jun 9, 2009, at 10:56 PM, Samuel Wales wrote:

> Here is a minimal test case:
>
> (save-excursion
>  (outline-up-heading 1 'invisible-ok)
>  (org-sort-entries-or-items nil ?a))
>
> What happens is that point stays on the parent headline.
>
> What I expect is for save-excursion to save point no
> differently from just saving point and doing goto-char.
>
> Also:
>
> When I change a todo state and then sort entries manually
> using my sort function, everything works.  But when I do so
> from org-after-todo-state-change-hook, point gets placed on
> the parent headline.  Point gets changed right after the
> save-excursion in org-todo (3rd paren from last).
>
> Reproducible?
>
> RMS in the reply to
> http://www.archivum.info/bug-gnu-emacs@gnu.org/2006-01/msg00053.html
> seems to say that it is inevitable.

I think it is in fact unavoidable when you delete and re-insert
text that contained a marker.  Not impossible to fix, or does
in fact do if for clock history markers, but for the sorting routine
that would really be too much to ask.

- Carsten


>
> Is there a way for org to work around this?
>
> If not, it is a warning to the wise.
>
> --  
> Myalgic encephalomyelitis denialism is causing death and severe  
> suffering,
> worse than MS.  Conflicts of interest are destroying research.  / 
> You/ can
> get the disease at any time permanently.  Do science and justice  
> matter to
> you?  http://www.meactionuk.org.uk/What_Is_ME_What_Is_CFS.htm
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: save-excursion fails to restore point
  2009-06-10  7:03 ` Carsten Dominik
@ 2009-06-10 16:11   ` Samuel Wales
  0 siblings, 0 replies; 3+ messages in thread
From: Samuel Wales @ 2009-06-10 16:11 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode

OK, thanks.  I won't expect s-e to work all the time.

The following does not work.

(add-hook 'org-after-todo-state-change-hook
          'alpha-org-after-todo-state-change-hook)
(defun alpha-org-after-todo-state-change-hook ()
  (let ((alpha-oatsch (point)))
    (if (alpha-org-entry-is-todo-type :doneish)
        (alpha-org-sort-siblings :very-coarse)
      (hide-leaves))
    (goto-char alpha-oatsch)))

Is this related?

(defadvice org-todo (around fix-point activate)
  (let ((alpha-defadvice-org-todo (point)))
    ad-do-it
    (goto-char alpha-defadvice-org-todo)))

does work.

Thanks.

On Wed, Jun 10, 2009 at 00:03, Carsten Dominik<carsten.dominik@gmail.com> wrote:
>
> On Jun 9, 2009, at 10:56 PM, Samuel Wales wrote:
>
>> Here is a minimal test case:
>>
>> (save-excursion
>>  (outline-up-heading 1 'invisible-ok)
>>  (org-sort-entries-or-items nil ?a))
>>
>> What happens is that point stays on the parent headline.
>>
>> What I expect is for save-excursion to save point no
>> differently from just saving point and doing goto-char.
>>
>> Also:
>>
>> When I change a todo state and then sort entries manually
>> using my sort function, everything works.  But when I do so
>> from org-after-todo-state-change-hook, point gets placed on
>> the parent headline.  Point gets changed right after the
>> save-excursion in org-todo (3rd paren from last).
>>
>> Reproducible?
>>
>> RMS in the reply to
>> http://www.archivum.info/bug-gnu-emacs@gnu.org/2006-01/msg00053.html
>> seems to say that it is inevitable.
>
> I think it is in fact unavoidable when you delete and re-insert
> text that contained a marker.  Not impossible to fix, or does
> in fact do if for clock history markers, but for the sorting routine
> that would really be too much to ask.
>
> - Carsten
>
>
>>
>> Is there a way for org to work around this?
>>
>> If not, it is a warning to the wise.
>>
>> -- Myalgic encephalomyelitis denialism is causing death and severe
>> suffering,
>> worse than MS.  Conflicts of interest are destroying research.  /You/ can
>> get the disease at any time permanently.  Do science and justice matter to
>> you?  http://www.meactionuk.org.uk/What_Is_ME_What_Is_CFS.htm
>>
>>
>> _______________________________________________
>> Emacs-orgmode mailing list
>> Remember: use `Reply All' to send replies to the list.
>> Emacs-orgmode@gnu.org
>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>
>



-- 
Myalgic encephalomyelitis denialism is causing death and severe suffering,
worse than MS.  Conflicts of interest are destroying research.  /You/ can
get the disease at any time permanently.  Do science and justice matter to
you?  http://www.meactionuk.org.uk/What_Is_ME_What_Is_CFS.htm

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

end of thread, other threads:[~2009-06-10 16:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-09 20:56 save-excursion fails to restore point Samuel Wales
2009-06-10  7:03 ` Carsten Dominik
2009-06-10 16:11   ` Samuel Wales

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