`org-forward/backward-paragraph' do not error at buffer boundaries
* lisp/org.el (org-forward-paragraph): (org-backward-paragraph): Do not error at buffer boundaries. Reported-by: Omar Antolín Camarena <omar.antolin@gmail.com> <http://lists.gnu.org/archive/html/emacs-orgmode/2017-07/msg00478.html>
This commit is contained in:
parent
f203d378bd
commit
808089ee04
|
@ -24432,7 +24432,7 @@ item, etc. It also provides some special moves for convenience:
|
|||
- On a table or a property drawer, jump after it.
|
||||
- On a verse or source block, stop after blank lines."
|
||||
(interactive)
|
||||
(when (eobp) (user-error "Cannot move further down"))
|
||||
(unless (eobp)
|
||||
(let* ((deactivate-mark nil)
|
||||
(element (org-element-at-point))
|
||||
(type (org-element-type element))
|
||||
|
@ -24499,7 +24499,7 @@ item, etc. It also provides some special moves for convenience:
|
|||
((> (line-end-position) contents-begin)
|
||||
(end-of-line)
|
||||
(org-forward-paragraph))
|
||||
(t (goto-char contents-begin)))))
|
||||
(t (goto-char contents-begin))))))
|
||||
|
||||
(defun org-backward-paragraph ()
|
||||
"Move backward to start of previous paragraph or equivalent.
|
||||
|
@ -24514,7 +24514,7 @@ convenience:
|
|||
- On a table or a property drawer, move to its beginning.
|
||||
- On a verse or source block, stop before blank lines."
|
||||
(interactive)
|
||||
(when (bobp) (user-error "Cannot move further up"))
|
||||
(unless (bobp)
|
||||
(let* ((deactivate-mark nil)
|
||||
(element (org-element-at-point))
|
||||
(type (org-element-type element))
|
||||
|
@ -24562,7 +24562,7 @@ convenience:
|
|||
(org-backward-paragraph))
|
||||
(t (goto-char (or post-affiliated begin))))
|
||||
;; Ensure we never leave point invisible.
|
||||
(when (org-invisible-p (point)) (beginning-of-visual-line))))
|
||||
(when (org-invisible-p (point)) (beginning-of-visual-line)))))
|
||||
|
||||
(defun org-forward-element ()
|
||||
"Move forward by one element.
|
||||
|
|
|
@ -3259,11 +3259,12 @@ SCHEDULED: <2017-05-06 Sat>
|
|||
|
||||
(ert-deftest test-org/forward-paragraph ()
|
||||
"Test `org-forward-paragraph' specifications."
|
||||
;; At end of buffer, return an error.
|
||||
(should-error
|
||||
;; At end of buffer, do not return an error.
|
||||
(should
|
||||
(org-test-with-temp-text "Paragraph"
|
||||
(goto-char (point-max))
|
||||
(org-forward-paragraph)))
|
||||
(org-forward-paragraph)
|
||||
t))
|
||||
;; Standard test.
|
||||
(should
|
||||
(org-test-with-temp-text "P1\n\nP2\n\nP3"
|
||||
|
@ -3328,10 +3329,11 @@ SCHEDULED: <2017-05-06 Sat>
|
|||
|
||||
(ert-deftest test-org/backward-paragraph ()
|
||||
"Test `org-backward-paragraph' specifications."
|
||||
;; Error at beginning of buffer.
|
||||
(should-error
|
||||
;; Do not error at beginning of buffer.
|
||||
(should
|
||||
(org-test-with-temp-text "Paragraph"
|
||||
(org-backward-paragraph)))
|
||||
(org-backward-paragraph)
|
||||
t))
|
||||
;; Regular test.
|
||||
(should
|
||||
(org-test-with-temp-text "P1\n\nP2\n\nP3"
|
||||
|
|
Loading…
Reference in New Issue