emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] [BUG] org.el: Fix first call of `org-paste-subtree'


From: Max Nikulin
Subject: [PATCH] [BUG] org.el: Fix first call of `org-paste-subtree'
Date: Mon, 29 Nov 2021 19:02:35 +0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0

An old bug is living in Org.

=C-c C-x C-y= ~org-paste-subtree~ fails just after Emacs start.
Maybe there are more similar issues.

- Start *new* instance of emacs.
- Copy some text that is Org subtree from some
  *external* application (not Emacs).
  I usually come across this issue when I copy capture
  from my Firefox extension. Alternative:
  #+begin_src elisp :results silent
    (require 'ob-shell)
  #+end_src

  #+begin_src bash :results silent
    printf '%b' '* Heading\n\nbody\n' |
      xclip -in -selection clipborad >/dev/null
      # xsel --input --clipboard
  #+end_src

- Try =C-c C-x C-y= or [[elisp:(org-paste-subtree)]]

  + Actual result is the following message:
: user-error: The kill is not a (set of) tree(s). Use ‘C-y’ to yank anyway
  + Expected result is a heading pasted at the end of the buffer.
+ The result may be achieved by calling [[elisp:(org-paste-subtree)]] once more.

- The problem is ~(and kill-ring (current-kill 0))~ expression
  in the definition of ~org-paste-subtree~.
  Restart emacs and repeat steps above skipping ~org-paste-subtree~.
  Notice that ~(current-kill 0)~ call changes value of ~kill-ring~.
  #+begin_src elisp :results pp
    (list (and kill-ring t) (current-kill 0) (and kill-ring t))
  #+end_src

  #+RESULTS:
  : (nil "* Heading\n\nbody\n" t)

I suppose, it is better to let the error from ~current-kill~ to propagate (in the case of empty `kill-ring' and clipboard). I do not have Windows machine available to test the change.

There is another occurence of ~(and (current-kill 0))~
in ~org-kill-is-subtree-p~. I would rather transform it
to ~org~subtree-p~ to avoid call of ~current-kill~ inside, but this patch does not include such change.

Attachment: 0001-org.el-Fix-first-call-of-org-paste-subtree.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]