Re: [Orgmode] Weird behaviour with org-yank and org-startup-indented

2010-10-21 Thread Carsten Dominik


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


Julien Danjou jul...@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


Re: [Orgmode] Weird behaviour with org-yank and org-startup-indented

2010-10-21 Thread Chong Yidong
Stefan Monnier monn...@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.

___
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


Re: [Orgmode] Weird behaviour with org-yank and org-startup-indented

2010-10-20 Thread Julien Danjou
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
// ᐰ jul...@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


Re: [Orgmode] Weird behaviour with org-yank and org-startup-indented

2010-10-20 Thread Julien Danjou
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
// ᐰ jul...@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


Re: [Orgmode] Weird behaviour with org-yank and org-startup-indented

2010-10-20 Thread Andreas Röhler

Am 20.10.2010 17:24, schrieb Julien Danjou:

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



Hi Julien,

the 24' branch is simply not usable IMHO. I'm afraid for many reasons.
Have a look at

http://debbugs.gnu.org/


Andreas

--
https://code.launchpad.net/~a-roehler/python-mode/python-mode-components
https://code.launchpad.net/s-x-emacs-werkstatt/

___
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


Re: [Orgmode] Weird behaviour with org-yank and org-startup-indented

2010-10-20 Thread Lennart Borgman
On Wed, Oct 20, 2010 at 5:33 PM, Chong Yidong c...@stupidchicken.com wrote:
 Julien Danjou jul...@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).

___
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


Re: [Orgmode] Weird behaviour with org-yank and org-startup-indented

2010-10-20 Thread Chong Yidong
Julien Danjou jul...@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.

___
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


Re: [Orgmode] Weird behaviour with org-yank and org-startup-indented

2010-10-20 Thread Chong Yidong
Julien Danjou jul...@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.

___
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


Re: [Orgmode] Weird behaviour with org-yank and org-startup-indented

2010-10-20 Thread Stefan Monnier
 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

___
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


Re: [Orgmode] Weird behaviour with org-yank and org-startup-indented

2010-10-20 Thread Chong Yidong
Julien Danjou jul...@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.

___
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


Re: [Orgmode] Weird behaviour with org-yank and org-startup-indented

2010-10-18 Thread Julien Danjou
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  @\\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
]*?\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
) (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
) (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
// ᐰ jul...@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


[Orgmode] Weird behaviour with org-yank and org-startup-indented

2010-10-15 Thread Julien Danjou
Hi,

I'm using org 7.01h with Emacs 24 trunk. When I set org-startup-indented
to t, I observe the following:

** TODO Some stuff

I select stuff and press M-w. Then I go the the line under and press
C-y (org-yank).

Now I got:

** TODO Some stuff
** TODO Some

instead of:

** TODO Some stuff
stuff

Note that after M-w, `kill-ring' has a correct first entry of stuff:

  (#(stuff 0 5
 (fontified t face org-level-2))
   ...)

But on C-y (org-yank) something happens, and it paste the wrong text. I
think it's trying to be smart but it's not.

I've found that setting org-startup-indented to nil fix that behaviour.

What's wrong?
-- 
Julien Danjou
// ᐰ jul...@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