emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Julien Danjou <julien@danjou.info>
To: Carsten Dominik <carsten.dominik@gmail.com>
Cc: emacs-orgmode@gnu.org, emacs-devel@gnu.org
Subject: Re: Weird behaviour with org-yank and org-startup-indented
Date: Mon, 18 Oct 2010 16:37:12 +0200	[thread overview]
Message-ID: <sa3bp6r1s9z.fsf@cigue.easter-eggs.fr> (raw)
In-Reply-To: <3B1391C6-72E9-4BAA-9197-7B27B26249BC@gmail.com> (Carsten Dominik's message of "Sun, 17 Oct 2010 08:08:38 +0200")

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

  reply	other threads:[~2010-10-18 14:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-15 14:56 Weird behaviour with org-yank and org-startup-indented Julien Danjou
2010-10-17  6:08 ` Carsten Dominik
2010-10-18 14:37   ` Julien Danjou [this message]
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:38           ` Andreas Röhler
2010-10-20 15:58           ` [Orgmode] " 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sa3bp6r1s9z.fsf@cigue.easter-eggs.fr \
    --to=julien@danjou.info \
    --cc=carsten.dominik@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).