mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-08-25 10:02:52 +00:00
org-beginning/end-of-line: Fix when moving to different line
* lisp/org.el (org-beginning-of-line, org-end-of-line): Fix issue with `org-special-ctrl-a/e' not working correctly when moving to different line. * testing/lisp/test-org.el (test-org/beginning-of-line, test-org/end-of-line): Add new tests.
This commit is contained in:
parent
bf7a0cdcef
commit
93ebd64de1
|
@ -19986,7 +19986,7 @@ With argument N not nil or 1, move forward N - 1 lines first."
|
||||||
(if (eq special 'reversed)
|
(if (eq special 'reversed)
|
||||||
(when (and (= origin bol) (eq last-command this-command))
|
(when (and (= origin bol) (eq last-command this-command))
|
||||||
(goto-char refpos))
|
(goto-char refpos))
|
||||||
(when (or (> origin refpos) (= origin bol))
|
(when (or (> origin refpos) (<= origin bol))
|
||||||
(goto-char refpos)))))
|
(goto-char refpos)))))
|
||||||
((and (looking-at org-list-full-item-re)
|
((and (looking-at org-list-full-item-re)
|
||||||
(memq (org-element-type (save-match-data (org-element-at-point)))
|
(memq (org-element-type (save-match-data (org-element-at-point)))
|
||||||
|
@ -20001,7 +20001,7 @@ With argument N not nil or 1, move forward N - 1 lines first."
|
||||||
(if (eq special 'reversed)
|
(if (eq special 'reversed)
|
||||||
(when (and (= (point) origin) (eq last-command this-command))
|
(when (and (= (point) origin) (eq last-command this-command))
|
||||||
(goto-char after-bullet))
|
(goto-char after-bullet))
|
||||||
(when (or (> origin after-bullet) (= (point) origin))
|
(when (or (> origin after-bullet) (>= (point) origin))
|
||||||
(goto-char after-bullet)))))
|
(goto-char after-bullet)))))
|
||||||
;; No special context. Point is already at beginning of line.
|
;; No special context. Point is already at beginning of line.
|
||||||
(t nil))))
|
(t nil))))
|
||||||
|
@ -20056,7 +20056,7 @@ With argument N not nil or 1, move forward N - 1 lines first."
|
||||||
(goto-char tags)
|
(goto-char tags)
|
||||||
(end-of-line)))
|
(end-of-line)))
|
||||||
(t
|
(t
|
||||||
(if (or (< origin tags) (= origin (line-end-position)))
|
(if (or (< origin tags) (>= origin (line-end-position)))
|
||||||
(goto-char tags)
|
(goto-char tags)
|
||||||
(end-of-line))))))
|
(end-of-line))))))
|
||||||
((bound-and-true-p visual-line-mode)
|
((bound-and-true-p visual-line-mode)
|
||||||
|
|
|
@ -4036,6 +4036,16 @@ text"
|
||||||
(let ((org-special-ctrl-a/e '(nil . nil)))
|
(let ((org-special-ctrl-a/e '(nil . nil)))
|
||||||
(org-beginning-of-line)
|
(org-beginning-of-line)
|
||||||
(looking-at "Headline"))))
|
(looking-at "Headline"))))
|
||||||
|
(should
|
||||||
|
(org-test-with-temp-text "* TODO [#A] Headline\n<point>"
|
||||||
|
(let ((org-special-ctrl-a/e t))
|
||||||
|
(org-beginning-of-line 0)
|
||||||
|
(looking-at-p "Headline"))))
|
||||||
|
(should
|
||||||
|
(org-test-with-temp-text "<point>\n* TODO [#A] Headline"
|
||||||
|
(let ((org-special-ctrl-a/e t))
|
||||||
|
(org-beginning-of-line 2)
|
||||||
|
(looking-at-p "Headline"))))
|
||||||
;; At an headline with reversed movement, first move to beginning of
|
;; At an headline with reversed movement, first move to beginning of
|
||||||
;; line, then to the beginning of title.
|
;; line, then to the beginning of title.
|
||||||
(should
|
(should
|
||||||
|
@ -4056,6 +4066,18 @@ text"
|
||||||
(this-command last-command))
|
(this-command last-command))
|
||||||
(and (progn (org-beginning-of-line) (bolp))
|
(and (progn (org-beginning-of-line) (bolp))
|
||||||
(progn (org-beginning-of-line) (looking-at-p "Headline"))))))
|
(progn (org-beginning-of-line) (looking-at-p "Headline"))))))
|
||||||
|
(should
|
||||||
|
(org-test-with-temp-text "* TODO Headline\n<point>"
|
||||||
|
(let ((org-special-ctrl-a/e 'reversed)
|
||||||
|
(this-command last-command))
|
||||||
|
(and (progn (org-beginning-of-line 0) (bolp))
|
||||||
|
(progn (org-beginning-of-line) (looking-at-p "Headline"))))))
|
||||||
|
(should
|
||||||
|
(org-test-with-temp-text "<point>\n* TODO Headline"
|
||||||
|
(let ((org-special-ctrl-a/e 'reversed)
|
||||||
|
(this-command last-command))
|
||||||
|
(and (progn (org-beginning-of-line 2) (bolp))
|
||||||
|
(progn (org-beginning-of-line) (looking-at-p "Headline"))))))
|
||||||
;; At an item with special movement, first move after to beginning
|
;; At an item with special movement, first move after to beginning
|
||||||
;; of title, then to the beginning of line, rinse, repeat.
|
;; of title, then to the beginning of line, rinse, repeat.
|
||||||
(should
|
(should
|
||||||
|
@ -4064,6 +4086,14 @@ text"
|
||||||
(and (progn (org-beginning-of-line) (looking-at-p "Item"))
|
(and (progn (org-beginning-of-line) (looking-at-p "Item"))
|
||||||
(progn (org-beginning-of-line) (bolp))
|
(progn (org-beginning-of-line) (bolp))
|
||||||
(progn (org-beginning-of-line) (looking-at-p "Item"))))))
|
(progn (org-beginning-of-line) (looking-at-p "Item"))))))
|
||||||
|
(should
|
||||||
|
(org-test-with-temp-text "- [ ] Item\n<point>"
|
||||||
|
(let ((org-special-ctrl-a/e t))
|
||||||
|
(org-beginning-of-line 0) (looking-at-p "Item"))))
|
||||||
|
(should
|
||||||
|
(org-test-with-temp-text "<point>\n- [ ] Item"
|
||||||
|
(let ((org-special-ctrl-a/e t))
|
||||||
|
(org-beginning-of-line 2) (looking-at-p "Item"))))
|
||||||
;; At an item with reversed movement, first move to beginning of
|
;; At an item with reversed movement, first move to beginning of
|
||||||
;; line, then to the beginning of title.
|
;; line, then to the beginning of title.
|
||||||
(should
|
(should
|
||||||
|
@ -4072,6 +4102,18 @@ text"
|
||||||
(this-command last-command))
|
(this-command last-command))
|
||||||
(and (progn (org-beginning-of-line) (bolp))
|
(and (progn (org-beginning-of-line) (bolp))
|
||||||
(progn (org-beginning-of-line) (looking-at-p "Item"))))))
|
(progn (org-beginning-of-line) (looking-at-p "Item"))))))
|
||||||
|
(should
|
||||||
|
(org-test-with-temp-text "- [X] Item\n<point>"
|
||||||
|
(let ((org-special-ctrl-a/e 'reversed)
|
||||||
|
(this-command last-command))
|
||||||
|
(and (progn (org-beginning-of-line 0) (bolp))
|
||||||
|
(progn (org-beginning-of-line) (looking-at-p "Item"))))))
|
||||||
|
(should
|
||||||
|
(org-test-with-temp-text "<point>\n- [X] Item"
|
||||||
|
(let ((org-special-ctrl-a/e 'reversed)
|
||||||
|
(this-command last-command))
|
||||||
|
(and (progn (org-beginning-of-line 2) (bolp))
|
||||||
|
(progn (org-beginning-of-line) (looking-at-p "Item"))))))
|
||||||
;; Leave point before invisible characters at column 0.
|
;; Leave point before invisible characters at column 0.
|
||||||
(should
|
(should
|
||||||
(org-test-with-temp-text "[[https://orgmode.org]]<point>"
|
(org-test-with-temp-text "[[https://orgmode.org]]<point>"
|
||||||
|
@ -4174,6 +4216,14 @@ text"
|
||||||
(and (progn (org-end-of-line) (looking-at-p " :tag:"))
|
(and (progn (org-end-of-line) (looking-at-p " :tag:"))
|
||||||
(progn (org-end-of-line) (eolp))
|
(progn (org-end-of-line) (eolp))
|
||||||
(progn (org-end-of-line) (looking-at-p " :tag:"))))))
|
(progn (org-end-of-line) (looking-at-p " :tag:"))))))
|
||||||
|
(should
|
||||||
|
(org-test-with-temp-text "* Headline1 :tag:\n<point>"
|
||||||
|
(let ((org-special-ctrl-a/e t))
|
||||||
|
(org-end-of-line 0) (looking-at-p " :tag:"))))
|
||||||
|
(should
|
||||||
|
(org-test-with-temp-text "<point>\n* Headline1 :tag:\n"
|
||||||
|
(let ((org-special-ctrl-a/e t))
|
||||||
|
(org-end-of-line 2) (looking-at-p " :tag:"))))
|
||||||
(should
|
(should
|
||||||
(org-test-with-temp-text "* Headline2a :tag:\n** Sub"
|
(org-test-with-temp-text "* Headline2a :tag:\n** Sub"
|
||||||
(org-overview)
|
(org-overview)
|
||||||
|
@ -4201,6 +4251,18 @@ text"
|
||||||
(this-command last-command))
|
(this-command last-command))
|
||||||
(and (progn (org-end-of-line) (eolp))
|
(and (progn (org-end-of-line) (eolp))
|
||||||
(progn (org-end-of-line) (looking-at-p " :tag:"))))))
|
(progn (org-end-of-line) (looking-at-p " :tag:"))))))
|
||||||
|
(should
|
||||||
|
(org-test-with-temp-text "* Headline3 :tag:\n<point>"
|
||||||
|
(let ((org-special-ctrl-a/e 'reversed)
|
||||||
|
(this-command last-command))
|
||||||
|
(and (progn (org-end-of-line 0) (eolp))
|
||||||
|
(progn (org-end-of-line) (looking-at-p " :tag:"))))))
|
||||||
|
(should
|
||||||
|
(org-test-with-temp-text "<point>\n* Headline3 :tag:\n"
|
||||||
|
(let ((org-special-ctrl-a/e 'reversed)
|
||||||
|
(this-command last-command))
|
||||||
|
(and (progn (org-end-of-line 2) (eolp))
|
||||||
|
(progn (org-end-of-line) (looking-at-p " :tag:"))))))
|
||||||
(should
|
(should
|
||||||
(org-test-with-temp-text "* Headline2a :tag:\n** Sub"
|
(org-test-with-temp-text "* Headline2a :tag:\n** Sub"
|
||||||
(org-overview)
|
(org-overview)
|
||||||
|
|
Loading…
Reference in a new issue