emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-element-drag-* broken
@ 2012-07-04 10:36 suvayu ali
  2012-07-04 15:56 ` Nicolas Goaziou
  0 siblings, 1 reply; 5+ messages in thread
From: suvayu ali @ 2012-07-04 10:36 UTC (permalink / raw)
  To: org-mode mailing list; +Cc: Nicolas Goaziou

Hi Nicolas,

I have been trying out the `org-element-drag-backward' and
`org-element-drag-forward' navigation commands. I believe they stopped
working yesterday when I updated my org-mode (Git: dab2505 -> a69f4b8).

When I try to move list items, I get the backtrace shown below. FWIW,
promotion and demotion works.

I hope this helps.


Debugger entered--Lisp error: (error "Cannot swap elements")
  signal(error ("Cannot swap elements"))
  error("Cannot swap elements")
  (if (and specialp (or (not (eq (org-element-type elem-B) (quote
paragraph))) (/= (org-element-property :begin elem-B)
(org-element-property :contents-begin elem-B)))) (error "Cannot swap
elements"))
  (let ((specialp (not (bolp)))) (if (and specialp (or (not (eq
(org-element-type elem-B) (quote paragraph))) (/=
(org-element-property :begin elem-B) (org-element-property
:contents-begin elem-B)))) (error "Cannot swap elements")) (let*
((ind-B (when specialp (goto-char (org-element-property :begin
elem-B)) (org-get-indentation))) (beg-A (org-element-property :begin
elem-A)) (end-A (save-excursion (goto-char (org-element-property :end
elem-A)) (skip-chars-backward "
	\n") (point-at-eol))) (beg-B (org-element-property :begin elem-B))
(end-B (save-excursion (goto-char (org-element-property :end elem-B))
(skip-chars-backward "
	\n") (point-at-eol))) (overlays (cons (mapcar (lambda (ov) (list ov
... ...)) (overlays-in beg-A end-A)) (mapcar (lambda (ov) (list ov ...
...)) (overlays-in beg-B end-B)))) (body-A (buffer-substring beg-A
end-A)) (body-B (delete-and-extract-region beg-B end-B))) (goto-char
beg-B) (when specialp (setq body-B (replace-regexp-in-string "\\`[
	]*" "" body-B)) (org-indent-to-column ind-B)) (insert body-A) (mapc
(lambda (ov) (move-overlay (car ov) (+ (nth 1 ov) (- beg-B beg-A)) (+
(nth 2 ov) (- beg-B beg-A)))) (car overlays)) (goto-char beg-A)
(delete-region beg-A end-A) (insert body-B) (mapc (lambda (ov)
(move-overlay (car ov) (+ (nth 1 ov) (- beg-A beg-B)) (+ (nth 2 ov) (-
beg-A beg-B)))) (cdr overlays)) (goto-char (org-element-property :end
elem-B))))
  org-element-swap-A-B((paragraph (:begin 1258 :end 1268
:contents-begin 1258 :contents-end 1267 :post-blank 0)) (item (:bullet
"- " :begin 1268 :end 1298 :contents-begin 1270 :contents-end 1298
:checkbox nil :counter nil :tag nil :hiddenp nil :structure ((1256 0
"- " nil nil nil 1268) (1268 0 "- " nil nil nil 1298) (1298 0 "- " nil
nil nil 1307) (1307 0 "- " nil nil nil 1335) (1335 0 "- " nil nil nil
1344)) :post-blank 0)))
  (let ((size-next (- (save-excursion (goto-char (org-element-property
:end next-elem)) (skip-chars-backward "
	\n") (forward-line) (if (and (eolp) (not ...)) (1+ (point)) (point)))
(org-element-property :begin next-elem))) (size-blank (-
(org-element-property :end elem) (save-excursion (goto-char
(org-element-property :end elem)) (skip-chars-backward "
	\n") (forward-line) (point))))) (org-element-swap-A-B elem next-elem)
(goto-char (+ pos size-next size-blank)))
  (let ((next-elem (org-element-at-point))) (when (or
(org-element-nested-p elem next-elem) (and (eq (org-element-type
next-elem) (quote headline)) (not (eq (org-element-type elem) (quote
headline))))) (goto-char pos) (error "Cannot drag element forward"))
(let ((size-next (- (save-excursion (goto-char (org-element-property
:end next-elem)) (skip-chars-backward "
	\n") (forward-line) (if (and ... ...) (1+ ...) (point)))
(org-element-property :begin next-elem))) (size-blank (-
(org-element-property :end elem) (save-excursion (goto-char
(org-element-property :end elem)) (skip-chars-backward "
	\n") (forward-line) (point))))) (org-element-swap-A-B elem next-elem)
(goto-char (+ pos size-next size-blank))))
  (let* ((pos (point)) (elem (org-element-at-point))) (when (=
(point-max) (org-element-property :end elem)) (error "Cannot drag
element forward")) (goto-char (org-element-property :end elem)) (let
((next-elem (org-element-at-point))) (when (or (org-element-nested-p
elem next-elem) (and (eq (org-element-type next-elem) (quote
headline)) (not (eq (org-element-type elem) (quote headline)))))
(goto-char pos) (error "Cannot drag element forward")) (let
((size-next (- (save-excursion (goto-char ...) (skip-chars-backward "
	\n") (forward-line) (if ... ... ...)) (org-element-property :begin
next-elem))) (size-blank (- (org-element-property :end elem)
(save-excursion (goto-char ...) (skip-chars-backward "
	\n") (forward-line) (point))))) (org-element-swap-A-B elem next-elem)
(goto-char (+ pos size-next size-blank)))))
  org-metadown()
  call-interactively(org-metadown nil nil)


-- 
Suvayu

Open source is the future. It sets us free.

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

* Re: org-element-drag-* broken
  2012-07-04 10:36 org-element-drag-* broken suvayu ali
@ 2012-07-04 15:56 ` Nicolas Goaziou
  2012-07-04 16:13   ` suvayu ali
  0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Goaziou @ 2012-07-04 15:56 UTC (permalink / raw)
  To: suvayu ali; +Cc: org-mode mailing list

Hello,

suvayu ali <fatkasuvayu+linux@gmail.com> writes:

> I have been trying out the `org-element-drag-backward' and
> `org-element-drag-forward' navigation commands. I believe they stopped
> working yesterday when I updated my org-mode (Git: dab2505 -> a69f4b8).
>
> When I try to move list items, I get the backtrace shown below. FWIW,
> promotion and demotion works.

Could you provide an ECM? I cannot reproduce the problem.

Also, is the move that you're trying to achieve allowed?


Regards,

-- 
Nicolas Goaziou

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

* Re: org-element-drag-* broken
  2012-07-04 15:56 ` Nicolas Goaziou
@ 2012-07-04 16:13   ` suvayu ali
  2012-07-04 16:22     ` Nicolas Goaziou
  0 siblings, 1 reply; 5+ messages in thread
From: suvayu ali @ 2012-07-04 16:13 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: org-mode mailing list

[-- Attachment #1: Type: text/plain, Size: 533 bytes --]

On Wed, Jul 4, 2012 at 5:56 PM, Nicolas Goaziou <n.goaziou@gmail.com> wrote:
> Could you provide an ECM? I cannot reproduce the problem.
>
> Also, is the move that you're trying to achieve allowed?

Yes the move is allowed. I can reproduce the problem with the attached
ECM. Evaluate the lisp block in a minimal Emacs session and try to
reorder the list below with M-<up/down>.

PS: Sorry for the weird filename. Without the txt, Gmail screws up the
    attachment MIME type.

-- 
Suvayu

Open source is the future. It sets us free.

[-- Attachment #2: org-element-ecm.org.txt --]
[-- Type: text/plain, Size: 297 bytes --]

# -*- mode: org; -*-

* Setup
#+BEGIN_SRC emacs-lisp :results silent
  (load-library "org-export")
  (defalias 'org-metaup 'org-element-drag-backward)
  (defalias 'org-metadown 'org-element-drag-forward)
#+END_SRC

* Comparisons
Some text
1. list item
2. some emphasized text
3. another list item

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

* Re: org-element-drag-* broken
  2012-07-04 16:13   ` suvayu ali
@ 2012-07-04 16:22     ` Nicolas Goaziou
  2012-07-04 16:28       ` suvayu ali
  0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Goaziou @ 2012-07-04 16:22 UTC (permalink / raw)
  To: suvayu ali; +Cc: org-mode mailing list

Hello,

suvayu ali <fatkasuvayu+linux@gmail.com> writes:

> Yes the move is allowed. I can reproduce the problem with the attached
> ECM. Evaluate the lisp block in a minimal Emacs session and try to
> reorder the list below with M-<up/down>.

I see. This behaviour is documented in `org-element-at-point' docstring:

--8<---------------cut here---------------start------------->8---
As a special case, if point is at the very beginning of a list or
sub-list, returned element will be that list instead of the first
item.  In the same way, if point is at the beginning of the first
row of a table, returned element will be the table instead of the
first row.
--8<---------------cut here---------------end--------------->8---

It means that if point is at the very beginning of the list, it will try
to move the whole list. Since there is nothing after the list, it
returns an error.

In order to drag the first item, you have to move one character forward,
or use `org-element-down' in order to "enter" the list.


Regards,

-- 
Nicolas Goaziou

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

* Re: org-element-drag-* broken
  2012-07-04 16:22     ` Nicolas Goaziou
@ 2012-07-04 16:28       ` suvayu ali
  0 siblings, 0 replies; 5+ messages in thread
From: suvayu ali @ 2012-07-04 16:28 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: org-mode mailing list

Hi Nicolas,

On Wed, Jul 4, 2012 at 6:22 PM, Nicolas Goaziou <n.goaziou@gmail.com> wrote:
> It means that if point is at the very beginning of the list, it will try
> to move the whole list. Since there is nothing after the list, it
> returns an error.
>
> In order to drag the first item, you have to move one character forward,
> or use `org-element-down' in order to "enter" the list.

Ah! A very subtle effect; I have to apologise I hadn't gone through
the docs, sorry.

Cheers,

-- 
Suvayu

Open source is the future. It sets us free.

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

end of thread, other threads:[~2012-07-04 16:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-04 10:36 org-element-drag-* broken suvayu ali
2012-07-04 15:56 ` Nicolas Goaziou
2012-07-04 16:13   ` suvayu ali
2012-07-04 16:22     ` Nicolas Goaziou
2012-07-04 16:28       ` suvayu ali

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