unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: Weird behaviour with org-yank and org-startup-indented
       [not found] ` <3B1391C6-72E9-4BAA-9197-7B27B26249BC@gmail.com>
@ 2010-10-18 14:37   ` Julien Danjou
  2010-10-20 12:31     ` [Orgmode] " Julien Danjou
  0 siblings, 1 reply; 10+ messages in thread
From: Julien Danjou @ 2010-10-18 14:37 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode, emacs-devel

On Sun, Oct 17 2010, Carsten Dominik wrote:

> This is bad.  As this problem does not exist in Emacs 23 and I have not
> changed anything in this part of the code, maybe a bug report to  EMacs is
> in order.  Will you file one, with the remark that this works  fine in Emacs
> 23?

I'm not sure that will work fine. Well, I've started to debug this, any
help appreciated.

I'm adding emacs-devel in Cc since this is clearly a bug in Emacs 24.
For people not reading orgmode list, the problem is that when
org-startup-indented is set to t, the yanking does not yank the correct
text.

To test, this is what I've got:

* TODO Blalaundo

I copy "undo" with C-space on `u', C-e, M-w.

Then I press C-y (org-yank). Everything is fine, except that as that
moment:

Debugger entered--returning value: "* TODO Blala"
  x-get-selection(PRIMARY UTF8_STRING)
* byte-code("\303\b	@\"\x12\303\207" [type request-type text x-get-selection] 3)
* x-selection-value-internal(PRIMARY)
* x-selection-value()
* current-kill(0)
* (and kill-ring (current-kill 0))
* (or txt (and kill-ring (current-kill 0)) "")
* (let* ((kill (or txt (and kill-ring (current-kill 0)) "")) (start-level (and kill (string-match (concat "\\`\\([ 	\n\r]*?\n\\)?\\(" org-outline-regexp "\\)") kill) (- (match-end 2) (match-beginning 2) 1))) (re (concat "^" org-outline-regexp)) (start (1+ (or (match-beginning 2) -1)))) (if (not start-level) (progn nil) (catch (quote exit) (while (setq start (string-match re kill (1+ start))) (when (< (- (match-end 0) (match-beginning 0) 1) start-level) (throw (quote exit) nil))) t)))
* org-kill-is-subtree-p()
* (and (org-kill-is-subtree-p) (or (bolp) (and (looking-at "[ 	]*$") (string-match "\\`\\*+\\'" (buffer-substring (point-at-bol) (point))))))
* (let ((subtreep (and (org-kill-is-subtree-p) (or (bolp) (and (looking-at "[ 	]*$") (string-match "\\`\\*+\\'" (buffer-substring ... ...)))))) swallowp) (cond ((and subtreep org-yank-folded-subtrees) (let ((beg (point)) end) (if (and subtreep org-yank-adjusted-subtrees) (org-paste-subtree nil nil (quote for-yank)) (call-interactively command)) (setq end (point)) (goto-char beg) (when (and (bolp) subtreep (not (setq swallowp ...))) (or (looking-at outline-regexp) (re-search-forward (concat "^" outline-regexp) end t)) (while (and (< ... end) (looking-at outline-regexp)) (hide-subtree) (org-cycle-show-empty-lines (quote folded)) (condition-case nil (outline-forward-same-level 1) (error ...)))) (when swallowp (message "Inserted text not folded because that would swallow text")) (goto-char end) (skip-chars-forward " 	\n\r") (beginning-of-line 1) (push-mark beg (quote nomsg)))) ((and subtreep org-yank-adjusted-subtrees) (let ((beg (point-at-bol))) (org-paste-subtree nil nil (quote for-yank)) (push-mark beg (quote nomsg)))) (t (call-interactively command))))
* (if arg (call-interactively command) (let ((subtreep (and (org-kill-is-subtree-p) (or (bolp) (and (looking-at "[ 	]*$") (string-match "\\`\\*+\\'" ...))))) swallowp) (cond ((and subtreep org-yank-folded-subtrees) (let ((beg (point)) end) (if (and subtreep org-yank-adjusted-subtrees) (org-paste-subtree nil nil (quote for-yank)) (call-interactively command)) (setq end (point)) (goto-char beg) (when (and (bolp) subtreep (not ...)) (or (looking-at outline-regexp) (re-search-forward ... end t)) (while (and ... ...) (hide-subtree) (org-cycle-show-empty-lines ...) (condition-case nil ... ...))) (when swallowp (message "Inserted text not folded because that would swallow text")) (goto-char end) (skip-chars-forward " 	\n\r") (beginning-of-line 1) (push-mark beg (quote nomsg)))) ((and subtreep org-yank-adjusted-subtrees) (let ((beg (point-at-bol))) (org-paste-subtree nil nil (quote for-yank)) (push-mark beg (quote nomsg)))) (t (call-interactively command)))))
* org-yank-generic(yank nil)
* org-yank(nil)
  call-interactively(org-yank nil nil)

No clue why, but the PRIMARY selection seems to return the start of the
line.

I've done this then:

* TODO Blalaundo

I go on `u', press C-space, then C-e. The M-; and execute
(x-selection-value), which returns: "undo".

So far so good. But if I go on `u', press C-space, then C-e, then M-w,
then M-; to execute (x-selection-value), it returns "* TODO Blala".

So it seems that when the org-startup-indented is set to t, M-w goes
crazy and set the primary selection wrongly.

Hint?
-- 
Julien Danjou
// ᐰ <julien@danjou.info>   http://julien.danjou.info

_______________________________________________
Emacs-orgmode mailing list
Please 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] 10+ messages in thread

* Re: [Orgmode] Weird behaviour with org-yank and org-startup-indented
  2010-10-18 14:37   ` Weird behaviour with org-yank and org-startup-indented Julien Danjou
@ 2010-10-20 12:31     ` Julien Danjou
  2010-10-20 15:09       ` Chong Yidong
  2010-10-20 15:33       ` Chong Yidong
  0 siblings, 2 replies; 10+ messages in thread
From: Julien Danjou @ 2010-10-20 12:31 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode, emacs-devel

On Mon, Oct 18 2010, Julien Danjou wrote:

> I've done this then:
>
> * TODO Blalaundo
>
> I go on `u', press C-space, then C-e. The M-; and execute
> (x-selection-value), which returns: "undo".
>
> So far so good. But if I go on `u', press C-space, then C-e, then M-w,
> then M-; to execute (x-selection-value), it returns "* TODO Blala".
>
> So it seems that when the org-startup-indented is set to t, M-w goes
> crazy and set the primary selection wrongly.

So it seems that the problem I raise does not interest anybody, but I
will continue to debug.

This is how to reproduce.
In a Org buffer with org-startup-indented set to t, type:

** TODO abcdefgh

Then:
M-x debug-on-entry x-set-selection

Go on `c', activate mark press C-e, press M-w (kill-ring-save). You'll
hit several breakpoint until you'll get:

Debugger entered--entering a function:
* x-set-selection(PRIMARY "** TODO")
  deactivate-mark()

And I've been further:
saved-region-selection is nil
Then as soon as I select the `c' of the above string,
saved-region-selection is set to "** TODO".

Which seems *bad*. :)

-- 
Julien Danjou
// ᐰ <julien@danjou.info>   http://julien.danjou.info



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

* Re: [Orgmode] Weird behaviour with org-yank and org-startup-indented
  2010-10-20 12:31     ` [Orgmode] " Julien Danjou
@ 2010-10-20 15:09       ` Chong Yidong
  2010-10-20 15:24         ` Julien Danjou
  2010-10-20 15:33       ` Chong Yidong
  1 sibling, 1 reply; 10+ messages in thread
From: Chong Yidong @ 2010-10-20 15:09 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode, emacs-devel

Julien Danjou <julien@danjou.info> writes:

> So it seems that the problem I raise does not interest anybody, but I
> will continue to debug.
>
> This is how to reproduce.

It's rather strange to complain about nobody else working on the bug,
when you (i) did not give a recipe and (ii) stated that you were already
working on it.

Now that you have provided a recipe, I will take a look.



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

* Re: [Orgmode] Weird behaviour with org-yank and org-startup-indented
  2010-10-20 15:09       ` Chong Yidong
@ 2010-10-20 15:24         ` Julien Danjou
  2010-10-20 15:58           ` Chong Yidong
  0 siblings, 1 reply; 10+ messages in thread
From: Julien Danjou @ 2010-10-20 15:24 UTC (permalink / raw)
  To: Chong Yidong; +Cc: emacs-devel, emacs-orgmode, Carsten Dominik

On Wed, Oct 20 2010, Chong Yidong wrote:

> It's rather strange to complain about nobody else working on the bug,
> when you (i) did not give a recipe and (ii) stated that you were already
> working on it.

My bad, I think I forgot to add a smiley at the end of the sentence, so
 here it is: :-)

I did not mean to be rude. :)

-- 
Julien Danjou
// ᐰ <julien@danjou.info>   http://julien.danjou.info



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

* Re: [Orgmode] Weird behaviour with org-yank and org-startup-indented
  2010-10-20 12:31     ` [Orgmode] " Julien Danjou
  2010-10-20 15:09       ` Chong Yidong
@ 2010-10-20 15:33       ` Chong Yidong
  2010-10-20 15:37         ` Lennart Borgman
                           ` (2 more replies)
  1 sibling, 3 replies; 10+ messages in thread
From: Chong Yidong @ 2010-10-20 15:33 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode, emacs-devel

Julien Danjou <julien@danjou.info> writes:

> In a Org buffer with org-startup-indented set to t, type:
>
> ** TODO abcdefgh
>
> Go on `c', activate mark press C-e, press M-w (kill-ring-save).
> [Wrong primary selection appears]

The problem is in org-indent-refresh-section, which is run from a timer.
This function first moves point and then calls remove-text-properties,
which is considered a buffer change.  Since the mark is active, the
selection code saves the region to saved-region-selection, from which it
is later saved to the primary selection.

There are a few possible fixes, but I am yet not sure which is best.
One is to avoid setting saved-region-selection inside a timer.  Another
is for save-excursion to inhibit writing to saved-region-selection; a
third is not to treat remove-text-properties as a trigger for saving the
primary selection.



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

* Re: [Orgmode] Weird behaviour with org-yank and org-startup-indented
  2010-10-20 15:33       ` Chong Yidong
@ 2010-10-20 15:37         ` Lennart Borgman
  2010-10-20 17:38         ` Stefan Monnier
  2010-10-21 17:38         ` Carsten Dominik
  2 siblings, 0 replies; 10+ messages in thread
From: Lennart Borgman @ 2010-10-20 15:37 UTC (permalink / raw)
  To: Chong Yidong; +Cc: emacs-devel, emacs-orgmode, Carsten Dominik

On Wed, Oct 20, 2010 at 5:33 PM, Chong Yidong <cyd@stupidchicken.com> wrote:
> Julien Danjou <julien@danjou.info> writes:
>
>> In a Org buffer with org-startup-indented set to t, type:
>>
>> ** TODO abcdefgh
>>
>> Go on `c', activate mark press C-e, press M-w (kill-ring-save).
>> [Wrong primary selection appears]
>
> The problem is in org-indent-refresh-section, which is run from a timer.
> This function first moves point and then calls remove-text-properties,
> which is considered a buffer change.  Since the mark is active, the
> selection code saves the region to saved-region-selection, from which it
> is later saved to the primary selection.
>
> There are a few possible fixes, but I am yet not sure which is best.
> One is to avoid setting saved-region-selection inside a timer.  Another
> is for save-excursion to inhibit writing to saved-region-selection; a
> third is not to treat remove-text-properties as a trigger for saving the
> primary selection.

Another possibility is to protect remove-text-properties from marking
the buffer as changed (just as font-lock does).



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

* Re: [Orgmode] Weird behaviour with org-yank and org-startup-indented
  2010-10-20 15:24         ` Julien Danjou
@ 2010-10-20 15:58           ` Chong Yidong
  0 siblings, 0 replies; 10+ messages in thread
From: Chong Yidong @ 2010-10-20 15:58 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: emacs-orgmode, emacs-devel

Julien Danjou <julien@danjou.info> writes:

> On Wed, Oct 20 2010, Chong Yidong wrote:
>
>> It's rather strange to complain about nobody else working on the bug,
>> when you (i) did not give a recipe and (ii) stated that you were already
>> working on it.
>
> My bad, I think I forgot to add a smiley at the end of the sentence, so
>  here it is: :-)
>
> I did not mean to be rude. :)

No worries.  Thank you for working on the bug.



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

* Re: [Orgmode] Weird behaviour with org-yank and org-startup-indented
  2010-10-20 15:33       ` Chong Yidong
  2010-10-20 15:37         ` Lennart Borgman
@ 2010-10-20 17:38         ` Stefan Monnier
  2010-10-21 17:40           ` Chong Yidong
  2010-10-21 17:38         ` Carsten Dominik
  2 siblings, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2010-10-20 17:38 UTC (permalink / raw)
  To: Chong Yidong; +Cc: emacs-devel, emacs-orgmode, Carsten Dominik

> The problem is in org-indent-refresh-section, which is run from a timer.
> This function first moves point and then calls remove-text-properties,
> which is considered a buffer change.  Since the mark is active, the
> selection code saves the region to saved-region-selection, from which it
> is later saved to the primary selection.

Shouldn't org-indent-refresh-section use with-silent-modifications
around the remove-text-properties call?


        Stefan



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

* Re: Weird behaviour with org-yank and org-startup-indented
  2010-10-20 15:33       ` Chong Yidong
  2010-10-20 15:37         ` Lennart Borgman
  2010-10-20 17:38         ` Stefan Monnier
@ 2010-10-21 17:38         ` Carsten Dominik
  2 siblings, 0 replies; 10+ messages in thread
From: Carsten Dominik @ 2010-10-21 17:38 UTC (permalink / raw)
  To: Chong Yidong; +Cc: Julien Danjou, Org Mode, Stefan Monnier, Emacs developers


On Oct 20, 2010, at 5:33 PM, Chong Yidong wrote:

> Julien Danjou <julien@danjou.info> writes:
>
>> In a Org buffer with org-startup-indented set to t, type:
>>
>> ** TODO abcdefgh
>>
>> Go on `c', activate mark press C-e, press M-w (kill-ring-save).
>> [Wrong primary selection appears]
>
> The problem is in org-indent-refresh-section, which is run from a  
> timer.
> This function first moves point and then calls remove-text-properties,
> which is considered a buffer change.  Since the mark is active, the
> selection code saves the region to saved-region-selection, from  
> which it
> is later saved to the primary selection.

Ah, this is interesting, thank you very much!

>
> There are a few possible fixes, but I am yet not sure which is best.
> One is to avoid setting saved-region-selection inside a timer.   
> Another
> is for save-excursion to inhibit writing to saved-region-selection; a
> third is not to treat remove-text-properties as a trigger for saving  
> the
> primary selection.

I'll go with Stefan's solution, using with-silent-modifications.  I  
had already
code that would restore buffer-modified-flag, but apparently this was  
not enough.

Thanks!

- Carsten

_______________________________________________
Emacs-orgmode mailing list
Please 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] 10+ messages in thread

* Re: [Orgmode] Weird behaviour with org-yank and org-startup-indented
  2010-10-20 17:38         ` Stefan Monnier
@ 2010-10-21 17:40           ` Chong Yidong
  0 siblings, 0 replies; 10+ messages in thread
From: Chong Yidong @ 2010-10-21 17:40 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel, emacs-orgmode, Carsten Dominik

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> The problem is in org-indent-refresh-section, which is run from a timer.
>> This function first moves point and then calls remove-text-properties,
>> which is considered a buffer change.  Since the mark is active, the
>> selection code saves the region to saved-region-selection, from which it
>> is later saved to the primary selection.
>
> Shouldn't org-indent-refresh-section use with-silent-modifications
> around the remove-text-properties call?

If we were starting from scratch, I think it's more sensible to make
text property changes "silent" by default, while providing an explicit
call to "unsilence" them when desired (which seem to be a minority of
cases).  I guess it's too late to change now, though.



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

end of thread, other threads:[~2010-10-21 17:40 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <87bp6vpks7.fsf@keller.adm.naquadah.org>
     [not found] ` <3B1391C6-72E9-4BAA-9197-7B27B26249BC@gmail.com>
2010-10-18 14:37   ` Weird behaviour with org-yank and org-startup-indented Julien Danjou
2010-10-20 12:31     ` [Orgmode] " Julien Danjou
2010-10-20 15:09       ` Chong Yidong
2010-10-20 15:24         ` Julien Danjou
2010-10-20 15:58           ` Chong Yidong
2010-10-20 15:33       ` Chong Yidong
2010-10-20 15:37         ` Lennart Borgman
2010-10-20 17:38         ` Stefan Monnier
2010-10-21 17:40           ` Chong Yidong
2010-10-21 17:38         ` Carsten Dominik

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.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).