From e4b35b34e82f264e98a72409c643d842e75fc586 Mon Sep 17 00:00:00 2001 From: Damien Cassou Date: Fri, 19 Mar 2021 11:14:10 +0100 Subject: * tests/nroam-test.el: Fix typo. --- tests/nroam-test.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/nroam-test.el b/tests/nroam-test.el index 63e5b8a..f75a7bb 100644 --- a/tests/nroam-test.el +++ b/tests/nroam-test.el @@ -40,7 +40,7 @@ Execute BODY and cleanup the file and buffer after that." (nroam-test-with-temp-file-buffer (insert "foo")) (describe "nroam" - (describe "nroam-more" + (describe "nroam-mode" (it "creates nroam sections immediately" (nroam-test-with-temp-file-buffer (insert "#+title: my notes\n") -- cgit v1.2.3-54-g00ecf From e85f625da11dfd0bd24ad6a1dc37db80c5ca5a23 Mon Sep 17 00:00:00 2001 From: Damien Cassou Date: Fri, 19 Mar 2021 11:20:42 +0100 Subject: nroam-test.el: Extract constant * tests/nroam-test.el (nroam-test-main-section-regexp): New constant. --- tests/nroam-test.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/nroam-test.el b/tests/nroam-test.el index f75a7bb..7db8f75 100644 --- a/tests/nroam-test.el +++ b/tests/nroam-test.el @@ -39,6 +39,8 @@ Execute BODY and cleanup the file and buffer after that." (nroam-test-with-temp-file-buffer (insert "foo")) +(defconst nroam-test-main-section-regexp "^* Backlinks") + (describe "nroam" (describe "nroam-mode" (it "creates nroam sections immediately" @@ -46,7 +48,7 @@ Execute BODY and cleanup the file and buffer after that." (insert "#+title: my notes\n") (nroam-mode) (setf (point) (point-min)) - (let ((section-position (re-search-forward "^* Backlinks" nil t))) + (let ((section-position (re-search-forward nroam-test-main-section-regexp nil t))) (expect section-position :not :to-be nil) (expect section-position :to-be-greater-than 10)))))) -- cgit v1.2.3-54-g00ecf From d7de243272f3f2bf7177ad81c5137b4ad97c15dd Mon Sep 17 00:00:00 2001 From: Damien Cassou Date: Fri, 19 Mar 2021 11:21:37 +0100 Subject: Add nroam-goto * nroam.el (nroam-goto): New function. * tests/nroam-test.el: New test for the function. --- nroam.el | 6 ++++++ tests/nroam-test.el | 10 +++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/nroam.el b/nroam.el index 6900d08..d2982aa 100644 --- a/nroam.el +++ b/nroam.el @@ -142,6 +142,12 @@ Make the region inserted by BODY read-only, and marked with (and (markerp nroam-start-marker) (marker-position nroam-start-marker))) +(defun nroam-goto () + "Move point to the beginning of nroam sections if any." + (interactive) + (when (nroam--sections-inserted-p) + (setf (point) (marker-position nroam-start-marker)))) + (defun nroam--prune () "Remove nroam sections from the current buffer." (let ((inhibit-read-only t)) diff --git a/tests/nroam-test.el b/tests/nroam-test.el index 7db8f75..c9a8a05 100644 --- a/tests/nroam-test.el +++ b/tests/nroam-test.el @@ -50,7 +50,15 @@ Execute BODY and cleanup the file and buffer after that." (setf (point) (point-min)) (let ((section-position (re-search-forward nroam-test-main-section-regexp nil t))) (expect section-position :not :to-be nil) - (expect section-position :to-be-greater-than 10)))))) + (expect section-position :to-be-greater-than 10))))) + (describe "nroam-goto" + (it "moves point if nroam heading is present" + (nroam-test-with-temp-file-buffer + (insert "nroam is great\n") + (nroam-update) + (setf (point) (point-min)) + (nroam-goto) + (expect (looking-at-p nroam-test-main-section-regexp) :to-be t))))) (provide 'nroam-test) ;;; nroam-test.el ends here -- cgit v1.2.3-54-g00ecf