diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2020-05-31 13:55:47 +0200 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2020-05-31 13:55:47 +0200 |
commit | 65fdf2be16c82df78fe533a022e1e233ae66d7a8 (patch) | |
tree | 1e8c521eb5ccc95718b5970974ec74fad23e02b0 | |
parent | f5997d5956a584edae16aa5136d7c4c2466529ec (diff) | |
download | org-mode-65fdf2be16c82df78fe533a022e1e233ae66d7a8.tar.gz |
Fix `org-mark-element' in narrowed buffers
* lisp/org.el (org-mark-element): Do not set mark past narrowed part
of the buffer.
* testing/lisp/test-org.el (test-org/mark-element): New test.
Reported-by: Kevin Liu <kevin@nivekuil.com>
<http://lists.gnu.org/r/emacs-orgmode/2020-05/msg00812.html>
-rw-r--r-- | lisp/org.el | 5 | ||||
-rw-r--r-- | testing/lisp/test-org.el | 21 |
2 files changed, 24 insertions, 2 deletions
diff --git a/lisp/org.el b/lisp/org.el index 4d1a6a6..4135ae2 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -21150,10 +21150,11 @@ ones already marked." (set-mark (save-excursion (goto-char (mark)) - (goto-char (org-element-property :end (org-element-at-point))))) + (goto-char (org-element-property :end (org-element-at-point))) + (point))) (let ((element (org-element-at-point))) (end-of-line) - (push-mark (org-element-property :end element) t t) + (push-mark (min (point-max) (org-element-property :end element)) t t) (goto-char (org-element-property :begin element)))))) (defun org-narrow-to-element () diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 29ac0a8..67137c9 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -2581,6 +2581,27 @@ Foo Bar ;;; Mark Region +(ert-deftest test-org/mark-element () + "Test `org-mark-element' specifications." + ;; Mark beginning and end of element. + (should + (equal '(t t) + (org-test-with-temp-text "Para<point>graph" + (org-mark-element) + (list (bobp) (= (mark) (point-max)))))) + (should + (equal '(t t) + (org-test-with-temp-text "P1\n\nPara<point>graph\n\nP2" + (org-mark-element) + (list (looking-at "Paragraph") + (org-with-point-at (mark) (looking-at "P2")))))) + ;; Do not set mark past (point-max). + (should + (org-test-with-temp-text "Para<point>graph" + (narrow-to-region 2 6) + (org-mark-element) + (= 6 (mark))))) + (ert-deftest test-org/mark-subtree () "Test `org-mark-subtree' specifications." ;; Error when point is before first headline. |