diff --git a/ChangeLog b/ChangeLog index be610344..a9dee689 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,29 @@ +2026-10-01 Bob Weiner + +* test/hyrolo-tests.el (hyrolo-tests--gen-kotl-outline): Fix kotl tests + that previously got no results from kotl calls and so undercounted + matches. Set the proper number to fix tests. + 2026-09-30 Bob Weiner +* hsys-consult.el (hsys-consult-entry-regexp): Add support for Koutline + cell relative ids trailing separators. + +* hyrolo.el (hyrolo-grep-file): Add check to not add 'hyrolo-entry-regexp' + prefix to patterns that already contain the prefix. This fixes + 'hyrolo-yank' for 'kotl-mode' entries. + kotl/kview.el (kview:outline-regexp): Allow for regexp quoted + backslashes in front of a period at the start of + 'kview:default-label-separator' so works properly when used in + 'hyrolo-entry-regexp' in 'hyrolo-grep-file' call from 'hyrolo-yank'. + test/hyrolo-tests.el (hyrolo-tests--yank): Add test from Mats that + now passes. + +* hyrolo.el (hyrolo-display-buffer): Clarify that this can be a buffer + or buffer name. + (hyrolo-display-buffer-name): Add and use where a string + type is required. + * man/hy-package.el: man/hy-straight.el: Remove configuration from these two files. man/use-package: Finish reference 'use-package' configuration here. diff --git a/hibtypes.el b/hibtypes.el index 1502504e..a12ec193 100644 --- a/hibtypes.el +++ b/hibtypes.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 19-Sep-91 at 20:45:31 -;; Last-Mod: 29-Sep-26 at 16:11:57 by Bob Weiner +;; Last-Mod: 30-Sep-26 at 17:04:10 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -333,7 +333,7 @@ in all buffers." ;; Don't want this to trigger in a mail/news summary buffer. (not (or (hmail:lister-p) (hnews:lister-p)))) (when (boundp 'hyrolo-display-buffer) - (equal (buffer-name) hyrolo-display-buffer)) + (equal (buffer-name) (hyrolo-display-buffer-name))) (and (hypb:buffer-file-name) (boundp 'hyrolo-file-list) (set:member (current-buffer) diff --git a/hsys-consult.el b/hsys-consult.el index 776df30a..3c171f07 100644 --- a/hsys-consult.el +++ b/hsys-consult.el @@ -2,7 +2,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 4-Jul-24 at 09:57:18 -;; Last-Mod: 20-Jul-26 at 01:52:39 by Bob Weiner +;; Last-Mod: 1-Oct-26 at 00:36:12 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -28,11 +28,12 @@ ;; Don't (require 'consult) here since want to create that dependency only ;; when a function within this library is called. +(require 'find-func) (require 'hbut) (require 'hargs) (require 'hproperty) (require 'hsys-org-roam) -(require 'find-func) +(require 'kview) ;; For `kview:outline-regexp' ;;; ************************************************************************ ;;; Public declarations @@ -69,8 +70,12 @@ ;;; Public variables ;;; ************************************************************************ -(defvar hsys-consult-entry-regexp "^[*#]+ " - "Regexp prefix to match to multi-line entries with `consult-grep'.") +;; This regexp is used interactively by `consult-grep' and can easily break +;; if changed. The groupings and not anchoring `kview:outline-regexp' to +;; the beginning of the line are necessary for matching to work properly. +;; -- RSW, 2026-10-01 +(defvar hsys-consult-entry-regexp (concat "\\(\\(^[*#]+ \\)\\|" kview:outline-regexp "\\)") + "`consult-grep' regexp to match to the first line of multi-line entries.") (defvar hsys-consult-exit-value nil "Value from a user-defined exit-hook sent to `hsys-consult-get-exit-value'.") @@ -153,7 +158,7 @@ optional REGEXP up to MAX-MATCHES in PATH-LIST. Use ripgrep (rg) if found, otherwise, plain grep. Initialize search with optional REGEXP and interactively prompt for changes. Limit matches per file to the absolute value of MAX-MATCHES, if given and not 0. If 0, match -to headlines only (lines that start with a '^[*#]+' regexp). +to headlines only (lines that start with `hsys-consult-entry-regexp'). With optional PROMPT string, use this as the first part of the grep prompt; omit any trailing colon and space in the prompt." @@ -270,7 +275,7 @@ Use ripgrep (rg) if found, otherwise, plain grep to search Org files within `org-roam-directory'. Initialize search with optional REGEXP and interactively prompt for changes. Limit matches per file to the absolute value of MAX-MATCHES, if given and not 0. If 0, match to the start of -headline text only (lines that start with the '^[*#]+' regexp)." +headline text only (lines that start with `hsys-consult-entry-regexp')." (interactive "i\nP") (hsys-consult--org-roam-call-function (lambda () diff --git a/hyrolo.el b/hyrolo.el index d4561508..2b2b366c 100644 --- a/hyrolo.el +++ b/hyrolo.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 7-Jun-89 at 22:08:29 -;; Last-Mod: 12-Sep-26 at 13:57:08 by Mats Lidell +;; Last-Mod: 30-Sep-26 at 17:28:37 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -171,7 +171,8 @@ their standard major modes perform.") :group 'hyperbole-hyrolo) (defvar hyrolo-display-buffer "*HyRolo*" - "Buffer used to display set of last matching rolo entries.") + "Buffer or buffer name used to display set of last matching HyRolo entries. +Call `hyrolo-display-buffer-name' to get its buffer name value.") (defvar hyrolo-source-buffer nil "The source file associated with (point) within the HyRolo display buffer. @@ -579,6 +580,16 @@ omit any trailing colon and space in the prompt." "Grep HyRolo headlines" "Grep HyRolo files"))))) +;;;###autoload +(defun hyrolo-display-buffer-name () + "Return `hyrolo-display-buffer's name or signal an error if an invalid type." + (cond ((stringp hyrolo-display-buffer) + hyrolo-display-buffer) + ((bufferp hyrolo-display-buffer) + (buffer-name hyrolo-display-buffer)) + (t (error "(hyrolo-display-buffer-name): `hyrolo-display-buffer' must be a string or buffer but is of type: %s" + (type-of hyrolo-display-buffer))))) + ;;;###autoload (defun hyrolo-display-matches (&optional display-buf return-to-buffer) "Display optional DISPLAY-BUF buffer of previously found rolo matches. @@ -844,7 +855,7 @@ If ARG is zero, move to the beginning of the current line." (defsubst hyrolo-hdr-at-p () "Return pos if point is at the start of a `hyrolo-mode' file header, else nil." - (text-property-any (point) (1+ (point)) :hyrolo-hdr t)) + (text-property-any (point) (min (1+ (point)) (point-max)) :hyrolo-hdr t)) ;;;###autoload (defun hyrolo-get-entry (name &optional regexp-flag exclude-sub-entries) @@ -1303,12 +1314,16 @@ Raise an error if a match is not found." (define-derived-mode hyrolo-outline-mode outline-mode "HyRoloOtl" "Set major mode for HyRolo searches of outlines with selective display. +Emacs outline files with extensions of .otl and .outl use this mode +automatically. + The difference from `outline-mode' is that it does not change the hidden state of any entries when invoked, as it is used in the HyRolo display matches buffer when moving through entries. -Headings are lines which start with asterisks: one for major headings, -two for subheadings, etc. Lines not starting with asterisks are body lines. +By default, headings are lines which start with asterisks: one for major +headings, two for subheadings, etc. Lines not starting with asterisks are +body lines. Body text or subheadings under a heading can be made temporarily invisible, or visible again. Invisible lines are attached to the end @@ -2184,7 +2199,8 @@ Return number of matching entries found." "#+[ \t]+\\|" (regexp-quote "^") "\\|" (regexp-quote "\\`") "\\)") - pattern))) + pattern)) + (not (string-match-p hyrolo-entry-regexp pattern))) ;; If matching only to headlines and pattern is not already ;; anchored to the beginning of lines, add a file-type-specific ;; headline prefix regexp to the pattern to match. diff --git a/kotl/kotl-mode.el b/kotl/kotl-mode.el index d52175f5..808e9593 100644 --- a/kotl/kotl-mode.el +++ b/kotl/kotl-mode.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 6/30/93 -;; Last-Mod: 29-Sep-26 at 19:20:34 by Bob Weiner +;; Last-Mod: 1-Oct-26 at 01:39:17 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -231,7 +231,7 @@ It provides the following keys: ;; Used by kimport.el functions. (unless (and (boundp 'kotl-previous-mode) kotl-previous-mode (eq kotl-previous-mode #'kotl-mode) - (not (string-prefix-p hyrolo-display-buffer (buffer-name)))) + (not (string-prefix-p (hyrolo-display-buffer-name) (buffer-name)))) (setq hyrolo-entry-regexp (concat "^" kview:outline-regexp) hyrolo-hdr-and-entry-regexp (concat hyrolo-hdr-prefix-regexp hyrolo-entry-regexp) hyrolo-entry-group-number 2 @@ -284,7 +284,7 @@ It provides the following keys: ;; May be a portion of a Koutline in a HyRolo match buffer; we set ;; kotl-mode then to use its local variable settings but don't want ;; to do any of the following formatting. - (if (string-prefix-p hyrolo-display-buffer (buffer-name)) + (if (string-prefix-p (hyrolo-display-buffer-name) (buffer-name)) (unless (and (boundp 'kotl-kview) (kview:is-p kotl-kview)) (kview:create (buffer-name))) ;; sets buffer-local `kotl-kview' ;; If buffer has not yet been formatted for editing, format it. @@ -311,7 +311,7 @@ It provides the following keys: (with-suppressed-warnings ((free-vars kotl-previous-mode)) (setq kotl-previous-mode 'kotl-mode)) (run-mode-hooks 'kotl-mode-hook) - (unless (string-prefix-p hyrolo-display-buffer (buffer-name)) + (unless (string-prefix-p (hyrolo-display-buffer-name) (buffer-name)) (add-hook 'change-major-mode-hook #'kotl-mode:show-all nil t)))) ;;;###autoload diff --git a/kotl/kview.el b/kotl/kview.el index bd9b4348..465ee313 100644 --- a/kotl/kview.el +++ b/kotl/kview.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 6/30/93 -;; Last-Mod: 24-Sep-26 at 16:47:15 by Bob Weiner +;; Last-Mod: 1-Oct-26 at 01:36:36 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -93,8 +93,9 @@ Default value is \". \"." :type 'string :group 'hyperbole-koutliner) -(defconst kview:outline-regexp (concat "\\( *\\)\\([0-9][0-9a-z.]*\\)\\(" - (regexp-quote kview:default-label-separator) +(defconst kview:outline-regexp (concat "\\(\\s-*\\)\\([0-9][0-9a-z.]*\\)" + "\\([\\\\]*" + (regexp-quote kview:default-label-separator) "\\)") "Koutline view `outline-regexp' value that handles all label formats.") diff --git a/test/demo-tests.el b/test/demo-tests.el index 09dc8987..4080b5f9 100644 --- a/test/demo-tests.el +++ b/test/demo-tests.el @@ -3,7 +3,7 @@ ;; Author: Mats Lidell ;; ;; Orig-Date: 30-Jan-21 at 12:00:00 -;; Last-Mod: 29-Sep-26 at 02:06:23 by Bob Weiner +;; Last-Mod: 30-Sep-26 at 17:04:16 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -151,7 +151,7 @@ (with-temp-buffer (load (expand-file-name "hyrolo-demo.el" hyperb:dir)) (should (hact 'kbd-key "C-x 4 r work RET")) - (should (string= (buffer-name) hyrolo-display-buffer)) + (should (string= (buffer-name) (hyrolo-display-buffer-name))) (should (search-forward "Dunn, John"))) (hyrolo-demo-quit))) diff --git a/test/hyrolo-tests.el b/test/hyrolo-tests.el index 91ab7500..352a6a18 100644 --- a/test/hyrolo-tests.el +++ b/test/hyrolo-tests.el @@ -3,7 +3,7 @@ ;; Author: Mats Lidell ;; ;; Orig-Date: 19-Jun-21 at 22:42:00 -;; Last-Mod: 8-Jun-26 at 23:42:26 by Mats Lidell +;; Last-Mod: 1-Oct-26 at 02:31:22 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -106,7 +106,7 @@ (progn (load "../hyrolo-demo") (execute-kbd-macro (kbd "C-x 4r work RET")) - (should (string= (buffer-name) hyrolo-display-buffer)) + (should (string= (buffer-name) (hyrolo-display-buffer-name))) (should (looking-at "======")) (forward-line 5) (should (looking-at "\\*.*Work"))) @@ -118,7 +118,7 @@ (progn (load "../hyrolo-demo") (execute-kbd-macro (kbd "C-x 4r work RET TAB")) - (should (string= (buffer-name) hyrolo-display-buffer)) + (should (string= (buffer-name) (hyrolo-display-buffer-name))) (should (looking-at "Work"))) (hyrolo-demo-quit))) @@ -128,7 +128,7 @@ (progn (load "../hyrolo-demo") (execute-kbd-macro (kbd "C-x 4r work RET TAB")) - (should (string= (buffer-name) hyrolo-display-buffer)) + (should (string= (buffer-name) (hyrolo-display-buffer-name))) (should (looking-at "Work")) (execute-kbd-macro (kbd "h")) @@ -152,7 +152,7 @@ (progn (load "../hyrolo-demo") (execute-kbd-macro (kbd "C-x 4r work RET TAB")) - (should (string= (buffer-name) hyrolo-display-buffer)) + (should (string= (buffer-name) (hyrolo-display-buffer-name))) (should (looking-at "work")) (execute-kbd-macro (kbd "o")) @@ -172,7 +172,7 @@ (progn (load "../hyrolo-demo") (execute-kbd-macro (kbd "C-x 4r work RET TAB")) - (should (string= (buffer-name) hyrolo-display-buffer)) + (should (string= (buffer-name) (hyrolo-display-buffer-name))) (should (looking-at "work")) (execute-kbd-macro (kbd "<")) @@ -188,7 +188,7 @@ (progn (load "../hyrolo-demo") (execute-kbd-macro (kbd "C-x 4r work RET TAB")) - (should (string= (buffer-name) hyrolo-display-buffer)) + (should (string= (buffer-name) (hyrolo-display-buffer-name))) (execute-kbd-macro (kbd "\C-u,n")) (should (looking-at "\\*\\*\\s-+Hansen")) @@ -204,7 +204,7 @@ and {b} the previous same level cell." (progn (load "../hyrolo-demo") (execute-kbd-macro (kbd "C-x 4r com RET TAB")) - (should (string= (buffer-name) hyrolo-display-buffer)) + (should (string= (buffer-name) (hyrolo-display-buffer-name))) (execute-kbd-macro (kbd "<")) (should (equal (point) (point-min))) @@ -225,7 +225,7 @@ and {b} the previous same level cell." (load "../hyrolo-demo") (execute-kbd-macro (kbd "C-x 4r com RET TAB")) - (should (string= (buffer-name) hyrolo-display-buffer)) + (should (string= (buffer-name) (hyrolo-display-buffer-name))) (execute-kbd-macro (kbd "<")) (should (equal (point) (point-min))) @@ -334,7 +334,7 @@ and {b} the previous same level cell." (hy-test-helpers:ert-simulate-keys "string\n" (should (= 4 (call-interactively #'hyrolo-fgrep)))) (should (= 4 (hyrolo-fgrep "string")))) - (should (string= (buffer-name) hyrolo-display-buffer)) + (should (string= (buffer-name) (hyrolo-display-buffer-name))) (should (= (how-many "@loc>") 4)) (dolist (f (list org-file kotl-file md-file outl-file)) (should (= (how-many (concat "@loc> \"" f "\"")) 1))))) @@ -351,7 +351,7 @@ and {b} the previous same level cell." (unwind-protect (progn (should (= 1 (hyrolo-fgrep "string"))) - (should (string= (buffer-name) hyrolo-display-buffer)) + (should (string= (buffer-name) (hyrolo-display-buffer-name))) (should (= (how-many "@loc>") 1)) (should (looking-at-p "===")) (hyrolo-outline-next-visible-heading 1) @@ -379,7 +379,7 @@ and {b} the previous same level cell." (kotl-mode:newline 1) (insert "more") (should (= 1 (hyrolo-fgrep "string"))) - (should (string= (buffer-name) hyrolo-display-buffer)) + (should (string= (buffer-name) (hyrolo-display-buffer-name))) (should (= (how-many "@loc>") 1)) (should (looking-at-p "===")) (hyrolo-outline-next-visible-heading 1) @@ -400,7 +400,7 @@ and {b} the previous same level cell." (unwind-protect (progn (should (= 1 (hyrolo-fgrep "string"))) - (should (string= (buffer-name) hyrolo-display-buffer)) + (should (string= (buffer-name) (hyrolo-display-buffer-name))) (should (= (how-many "@loc>") 1)) (should (looking-at-p "===")) (hyrolo-outline-next-visible-heading 1) @@ -421,7 +421,7 @@ and {b} the previous same level cell." (unwind-protect (progn (should (= 1 (hyrolo-fgrep "string"))) - (should (string= (buffer-name) hyrolo-display-buffer)) + (should (string= (buffer-name) (hyrolo-display-buffer-name))) (should (= (how-many "@loc>") 1)) (should (looking-at-p "===")) (hyrolo-outline-next-visible-heading 1) @@ -451,7 +451,7 @@ Match a string in a level 2 child cell." (kotl-mode:newline 1) (insert "more") (should (= 1 (hyrolo-fgrep "string"))) - (should (string= (buffer-name) hyrolo-display-buffer)) + (should (string= (buffer-name) (hyrolo-display-buffer-name))) (should (= (how-many "@loc>") 1)) (should (looking-at-p "===")) (hyrolo-outline-next-visible-heading 1) @@ -481,7 +481,7 @@ Match a string in the second cell." (kotl-mode:newline 1) (insert "more") (should (= 1 (hyrolo-fgrep "string"))) - (should (string= (buffer-name) hyrolo-display-buffer)) + (should (string= (buffer-name) (hyrolo-display-buffer-name))) (should (= (how-many "@loc>") 1)) (should (looking-at-p "===")) (hyrolo-outline-next-visible-heading 1) @@ -502,8 +502,8 @@ Match a string in the second cell." (h1a_str " 1a\\. heading 1")) (unwind-protect (progn - (should (= 2 (hyrolo-fgrep "bar"))) - (should (string= hyrolo-display-buffer (buffer-name))) + (should (= 4 (hyrolo-fgrep "bar"))) + (should (string= (hyrolo-display-buffer-name) (buffer-name))) (ert-info ("Hide first header move down using ?f") (should (looking-at-p "===")) @@ -704,7 +704,7 @@ below verifies all the details." (progn (hy-test-helpers:ert-simulate-keys "body\n" (should (= 2 (call-interactively #'hyrolo-grep)))) - (should (string= hyrolo-display-buffer (buffer-name))) + (should (string= (hyrolo-display-buffer-name) (buffer-name))) (should (looking-at-p "===")) (execute-kbd-macro (kbd "n")) @@ -720,7 +720,7 @@ below verifies all the details." (unwind-protect (progn (should (= 2 (hyrolo-grep "body"))) - (should (string= hyrolo-display-buffer (buffer-name))) + (should (string= (hyrolo-display-buffer-name) (buffer-name))) ;; Move down (should (looking-at-p "===")) @@ -758,7 +758,7 @@ below verifies all the details." (unwind-protect (progn (should (= 2 (hyrolo-grep "body"))) - (should (string= hyrolo-display-buffer (buffer-name))) + (should (string= (hyrolo-display-buffer-name) (buffer-name))) ;; Move down (should (looking-at-p "===")) @@ -796,7 +796,7 @@ below verifies all the details." (unwind-protect (progn (should (= 2 (hyrolo-grep "body"))) - (should (string= hyrolo-display-buffer (buffer-name))) + (should (string= (hyrolo-display-buffer-name) (buffer-name))) ;; Move down (should (looking-at-p "===")) @@ -834,7 +834,7 @@ below verifies all the details." (unwind-protect (progn (should (= 2 (hyrolo-grep "body"))) - (should (string= hyrolo-display-buffer (buffer-name))) + (should (string= (hyrolo-display-buffer-name) (buffer-name))) ;; Move to last heading (goto-char (point-max)) @@ -858,7 +858,7 @@ below verifies all the details." (unwind-protect (progn (should (= 2 (hyrolo-grep "body"))) - (should (string= hyrolo-display-buffer (buffer-name))) + (should (string= (hyrolo-display-buffer-name) (buffer-name))) ;; Move down (should (looking-at-p "===")) @@ -915,7 +915,7 @@ optional DEPTH the number of sub cells are created to that depth." (unwind-protect (progn (should (= 1 (hyrolo-grep "body"))) - (should (string= hyrolo-display-buffer (buffer-name))) + (should (string= (hyrolo-display-buffer-name) (buffer-name))) (should (looking-at-p "===")) (execute-kbd-macro (kbd "n")) @@ -942,7 +942,7 @@ optional DEPTH the number of sub cells are created to that depth." (unwind-protect (progn (should (= 4 (hyrolo-grep "body"))) - (should (string= hyrolo-display-buffer (buffer-name))) + (should (string= (hyrolo-display-buffer-name) (buffer-name))) ;; Move down (dolist (v '("===" "^\\* heading-org 1$" "===" "^\\* heading-otl 1$" @@ -980,7 +980,7 @@ optional DEPTH the number of sub cells are created to that depth." (unwind-protect (progn (should (= 1 (hyrolo-grep "body"))) - (should (string= hyrolo-display-buffer (buffer-name))) + (should (string= (hyrolo-display-buffer-name) (buffer-name))) ;; Hide/Show first line hides whole section (should (looking-at-p "===")) @@ -1021,7 +1021,7 @@ optional DEPTH the number of sub cells are created to that depth." (unwind-protect (progn (should (= 1 (hyrolo-grep "body"))) - (should (string= hyrolo-display-buffer (buffer-name))) + (should (string= (hyrolo-display-buffer-name) (buffer-name))) ;; Hide first line hides whole section (should (looking-at-p "===")) @@ -1052,7 +1052,7 @@ tabbing though the matches." (unwind-protect (progn (should (= 2 (hyrolo-grep "body"))) - (should (string= hyrolo-display-buffer (buffer-name))) + (should (string= (hyrolo-display-buffer-name) (buffer-name))) ;; Search Down (should (looking-at-p "===")) @@ -1086,7 +1086,7 @@ tabbing though the matches." (unwind-protect (progn (should (= 1 (hyrolo-grep "body"))) - (should (string= hyrolo-display-buffer (buffer-name))) + (should (string= (hyrolo-display-buffer-name) (buffer-name))) ;; Search Down (should (looking-at-p "===")) @@ -1125,7 +1125,7 @@ tabbing though the matches." (save-buffer) (hyrolo-grep "item") (execute-kbd-macro (kbd "TAB")) - (should (string= (buffer-name) hyrolo-display-buffer)) + (should (string= (buffer-name) (hyrolo-display-buffer-name))) (should (looking-at (rx-to-string `(seq "item\n" (one-or-more whitespace) ,test-time)))) (setq test-time "2025-01-01") (hyrolo-edit-entry) @@ -1148,7 +1148,7 @@ All files types are present." (unwind-protect (progn (should (= 7 (hyrolo-grep "body"))) - (should (string= hyrolo-display-buffer (buffer-name))) + (should (string= (hyrolo-display-buffer-name) (buffer-name))) ;; Move forward (dolist (v '("^\\* heading-org 1$" "^\\* heading-org 2$" @@ -1183,8 +1183,8 @@ structure." (hyrolo-file-list (list org-file1 md-file1 otl-file1 kotl-file1))) (unwind-protect (progn - (should (= 4 (hyrolo-grep "body"))) - (should (string= hyrolo-display-buffer (buffer-name))) + (should (= 6 (hyrolo-grep "body"))) + (should (string= (hyrolo-display-buffer-name) (buffer-name))) ;; Move forward (dolist (v '("===" "^\\* heading-org 1$" "===" "^# heading-md 1$" @@ -1242,7 +1242,7 @@ Useful for creating outline and markdown test data from org examples." (unwind-protect (progn (should (= 4 (hyrolo-grep "body"))) - (should (string= hyrolo-display-buffer (buffer-name))) + (should (string= (hyrolo-display-buffer-name) (buffer-name))) ;; Move to first second level header (search-forward "** h-org 1.1") @@ -1278,8 +1278,8 @@ Useful for creating outline and markdown test data from org examples." (hyrolo-file-list (list org-file1 otl-file1 md-file1 kotl-file1))) (unwind-protect (progn - (should (= 7 (hyrolo-grep "body"))) - (should (string= hyrolo-display-buffer (buffer-name))) + (should (= 9 (hyrolo-grep "body"))) + (should (string= (hyrolo-display-buffer-name) (buffer-name))) ;; Move to first second level header (search-forward "** h-org 1.1") @@ -1581,7 +1581,7 @@ body (hyrolo-file-list (list kotl-file1))) (unwind-protect (progn - (should (= 1 (hyrolo-grep "body"))) + (should (= 2 (hyrolo-grep "body"))) (hyrolo-top-level) (should (string= (concat @@ -1596,7 +1596,6 @@ body "\ 1. h-kotl body - 1a. h-kotl 1 body 1 ") @@ -1620,7 +1619,7 @@ body (hyrolo-file-list (list org-file1 otl-file1 md-file1 kotl-file1))) (unwind-protect (progn - (should (= 7 (hyrolo-grep "body"))) + (should (= 9 (hyrolo-grep "body"))) (hyrolo-top-level) (should (string= @@ -1658,7 +1657,7 @@ body (hyrolo-file-list (list org-file1 otl-file1 md-file1 kotl-file1))) (unwind-protect (progn - (should (= 7 (hyrolo-grep "body"))) + (should (= 9 (hyrolo-grep "body"))) (hyrolo-overview nil) (should (string= @@ -1754,7 +1753,7 @@ body (hyrolo-file-list (list kotl-file1))) (unwind-protect (progn - (should (= 1 (hyrolo-grep "body"))) + (should (= 2 (hyrolo-grep "body"))) (hyrolo-next-match) (action-key) (should (string= (hypb:buffer-file-name) kotl-file1)) @@ -1777,7 +1776,7 @@ body (hyrolo-file-list (list kotl-file1))) (unwind-protect (progn - (should (= 1 (hyrolo-grep "h-kotl"))) + (should (= 2 (hyrolo-grep "h-kotl"))) (hyrolo-next-match) (action-key) (should (string= (hypb:buffer-file-name) kotl-file1)) @@ -1800,7 +1799,7 @@ body (hyrolo-file-list (list kotl-file1))) (unwind-protect (progn - (should (= 1 (hyrolo-grep "body2"))) + (should (= 2 (hyrolo-grep "body2"))) (hyrolo-next-match) (action-key) (should (string= (hypb:buffer-file-name) kotl-file1)) @@ -1824,7 +1823,7 @@ body (unwind-protect (progn (kotl-mode:beginning-of-buffer) - (should (= 1 (hyrolo-grep "h2"))) + (should (= 2 (hyrolo-grep "h2"))) (action-key) (should (string= (hypb:buffer-file-name) kotl-file1)) (should (looking-at-p "h1 / h2$")) @@ -2159,7 +2158,7 @@ body 2 (unwind-protect (progn (should (= 2 (hyrolo-grep "heading"))) - (should (string= hyrolo-display-buffer (buffer-name))) + (should (string= (hyrolo-display-buffer-name) (buffer-name))) ;; Search Down (should (looking-at-p "===")) @@ -2176,6 +2175,39 @@ body 2 (kill-buffer hyrolo-display-buffer) (hy-delete-files-and-buffers hyrolo-file-list)))) +(ert-deftest hyrolo-tests--yank () + "Verify `hyrolo-yank' insert." + (let* ((org-file1 (make-temp-file "hypb" nil ".org" + (hyrolo-tests--gen-outline ?* "heading-org" 1 "body" 2))) + (otl-file1 (make-temp-file "hypb" nil ".otl" + (hyrolo-tests--gen-outline ?* "heading-otl" 1 "body" 2))) + (md-file1 (make-temp-file "hypb" nil ".md" + (hyrolo-tests--gen-outline ?# "heading-md" 1 "body" 2))) + (kotl-file1 (hyrolo-tests--gen-kotl-outline "heading-kotl" "body-kotl")) + (hyrolo-file-list (list org-file1 otl-file1 md-file1 kotl-file1))) + (unwind-protect + (with-temp-buffer + (erase-buffer) + (hyrolo-yank "There is no such line" nil t) + ;; FIXME: Above call fails before verification. + ;; (should (string= "* heading-kotl\nbody-kotl\n" + ;; (buffer-substring-no-properties (point-min) (point-max)))) + + (dolist (v '(("heading-org" . ?*) ("heading-otl" . ?*) ("heading-md" . ?#))) + (let* ((header (car v)) + (char (cdr v)) + ;; (debug-on-message "Making hyrolo-display-buffer buffer-local while locally let-bound!") + (file-string (hyrolo-tests--gen-outline char header 1 "body" 2))) + (erase-buffer) + (hyrolo-yank header nil t) + (should (string= (concat (string-join (seq-take (string-lines file-string) 2) "\n") "\n") + (buffer-substring-no-properties (point-min) (point-max)))) + + (erase-buffer) + (hyrolo-yank header) + (should (string= file-string + (buffer-substring-no-properties (point-min) (point-max)))))))))) + (provide 'hyrolo-tests) ;; This file can't be byte-compiled without the `el-mock' package