Fix `org-next-visible-heading'
* lisp/org.el (org-next-visible-heading): Fix function when `org-cycle-separator-lines' is different from 0. * testing/lisp/test-org.el (test-org/next-visible-heading): New test.
This commit is contained in:
parent
3b2de48989
commit
1596113512
|
@ -20482,15 +20482,16 @@ With ARG, repeats or can move backward if negative."
|
|||
(beginning-of-line))
|
||||
(_ nil)))
|
||||
(cl-incf arg))
|
||||
(while (and (> arg 0) (re-search-forward regexp nil :move))
|
||||
(while (and (> arg 0) (re-search-forward regexp nil t))
|
||||
(pcase (get-char-property-and-overlay (point) 'invisible)
|
||||
(`(outline . ,o)
|
||||
(goto-char (overlay-end o))
|
||||
(end-of-line 2))
|
||||
(skip-chars-forward " \t\n")
|
||||
(end-of-line))
|
||||
(_
|
||||
(end-of-line)))
|
||||
(cl-decf arg))
|
||||
(when (/= arg initial-arg) (beginning-of-line))))
|
||||
(if (> arg 0) (goto-char (point-max)) (beginning-of-line))))
|
||||
|
||||
(defun org-previous-visible-heading (arg)
|
||||
"Move to the previous visible heading.
|
||||
|
|
|
@ -3114,6 +3114,54 @@ SCHEDULED: <2017-05-06 Sat>
|
|||
|
||||
;;; Navigation
|
||||
|
||||
(ert-deftest test-org/next-visible-heading ()
|
||||
"Test `org-next-visible-heading' specifications."
|
||||
;; Move to the beginning of the next headline, taking into
|
||||
;; consideration ARG.
|
||||
(should
|
||||
(org-test-with-temp-text "* H1\n* H2"
|
||||
(org-next-visible-heading 1)
|
||||
(looking-at "\\* H2")))
|
||||
(should
|
||||
(org-test-with-temp-text "* H1\n* H2\n* H3"
|
||||
(org-next-visible-heading 2)
|
||||
(looking-at "\\* H3")))
|
||||
;; Ignore invisible headlines.
|
||||
(should
|
||||
(org-test-with-temp-text "* H1\n** H2\n* H3"
|
||||
(org-cycle)
|
||||
(org-next-visible-heading 1)
|
||||
(looking-at "\\* H3")))
|
||||
(should
|
||||
(org-test-with-temp-text "* H1\n* H2\n* H3"
|
||||
(org-next-visible-heading 1)
|
||||
(looking-at "\\* H2")))
|
||||
;; Move point between headlines, not on blank lines between.
|
||||
(should
|
||||
(org-test-with-temp-text "* H1\n** H2\n\n\n\n* H3"
|
||||
(let ((org-cycle-separator-lines 1))
|
||||
(org-cycle)
|
||||
(org-next-visible-heading 1))
|
||||
(looking-at "\\* H3")))
|
||||
;; Move at end of buffer when there is no more headline.
|
||||
(should
|
||||
(org-test-with-temp-text "* H1"
|
||||
(org-next-visible-heading 1)
|
||||
(eobp)))
|
||||
(should
|
||||
(org-test-with-temp-text "* H1\n* H2"
|
||||
(org-next-visible-heading 2)
|
||||
(eobp)))
|
||||
;; With a negative argument, move backwards.
|
||||
(should
|
||||
(org-test-with-temp-text "* H1\n* H2\n<point>* H3"
|
||||
(org-next-visible-heading -1)
|
||||
(looking-at "\\* H2")))
|
||||
(should
|
||||
(org-test-with-temp-text "* H1\n* H2\n<point>* H3"
|
||||
(org-next-visible-heading -2)
|
||||
(looking-at "\\* H1"))))
|
||||
|
||||
(ert-deftest test-org/forward-heading-same-level ()
|
||||
"Test `org-forward-heading-same-level' specifications."
|
||||
;; Test navigation at top level, forward and backward.
|
||||
|
|
Loading…
Reference in New Issue