Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chachie committed Nov 26, 2023
1 parent 1c3e25c commit 53ea818
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
11 changes: 6 additions & 5 deletions lisp-diary-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,16 @@
(should (= 24 (length r))))
)

(ert-deftest test-topic-search ()
(ert-deftest test-topic-search-helper ()
(should
(eq 5
(with-temp-buffer
(< 0
(with-temp-buffer
(mapc (lambda (n) (insert (format "[topic%sa topic%sb] abc %s %s\n"
n (1+ n) n (1+ n))))
(number-sequence 1 100))
(topic-search t "topic6b topic5a")
(line-number-at-pos)
(topic-search-helper 0 "topic6b topic5a")
(switch-to-buffer "*Occur*")
(search-forward "abc 5 6")
))))

(provide 'lisp-diary-tests)
Expand Down
16 changes: 10 additions & 6 deletions lisp-diary.el
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,8 @@ If new file, add initial content."
len))
res)))

(defun topic-search (nlines keywords)
"Search forward for KEYWORDS in brackets.
With numberic prefix NLINES, display surrounding lines.
See `occur for a description of the values taken by NLINES."
(interactive "P\nsKeywords: ")
(todays-notes lisp-diary-path)
(defun topic-search-helper (nlines keywords)
"See `topic-search for a description of NLINES and KEYWORDS params."
(let* ((opening-bracket "\\[")
(closing-bracket "\\]")
(pipe "\\|")
Expand All @@ -142,6 +138,14 @@ See `occur for a description of the values taken by NLINES."
pipe)))
(occur regex nlines)))

(defun topic-search (nlines keywords)
"Search forward for KEYWORDS in brackets.
With numberic prefix NLINES, display surrounding lines.
See `occur for a description of the values taken by NLINES."
(interactive "P\nsKeywords: ")
(when lisp-diary-path (todays-notes lisp-diary-path))
(topic-search-helper nlines keywords))

(provide 'lisp-diary)

;;; End:
Expand Down

0 comments on commit 53ea818

Please sign in to comment.