[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Outline cycling does not preserve point's position
From: |
Nicolas Goaziou |
Subject: |
Re: [O] Outline cycling does not preserve point's position |
Date: |
Wed, 11 Sep 2013 13:09:48 +0200 |
Hello,
Jambunathan K <address@hidden> writes:
> Some suggestions:
>
> 1. Give a better name. Say "pre-order" traversal of element in the
> parse tree. [1]
I don't know what "pre-order" means. What about
`org-flat-forward-element' or simply (but misleading) `org-forward-paragraph'?
> 3. When you say "Shouldn't be here", it means that point is NOT at the
> canonical C-down position. But you do seem to "adjust" it to the
> canonical position down below.
>
> May be you want to remove it or say something more positive like - In
> the middle of nowhere. Trying to get to the assembly point.
I don't understand. Are you talking about the error message? There is no
"canonical" C-down position, so I'm a bit confused.
>> New version:
>
> Couple of issues.
>
> 1. Visit the attached file. Make sure everything is visible.
> 2. M-<
> 3. C-down gives a stacktrace. See below.
Fixed.
> 1. Move to bol of the empty line that is in <<<Radioed Target>>> section.
> That
> is not an empty line but has spaces.
>
> 2. C-down
>
> 3. Cursor does NOT do a stop over at "References" headline but skips
> past to References to Fuzzy Target
That was a bug in `org-element-at-point', which is now fixed. Thank you.
You'll need to update Org.
New version, with comments and docstring:
(defun org-forward-linear-element ()
"Move forward to next element, ignoring depth.
The function implements some special moves for convenience:
- On an affiliated keyword, jump to the beginning of the
relative element.
- On an item or a footnote definition, move to the second
element inside, if any.
- On a table, jump after it.
- On a verse block, stop after each blank line."
(interactive)
(when (eobp) (user-error "Cannot move further down"))
(let* ((origin (point))
(element (org-element-at-point))
(type (org-element-type element))
(post-affiliated (org-element-property :post-affiliated element))
(contents-begin (org-element-property :contents-begin element))
(contents-end (org-element-property :contents-end element))
(end (let ((end (org-element-property :end element)) (parent element))
(while (and (setq parent (org-element-property :parent parent))
(= (org-element-property :contents-end parent) end))
(setq end (org-element-property :end parent)))
end)))
(skip-chars-forward " \r\t\n")
(or (eobp) (goto-char (max (line-beginning-position) origin)))
(cond ((or (eobp) (not end) (= (point) end)))
;; On affiliated keywords, move to element's beginning.
((and post-affiliated (< (point) post-affiliated))
(goto-char post-affiliated))
;; At a table row, move to the end of the table.
((eq type 'table-row)
(goto-char (org-element-property
:end (org-element-property :parent element))))
((eq type 'table) (goto-char end))
((not contents-begin) (goto-char end))
;; If current element contents are invisible, skip the
;; element.
((outline-invisible-p (line-end-position))
(if (not (eq type 'plain-list)) (goto-char end)
;; At a plain list, make sure we move to the next item
;; instead of skipping the whole list.
(forward-char)
(org-forward-linear-element)))
((< (point) contents-begin)
(if (not (memq type '(footnote-definition item)))
(goto-char contents-begin)
;; At footnote definitions and items, move to second
;; element, if any, or to next element otherwise.
(end-of-line)
(org-forward-linear-element)))
((>= (point) contents-end) (goto-char end))
((eq type 'paragraph) (goto-char end))
((eq type 'plain-list)
(end-of-line)
(org-forward-linear-element))
;; Verse blocks cannot contain paragraphs. Though, we
;; emulate them with blank lines separators to ease
;; editing.
((eq type 'verse-block)
(or (re-search-forward "^[ \t]*$" contents-end t)
(goto-char end)))
(t (error "This shouldn't happen")))))
Regards,
--
Nicolas Goaziou
- Re: [O] Outline cycling does not preserve point's position, (continued)
- Re: [O] Outline cycling does not preserve point's position, Carsten Dominik, 2013/09/10
- Re: [O] Outline cycling does not preserve point's position, Suvayu Ali, 2013/09/11
- Re: [O] Outline cycling does not preserve point's position, Jambunathan K, 2013/09/12
- Re: [O] Outline cycling does not preserve point's position, Nicolas Goaziou, 2013/09/12
- Re: [O] Outline cycling does not preserve point's position, Jambunathan K, 2013/09/12
- Re: [O] Outline cycling does not preserve point's position, Suvayu Ali, 2013/09/12
- Re: [O] Outline cycling does not preserve point's position, Jambunathan K, 2013/09/12
- Re: [O] Outline cycling does not preserve point's position,
Nicolas Goaziou <=
- Re: [O] Outline cycling does not preserve point's position, Jambunathan K, 2013/09/12
- Re: [O] Outline cycling does not preserve point's position, Nicolas Goaziou, 2013/09/11
- Re: [O] Outline cycling does not preserve point's position, Jambunathan K, 2013/09/12
- Re: [O] Outline cycling does not preserve point's position, Jambunathan K, 2013/09/12
- Re: [O] Outline cycling does not preserve point's position, Nicolas Goaziou, 2013/09/11
- Re: [O] Outline cycling does not preserve point's position, Jambunathan K, 2013/09/12
- Re: [O] Outline cycling does not preserve point's position, Nicolas Goaziou, 2013/09/11
- Re: [O] Outline cycling does not preserve point's position, Suvayu Ali, 2013/09/11
- Re: [O] Outline cycling does not preserve point's position, Sebastien Vauban, 2013/09/12
- Re: [O] Outline cycling does not preserve point's position, Jambunathan K, 2013/09/12