branch: externals/hyperbole commit 926f8a02fd113ec113660e61ff64728e3ef93606 Author: bw <r...@gnu.org> Commit: bw <r...@gnu.org>
Fix many hyrolo multi-file-format issues; fix hywconfig by name hibtypes.el (Info-node): Tighten match to limit valid chars after closing paren. (hyrolo-stuck-msg): Add to jump to the position where a HyRolo match became stuck, if ever happens, when point is on the error. hyrolo.el (hyrolo-grep-file): Update 'Stuck looping in buffer' msg so can be used in new 'hyrolo-stuck-msg' ibtype. man/hyperbole.texi (Implicit Button Types): Add doc for 'hib-python-traceback' and 'hyrolo-stuck-msg'. hyperbole.el: The 'describe-package' function fails under Emacs 28 when multiple maintainers are listed under the 'Maintainer' header but later Emacs versions support a 'Maintainers' header, so include both. Change to using 'Authors' --- ChangeLog | 78 ++++++++++++++ hbut.el | 4 +- hibtypes.el | 28 ++++- hypb.el | 26 ++++- hyperbole.el | 7 +- hyrolo.el | 268 ++++++++++++++++++++++++------------------------ hywconfig.el | 109 ++++++++++++-------- kotl/kotl-mode.el | 28 +++-- kotl/kview.el | 4 +- man/hyperbole.texi | 20 +++- test/hyrolo-tests.el | 17 ++- test/hywconfig-tests.el | 20 ++-- 12 files changed, 386 insertions(+), 223 deletions(-) diff --git a/ChangeLog b/ChangeLog index dc7107fd43..f174532673 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,81 @@ +2023-12-23 Bob Weiner <r...@gnu.org> + +* kotl/kotl-mode.el (kotl-mode): Ensure local vars are set if current buffer + is HyRolo display matches buffer. + +* hypb.el (hypb:remove-from-plist, hypb:do-remove-from-plist): Add for use in + "hywconfig.el". + hywconfig.el (hywconfig-add-by-name, hywconfig-delete-by-name, + hywconfig-restore-by-name): Fix all wconfig by name functions + which were storing only unnamed window configs. Change all to return a + boolean value based on whether the operation succeeds or not. + (hywconfig-set-names): Replace with 'hywconfig-named-set-entries'. + (hywconfig-named-get-entries, hywconfig-named-put, + hywconfig-named-get): Add. + (hywconfig-get-names): Replace with 'hywconfig-named-get-names'. + (hywconfig-set-window-configuration): Add doc. + (require 'set): Remove, no longer used. + +* kotl/kotl-mode.el (kotl-mode): Disable 'change-major-mode-hook' addition of + 'kotl-mode:show-all' if in the HyRolo display buffer. + +* hyrolo.el (hyrolo-entry-regexp): Add 'hyrolo-hdr-regexp' and 'hbut:source-prefix' + so are not skipped during hide/show operations. Also do this in + 'markdown-mode-hook' and 'kotl-mode'. + +* test/hyrolo-tests.el (hyrolo-demo-move-between-entries-on-same-level, + hyrolo-demo-no-following-same-level-heading): Fix + header skipping by using 'hyrolo-hdr-move-after-p'. + (hyrolo-fgrep-find-all-types-of-files): Fix by adding + proper headling structure to each file type. + (hyrolo-fgrep-and-goto-next-visible-md-heading): Fix + by removing one '#' from expected heading level. + +* kotl/kotl-mode.el (kotl-mode:reveal-toggle-invisible): May be in the + 'hyrolo-display-buffer', so wrap a 'hyrolo-funcall-match' call around + 'outline-reveal-toggle-invisible' call to ensure proper match buffer mode + is set for koutline matches. + +* hyrolo.el (hyrolo-grep-file): Remove 'backward-search-limit' as may miss prior + entry starting positions. + (hyrolo-add-match): Remove first arg, 'hyrolo-matches-buffer' and + use global 'hyrolo-display-buffer' instead. + (hyrolo-grep-file): Remove first arg from call to 'hyrolo-add-match'. + Remove unused local 'curr-entry-level-len' which would not work for Markdown + 'outline-regexp' anyway. + +2023-12-21 Bob Weiner <r...@gnu.org> + +* hyrolo.el (hyrolo-funcall-match, hyrolo-map-matches): Use (1- (point-max)) + when 'end' is nil, i.e. only a single file has been found and the start of + of the next one used to determine the end of this one has not yet been added. + +* man/hyperbole.texi (Implicit Button Types): Add doc for 'hib-python-traceback' + and 'hyrolo-stuck-msg'. + +* hibtypes.el (Info-node): Tighten match to limit valid chars after closing paren. + (hyrolo-stuck-msg): Add to jump to the position where a HyRolo match + became stuck, if ever happens, when point is on the error. + hyrolo.el (hyrolo-grep-file): Update 'Stuck looping in buffer' msg so can be + used in 'hyrolo-stuck-msg' ibtype. + +* hyperbole.el: The 'describe-package' function fails under Emacs 28 when multiple + maintainers are listed under the 'Maintainer' header but later Emacs versions + support a 'Maintainers' header, so include both. Change to using 'Authors' + instead of 'Author'. + +2023-12-20 Bob Weiner <r...@gnu.org> + +* hyrolo.el (hyrolo-edit-entry, hyrolo-locate): Wrap in 'hyrolo-funcall-match' call + to fix these functions to work with multiple modes. + (hyrolo-funcall-match): Ensure 'unwind-protect' end forms are run within + 'hyrolo-display-buffer'. + +* kotl/kview.el (kview:outline-regexp): Add grouping for kcell label matches; used + in `hyrolo-display-buffer'. + kotl/kotl-mode.el (kotl-mode): Add local settings of 'hyrolo-entry-group-number' + and 'hyrolo-entry-trailing-space-group-number'. + 2023-12-18 Bob Weiner <r...@gnu.org> * hyrolo.el (hyrolo-move-backward, hyrolo-move-forward): If FUNC is a lambda diff --git a/hbut.el b/hbut.el index 3aa2a4301d..f956da94a3 100644 --- a/hbut.el +++ b/hbut.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 18-Sep-91 at 02:57:09 -;; Last-Mod: 15-Dec-23 at 12:04:33 by Bob Weiner +;; Last-Mod: 21-Dec-23 at 13:12:49 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -1248,7 +1248,7 @@ is given." (file-name-nondirectory buffer-file-name))) ;; Handle any preceding @loc hyp-source implicit button location references. ;; This is used in report buffers of explicit buttons, i.e. hui:hbut-report - ;; as well as the *HyRolo* and *HyNote* output buffers. + ;; as well as the *HyRolo* display matches buffer. ((save-excursion (save-restriction (widen) diff --git a/hibtypes.el b/hibtypes.el index 5963b69da0..8825e147a6 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: 3-Dec-23 at 23:55:11 by Bob Weiner +;; Last-Mod: 21-Dec-23 at 13:12:35 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -869,7 +869,7 @@ See `hpath:find' function documentation for special file display options." ;;; ======================================================================== ;;; Jumps to source line associated with ipython, ripgrep, grep or -;;; compilation errors. +;;; compilation errors or HyRolo stuck position error messages. ;;; ======================================================================== (defib ipython-stack-frame () @@ -960,6 +960,23 @@ than a helm completion buffer)." (ibut:label-set but-label) (hact 'link-to-file-line file line-num))))))))) +(defib hyrolo-stuck-msg () + "Jump to the position where a HyRolo search has become stuck from the error. +Such errors are recognized in any buffer (other than a helm completion +buffer)." + (unless (derived-mode-p 'helm-major-mode) + (save-excursion + (beginning-of-line) + ;; HyRolo stuck error + (when (looking-at ".*(hyrolo-grep-file): Stuck looping in buffer \\\\?\"\\([^\\\t\n\r\f\"'`]+\\)\\\\?\" at position \\([0-9]+\\)") + (let* ((buffer-name (match-string-no-properties 1)) + (pos (or (match-string-no-properties 2) "1")) + (but-label (concat buffer-name ":P" pos))) + (when (buffer-live-p (get-buffer buffer-name)) + (setq pos (string-to-number pos)) + (ibut:label-set but-label) + (hact 'link-to-buffer-tmp buffer-name pos))))))) + (defib grep-msg () "Jump to the line associated with line numbered grep or compilation error msgs. Messages are recognized in any buffer (other than a helm completion @@ -971,6 +988,8 @@ in grep and shell buffers." (save-excursion (beginning-of-line) (when (or + ;; HyRolo stuck error + (looking-at ".*(hyrolo-grep-file): Stuck looping in \\(buffer\\) \\\\?\"\\([^\\\t\n\r\f\"'`]+\\)\\\\?\" at position \\([0-9]+\\)") ;; Emacs native compiler file lines (looking-at "Compiling \\(\\S-+\\)\\.\\.\\.$") (looking-at "Loading \\(\\S-+\\) (\\S-+)\\.\\.\\.$") @@ -1025,7 +1044,7 @@ in grep and shell buffers." ;;; ======================================================================== ;;; Jumps to source line associated with debugger stack frame or breakpoint -;;; lines. Supports gdb, dbx, and xdb. +;;; lines. Supports pdb, gdb, dbx, and xdb. ;;; ======================================================================== (defun hib-python-traceback () @@ -1374,7 +1393,8 @@ Activates only if point is within the first line of the Info-node name." (hbut:label-p t "`" "'" t t))) (ref (car node-ref-and-pos)) (node-ref (and (stringp ref) - (string-match-p "\\`([^\): \t\n\r\f]+)" ref) + (or (string-match-p "\\`([^\): \t\n\r\f]+)\\'" ref) + (string-match-p "\\`([^\): \t\n\r\f]+)[^ :;\"'`]" ref)) (hpath:is-p ref nil t)))) (and node-ref (ibut:label-set node-ref-and-pos) diff --git a/hypb.el b/hypb.el index fc649dcc0e..6f1f590593 100644 --- a/hypb.el +++ b/hypb.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 6-Oct-91 at 03:42:38 -;; Last-Mod: 30-Nov-23 at 11:18:54 by Bob Weiner +;; Last-Mod: 23-Dec-23 at 01:16:28 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -793,6 +793,30 @@ PACKAGE-NAME may be a symbol or a string." (keyboard-quit))) (require package-name)) +;; Adapted from cl--do-remf in "cl-extra.el" but uses 'equal' for comparisons. +;;;###autoload +(defun hypb:do-remove-from-plist (plist name) + (let ((p (cdr plist))) + ;; Can't use `plist-member' here because it goes to the cons-cell + ;; of NAME and we need the one before. + (while (and (cdr p) (not (equal (cadr p) name))) + (setq p (cddr p))) + (and (cdr p) (progn (setcdr p (cdddr p)) t)))) + +;; Adapted from cl-remf in "cl-macs.el" but uses 'equal' for comparisons. +;;;###autoload +(defmacro hypb:remove-from-plist (place name) + "Remove from property list PLACE a NAME string. +PLACE may be a symbol, or any generalized variable allowed by `setf'. +The form generated by the macro returns true if NAME was found and removed, nil otherwise." + (declare (debug (place form))) + (gv-letplace (tval setter) place + (macroexp-let2 macroexp-copyable-p tname name + `(if (equal ,tname (car ,tval)) + (progn ,(funcall setter `(cddr ,tval)) + t) + (hypb:do-remove-from-plist ,tval ,tname))))) + (defun hypb:remove-lines (regexp) "Remove lines containing match for REGEXP. Apply within an active region or to the end of buffer." diff --git a/hyperbole.el b/hyperbole.el index bd89ec0db4..415b473e33 100644 --- a/hyperbole.el +++ b/hyperbole.el @@ -4,10 +4,11 @@ ;; ;; Copyright (C) 1992-2023 Free Software Foundation, Inc. -;; Author: Bob Weiner -;; Maintainer: Bob Weiner <r...@gnu.org>, Mats Lidell <ma...@gnu.org> +;; Authors: Robert Weiner <r...@gnu.org> +;; Maintainer: Mats Lidell <ma...@gnu.org> +;; Maintainers: Robert Weiner <r...@gnu.org>, Mats Lidell <ma...@gnu.org> ;; Created: 06-Oct-92 at 11:52:51 -;; Last-Mod: 3-Dec-23 at 09:46:12 by Bob Weiner +;; Last-Mod: 23-Dec-23 at 01:50:36 by Bob Weiner ;; Released: 03-Dec-23 ;; Version: 9.0.0 ;; Keywords: comm, convenience, files, frames, hypermedia, languages, mail, matching, mouse, multimedia, outlines, tools, wp diff --git a/hyrolo.el b/hyrolo.el index 73936d410b..e182535685 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: 18-Dec-23 at 11:20:19 by Bob Weiner +;; Last-Mod: 22-Dec-23 at 22:44:50 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -156,8 +156,31 @@ A hyrolo-file consists of: ;; `customize-set-variable'. (add-variable-watcher 'hyrolo-file-list #'hyrolo-file-list-changed) -(defvar hyrolo-entry-regexp "^\\(\\*+\\)\\([ \t]+\\)" - "Regular expression to match the beginning of a rolo entry. +(defconst hyrolo-hdr-format + (concat + "===============================================================================\n" + "%s\n" + "===============================================================================\n") + "Header to insert preceding a file's first HyRolo entry match when +file has none of its own. Used with one argument, the file name.") + +(defconst hyrolo-hdr-regexp "^===" + "Regular expression to match the first and last lines of hyrolo file headers. +This header is inserted into hyrolo-display-buffer before any entries from the +file are added.") + +(defvar hyrolo-entry-group-number 1 + "Group number whose length represents the level of any entry matched. +See `hyrolo-entry-regexp'") + +(defvar hyrolo-entry-trailing-space-group-number 2 + "Group number within `hyrolo-entry-regexp' containing trailing space.") + +(defvar hyrolo-entry-regexp + (concat hyrolo-hdr-regexp + "\\|^" (if (boundp 'hbut:source-prefix) hbut:source-prefix "@loc> ") + "\\|^\\(\\*+\\)\\([ \t]+\\)") + "Regular expression to match the beginning of a HyRolo entry. This pattern must match the beginning of a line. `hyrolo-entry-group-number' must capture the entry's level in the hierarchy. `hyrolo-entry-trailing-space-group-number' must capture @@ -167,20 +190,21 @@ level.") ;; Support hyrolo searches in markdown files (add-hook 'markdown-mode-hook (lambda () - (make-local-variable 'hyrolo-entry-regexp) - (make-local-variable 'hyrolo-entry-group-number) - (make-local-variable 'hyrolo-entry-trailing-space-group-number) - (setq hyrolo-entry-regexp markdown-regex-header - hyrolo-entry-group-number 4 - ;; `hyrolo-add' handles removing # prefix from - ;; trailing-space grouping below - hyrolo-entry-trailing-space-group-number 4))) + (setq-local hyrolo-entry-regexp + (concat hyrolo-hdr-regexp + "\\|^" (if (boundp 'hbut:source-prefix) hbut:source-prefix "@loc> ") + "\\|^\\(#+\\)\\([ ]+\\)") + hyrolo-entry-group-number 1 + ;; `hyrolo-add' handles removing # prefix from + ;; trailing-space grouping below + hyrolo-entry-trailing-space-group-number 2 + outline-level #'hyrolo-markdown-outline-level))) (defcustom hyrolo-date-format "%m/%d/%Y" "Format of date string used in HyRolo automatic date stamps. An empty string disables adding or updating HyRolo dates. -Default is American style. See documentation of the function +Default appearance is MM/DD/YYYY. See documentation of the function `format-time-string' for format options." :type 'string :group 'hyperbole-hyrolo) @@ -298,26 +322,6 @@ matches." "List of hyrolo files after directory and file wildcard expansions. Hyrolo sets this internally; never set it yourself.") -(defvar hyrolo-entry-group-number 1 - "Group number whose length represents the level of any entry matched. -See `hyrolo-entry-regexp'") - -(defvar hyrolo-entry-trailing-space-group-number 2 - "Group number within `hyrolo-entry-regexp; containing trailing space.") - -(defconst hyrolo-hdr-format - (concat - "===============================================================================\n" - "%s\n" - "===============================================================================\n") - "Header to insert preceding a file's first hyrolo entry match when -file has none of its own. Used with one argument, the file name.") - -(defconst hyrolo-hdr-regexp "^===" - "Regular expression to match the first and last lines of hyrolo file headers. -This header is inserted into hyrolo-display-buffer before any entries from the -file are added.") - (defconst hyrolo-match-regexp nil "Last regular expression used to search the hyrolo. Nil before a search is done, including after a logical search is done. @@ -570,22 +574,25 @@ a parent entry which begins with the parent string." "Edit the source entry of the hyrolo match buffer entry at point. Return entry name, if any, otherwise, trigger an error." (interactive) - (let* ((name-and-src (hyrolo-name-at-p)) - (name (car name-and-src)) - (src (cdr name-and-src))) - (if name - (progn (cond ((and (boundp 'bbdb-file) (stringp bbdb-file) (equal src (expand-file-name bbdb-file))) - ;; For now, can't edit an entry from the bbdb database, signal an error. - (error "(hyrolo-edit-entry): BBDB entries are not editable")) - ((and (hyrolo-google-contacts-p) (equal src (get-buffer google-contacts-buffer-name))) - ;; For now, can't edit an entry from Google Contacts, signal an error. - (error "(hyrolo-edit-entry): Google Contacts entries are not editable")) - (src - (hyrolo-edit name src) - name) - (t - (error "(hyrolo-edit-entry): Move to an entry to edit it")))) - (error "(hyrolo-edit-entry): Move to an entry to edit it")))) + (hyrolo-funcall-match + (lambda () + (let* ((name-and-src (hyrolo-name-at-p)) + (name (car name-and-src)) + (src (cdr name-and-src))) + (if name + (progn (cond ((and (boundp 'bbdb-file) (stringp bbdb-file) (equal src (expand-file-name bbdb-file))) + ;; For now, can't edit an entry from the bbdb database, signal an error. + (error "(hyrolo-edit-entry): BBDB entries are not editable")) + ((and (hyrolo-google-contacts-p) (equal src (get-buffer google-contacts-buffer-name))) + ;; For now, can't edit an entry from Google Contacts, signal an error. + (error "(hyrolo-edit-entry): Google Contacts entries are not editable")) + (src + (hyrolo-edit name src) + name) + (t + (error "(hyrolo-edit-entry): Move to an entry to edit it")))) + (error "(hyrolo-edit-entry): Move to an entry to edit it")))) + t)) ;;;###autoload (defun hyrolo-fgrep (string &optional max-matches hyrolo-file count-only headline-only no-display) @@ -850,7 +857,8 @@ Return t if entry is killed, nil otherwise." (defun hyrolo-locate () "Interactively search for an entry beginning with a set of search characters." (interactive) - (hyrolo-isearch-for-regexp hyrolo-entry-regexp nil)) + (hyrolo-funcall-match + (lambda () (hyrolo-isearch-for-regexp hyrolo-entry-regexp nil)))) (defun hyrolo-mail-to () "Start composing mail addressed to the first e-mail address at or after point." @@ -1634,10 +1642,11 @@ Return number of matching entries found." (when (file-exists-p hyrolo-file-or-buf) (setq actual-buf (hyrolo-find-file-noselect hyrolo-file-or-buf) new-buf-flag t)))) - (let ((hdr-pos) (num-found 0) (curr-entry-level-len) + (let ((num-found 0) (incl-hdr t) (stuck-negative-point 0) - entry-start) + entry-start + hdr-pos) (when max-matches (cond ((eq max-matches t) (setq incl-hdr nil max-matches nil)) @@ -1658,22 +1667,18 @@ Return number of matching entries found." (when (hyrolo-hdr-move-after-p) (setq hdr-pos (cons (point-min) (point)))) (let* ((case-fold-search t) - (backward-search-limit (save-excursion - (if (re-search-forward hyrolo-entry-regexp nil t) - (match-beginning 0) - (point)))) match-end) (re-search-forward hyrolo-entry-regexp nil t) (while (and (or (null max-matches) (< num-found max-matches)) (funcall hyrolo-next-match-function pattern headline-only)) (setq match-end (point)) - ;; If no entry delimiters found, just return the line of the match alone. - (unless (re-search-backward hyrolo-entry-regexp backward-search-limit t) + ;; If no entry delimiters found, just return + ;; the line of the match alone. + (unless (re-search-backward hyrolo-entry-regexp nil t) (goto-char (line-beginning-position))) (setq entry-start (point)) (unless (re-search-forward hyrolo-entry-regexp nil t) (goto-char (line-end-position))) - (setq curr-entry-level-len (length (buffer-substring-no-properties entry-start (point)))) (unless (hyrolo-to-entry-end t) ;; If at the end of a line, move to the next line; ;; otherwise, move forward a character if possible. @@ -1707,15 +1712,15 @@ Return number of matching entries found." (set-buffer actual-buf)))) (setq num-found (1+ num-found)) (or count-only - (hyrolo-add-match hyrolo-display-buffer pattern entry-start (point))) - (setq backward-search-limit (point)))))) + (hyrolo-add-match pattern entry-start (point))))))) num-found)) (when (and (> num-found 0) (not count-only)) (hyrolo--cache-major-mode (current-buffer))) (when (< stuck-negative-point 0) (pop-to-buffer (current-buffer)) (goto-char (- stuck-negative-point)) - (error "(hyrolo-grep-file): Stuck looping at position %d in buffer \"%s\"" (point) (buffer-name))) + (error "(hyrolo-grep-file): Stuck looping in buffer \"%s\" at position %d" + (buffer-name) (point))) (hyrolo-kill-buffer actual-buf) num-found) 0))) @@ -1845,7 +1850,7 @@ Calls the functions given by `hyrolo-mode-hook'. (defun hyrolo-next-regexp-match (regexp headline-only) "In a HyRolo source buffer, move past next occurrence of REGEXP or return nil. -When found, return the mnatch starting position." +When found, return the match start position." (when (re-search-forward regexp (when headline-only (save-excursion (end-of-visible-line) (point))) @@ -2067,7 +2072,7 @@ nil if not found." file-or-buf)) (let ((case-fold-search t) (real-name name) (parent "") (level) end) (hyrolo-widen) - (goto-char 1) + (goto-char (point-min)) (if (get-text-property 0 'hyrolo-line-entry name) ;; this is a whole line to find without any entry delimiters (when (search-forward name nil t) @@ -2105,8 +2110,7 @@ nil if not found." (when (or (looking-at (buffer-local-value 'outline-regexp (get-buffer hyrolo-display-buffer))) - ;; Jump to non-first line - ;; within an entry + ;; Jump to non-first line within an entry (progn (back-to-indentation) (looking-at (regexp-quote name)))) (when (derived-mode-p 'kotl-mode) @@ -2140,28 +2144,29 @@ before the final newline of the entry. Return current point." (interactive "P") - (hyrolo-move-forward - (lambda (include-sub-entries) - (if (not include-sub-entries) - (outline-next-heading) - (outline-end-of-subtree) - (goto-char (1+ (point)))) - include-sub-entries)) + (hyrolo-move-forward (lambda () (hyrolo-move-to-entry-end include-sub-entries))) (when (called-interactively-p 'any) (goto-char (1- (point)))) (point)) +(defun hyrolo-move-to-entry-end (include-sub-entries) + (if (not include-sub-entries) + (outline-next-heading) + (outline-end-of-subtree) + (goto-char (1+ (point)))) + include-sub-entries) + ;;; ************************************************************************ ;;; Private functions ;;; ************************************************************************ -(defun hyrolo-add-match (hyrolo-matches-buffer regexp start end) - "Insert in HYROLO-MATCHES-BUFFER an entry matching REGEXP from current region. +(defun hyrolo-add-match (regexp start end) + "Add in `hyrolo-display-buffer' an entry matching REGEXP from current region. Entry is inserted before point. The region is between START to END." (let ((hyrolo-buf (current-buffer)) (hyrolo-entry (buffer-substring start end)) opoint) - (set-buffer (get-buffer-create hyrolo-matches-buffer)) + (set-buffer (get-buffer-create hyrolo-display-buffer)) (setq opoint (point)) (insert (funcall hyrolo-display-format-function hyrolo-entry)) (hyrolo-highlight-matches regexp opoint (point)) @@ -2354,8 +2359,7 @@ Do nothing if in a Koutline buffer or if `hyrolo-date-format' is an empty string. Suitable for use as an entry in `hyrolo-add-hook' and `hyrolo-edit-hook'. -The date format is determined by the setting, `hyrolo-date-format', with -a default of MM/DD/YYYY." +The date format is determined by the setting, `hyrolo-date-format'." (unless (or (string-empty-p hyrolo-date-format) (null hyrolo-date-format) (derived-mode-p 'kotl-mode)) (save-excursion @@ -2465,9 +2469,7 @@ Return final point." (forward-line 1) (re-search-backward hyrolo-hdr-regexp nil t 2)) (when (> (point) opoint) - (goto-char opoint)) - (when (derived-mode-p 'kotl-mode) - (kotl-mode:to-valid-position))) + (goto-char opoint))) ;; Narrow to current match buffer when given a lambda func. (not (symbolp func)))) (point)) @@ -2482,9 +2484,7 @@ Return final point." (condition-case nil (hyrolo-funcall-match (lambda () - (apply func args) - (when (derived-mode-p 'kotl-mode) - (kotl-mode:to-valid-position))) + (apply func args)) ;; Narrow to current match buffer when given a lambda func. (not (symbolp func))) ;; Prevent error and move past file header. @@ -2541,47 +2541,46 @@ its source location. With point in the HyRolo display matches buffer and optional NARROW-FLAG non-nil, narrow to the current file of matches prior to applying FUNC." + (when (zerop (buffer-size (current-buffer))) + (error "(hryolo-map-matches): No HyRolo matches in current buffer")) (let ((display-buf (get-buffer hyrolo-display-buffer))) (if (eq (current-buffer) display-buf) - (progn - (when (< (length hyrolo--cache-loc-match-bounds) 1) - (error "(hryolo-map-matches): No HyRolo matches in display buffer")) - (let ((bounds hyrolo--cache-loc-match-bounds) - (ofont-lock font-lock-mode) - (omode major-mode) - (ostart (point-min)) - (oend (point-max)) - start - end) - (unwind-protect - (save-excursion - (while (setq start (car bounds) - end (cadr bounds)) - (setq end (1- end) - bounds (cdr bounds)) - (when narrow-flag - (narrow-to-region start end)) - (goto-char start) - (let ((font-lock-mode)) - (hyrolo-cache-set-major-mode (1+ start)) - (setq font-lock-mode nil) ;; Prevent Org mode from font-locking - (funcall func)))) - (when narrow-flag - ;; Restore original restriction - (narrow-to-region ostart oend)) - ;; Restore original mode and font-locking - (funcall omode) - (font-lock-mode (if ofont-lock 1 0)) - (when (fboundp 'orgtbl-mode) - ;; Disable as overrides single letter keys - (orgtbl-mode 0))))) + (let ((bounds hyrolo--cache-loc-match-bounds) + (ofont-lock font-lock-mode) + (omode major-mode) + (ostart (point-min)) + (oend (point-max)) + start + end) + (unwind-protect + (save-excursion + (while (setq start (car bounds) + end (cadr bounds)) + (setq end (1- (or end (point-max))) + bounds (cdr bounds)) + (when narrow-flag + (narrow-to-region start end)) + (goto-char start) + (let ((font-lock-mode)) + (hyrolo-cache-set-major-mode (1+ start)) + (setq font-lock-mode nil) ;; Prevent Org mode from font-locking + (funcall func)))) + (when narrow-flag + ;; Restore original restriction + (narrow-to-region ostart oend)) + ;; Restore original mode and font-locking + (funcall omode) + (font-lock-mode (if ofont-lock 1 0)) + (when (fboundp 'orgtbl-mode) + ;; Disable as overrides single letter keys + (orgtbl-mode 0)))) (save-excursion (funcall func))))) (defun hyrolo-funcall-match (func &optional narrow-flag) "Apply FUNC with no arguments to the entry at point. If on a display match entry, set the appropriate major mode based -on its source location. +on its source location prior to applying FUNC. With point in the HyRolo display matches buffer and optional NARROW-FLAG non-nil, narrow to the current file of matches @@ -2598,24 +2597,25 @@ prior to applying FUNC." (unwind-protect (cl-destructuring-bind (start end) (hyrolo-cache-location-start-and-end) - (when end - (setq end (1- end)) - (when narrow-flag - (narrow-to-region start end)) - (let ((font-lock-mode)) - (hyrolo-cache-set-major-mode (1+ start)) - ;; Prevent Org and Outline minor modes from font-locking - (setq font-lock-mode nil) - (funcall func)))) - (when narrow-flag - ;; Restore original restriction - (narrow-to-region ostart oend)) - ;; Restore original mode and font-locking - (funcall omode) - (font-lock-mode (if ofont-lock 1 0)) - (when (fboundp 'orgtbl-mode) - ;; Disable as overrides single letter keys - (orgtbl-mode 0))))) + (setq end (1- (or end (point-max)))) + (when narrow-flag + (narrow-to-region start end)) + (let ((font-lock-mode)) + (hyrolo-cache-set-major-mode (1+ start)) + ;; Prevent Org and Outline minor modes from font-locking + (setq font-lock-mode nil) + (funcall func))) + (with-current-buffer display-buf + ;; func may have changed the current buffer + (when narrow-flag + ;; Restore original restriction + (narrow-to-region ostart oend)) + ;; Restore original mode and font-locking + (funcall omode) + (font-lock-mode (if ofont-lock 1 0)) + (when (fboundp 'orgtbl-mode) + ;; Disable as overrides single letter keys + (orgtbl-mode 0)))))) (funcall func)))) (defun hyrolo-cache-location-start-and-end () diff --git a/hywconfig.el b/hywconfig.el index 891991ac54..673b10acc6 100644 --- a/hywconfig.el +++ b/hywconfig.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 15-Mar-89 -;; Last-Mod: 5-Feb-23 at 16:51:16 by Bob Weiner +;; Last-Mod: 23-Dec-23 at 01:21:23 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -50,9 +50,8 @@ ;;; Other required Elisp libraries ;;; ************************************************************************ -(require 'hargs) +(require 'hargs) ;; this requires 'hypb (require 'ring) -(require 'set) ;;; ************************************************************************ ;;; Public variables @@ -75,58 +74,63 @@ (defun hywconfig-add-by-name (name) "Save the current window configuration under the string NAME. When called interactively and a window configuration already exists under -NAME, confirms whether or not to replace it." +NAME, confirm whether or not to replace it. + +Return t if name is added or replaced, else nil." (interactive "sName for current window configuration: ") (unless (stringp name) (error "(hywconfig-add-by-name): `name' argument is not a string: %s" name)) - (let ((set:equal-op (lambda (key elt) (equal key (car elt)))) - (wconfig-names (hywconfig-get-names))) - (when (or (not (called-interactively-p 'interactive)) - (not (set:member name wconfig-names)) - (y-or-n-p - (format "Replace existing `%s' window configuration? " name))) - (hywconfig-set-names (set:replace name (current-window-configuration) - wconfig-names)) - (when (called-interactively-p 'interactive) - (message - (substitute-command-keys - (format "Window configuration `%s' saved. Use {\\[hywconfig-restore-by-name]} to restore." name))))))) + (when (or (not (called-interactively-p 'interactive)) + (not (member name (hywconfig-named-get-names))) + (y-or-n-p + (format "Replace existing `%s' window configuration? " name))) + (hywconfig-named-put name (current-window-configuration)) + (when (called-interactively-p 'interactive) + (message + (substitute-command-keys + (format "Window configuration `%s' saved. Use {\\[hywconfig-restore-by-name]} to restore." name)))) + t)) ;;;###autoload (defun hywconfig-delete-by-name (name) - "Deletes frame-specific window configuration saved under NAME." + "Delete frame-specific window configuration saved with NAME. + +Return t if name exists and is deleted, else nil." (interactive (list (hargs:read-match "Delete window configuration named: " - (hywconfig-get-names) nil t))) + (hywconfig-named-get-names) nil t))) (cond ((null name) (message "There is no named window configuration to delete.")) ((not (stringp name)) (error "(hywconfig-delete-by-name): `name' argument is not a string: %s" name)) - (t (let ((set:equal-op (lambda (key elt) (equal key (car elt))))) - (hywconfig-set-names (set:remove name (hywconfig-get-names))) - (when (called-interactively-p 'interactive) - (message "Window configuration `%s' has been deleted." name)))))) + (t (let ((removed-flag (hywconfig-named-remove name))) + (when (and removed-flag (called-interactively-p 'interactive)) + (message "Window configuration `%s' has been deleted." name)) + removed-flag)))) ;;;###autoload (defun hywconfig-restore-by-name (name) - "Restore frame-specific window configuration saved under NAME." + "Restore frame-specific window configuration saved with NAME. + +Return t if name exists and is restored, else nil." (interactive (list (hargs:read-match "Restore window configuration named: " - (hywconfig-get-names) nil t))) + (hywconfig-named-get-names) nil t))) (cond ((null name) (message "There is no named window configuration to restore.")) ((not (stringp name)) (error "(hywconfig-restore-by-name): `name' argument is not a string: %s" name)) - (t (let ((wconfig (set:get name (hywconfig-get-names)))) + (t (let ((wconfig (hywconfig-named-get name))) (if wconfig (progn (hywconfig-set-window-configuration wconfig) (when (called-interactively-p 'interactive) - (message "Window configuration `%s' is now active." name))) + (message "Window configuration `%s' is now active." name)) + t) (error "(hywconfig-restore-by-name): No window configuration for this frame named `%s'" name)))))) ;;; Window configuration ring management (like text kill ring). ;;;###autoload (defun hywconfig-delete-pop () - "Replace the current frame's window configuration with the most recently saved. -Then deletes this new configuration from the ring." + "Replace the selected frame's window configuration with the most recently saved. +Then delete this new configuration from the ring." (interactive) (let ((ring (hywconfig-get-ring))) (if (ring-empty-p ring) @@ -138,8 +142,8 @@ Then deletes this new configuration from the ring." ;;;###autoload (defun hywconfig-delete-pop-continue () - "Replace current frame's window configuration with the most recently saved. -Delete this new configuration from the ring. If the hywconfig + "Replace selected frame's window configuration with the most recently saved. +Then delete this new configuration from the ring. If the hywconfig ring is not empty, then stay in the hywconfig menu." (interactive) (hywconfig-delete-pop) @@ -148,12 +152,12 @@ ring is not empty, then stay in the hywconfig menu." ;;;###autoload (defun hywconfig-ring-empty-p () - "Return t if the wconfig ring for the current frame is empty; nil otherwise." + "Return t if the wconfig ring for the selected frame is empty; nil otherwise." (ring-empty-p (hywconfig-get-ring))) ;;;###autoload (defun hywconfig-ring-save () - "Save the current frame's window configuration onto the save ring. + "Save the selected frame's window configuration onto the save ring. Use {\\[hywconfig-yank-pop]} to restore it at a later time." (interactive) (ring-insert (hywconfig-get-ring) (current-window-configuration)) @@ -164,7 +168,7 @@ Use {\\[hywconfig-yank-pop]} to restore it at a later time." ;;;###autoload (defun hywconfig-yank-pop (n) - "Replace current frame's window config with prefix arg Nth prior one in ring. + "Replace selected frame's window config with prefix arg Nth prior one in ring. Interactively, default value of N = 1, means the last saved window configuration is displayed. @@ -181,7 +185,7 @@ oldest one comes the newest one." ;;;###autoload (defun hywconfig-yank-pop-continue (n) - "Replace current frame's window config with prefix arg Nth prior one in ring. + "Replace selected frame's window config with prefix arg Nth prior one in ring. If there are more than one entries in the ring, then stay in the hywconfig menu. Interactively, default value of N = 1, means the last saved window @@ -198,20 +202,34 @@ oldest one comes the newest one." ;;; Private functions ;;; ************************************************************************ -(defun hywconfig-get-names () - "Return the current frame's list of named window configurations." - (let* ((frame (selected-frame)) - (names (frame-parameter frame 'hywconfig-names))) - (unless names - (set-frame-parameter frame 'hywconfig-names (setq names (set:create)))) - names)) +(defun hywconfig-named-get (name) + "Return the selected frame's window configuration with NAME." + (lax-plist-get (hywconfig-named-get-entries) name)) + +(defun hywconfig-named-get-names () + "Return the selected frame's list of window configuration names." + (hypb:map-plist (lambda (name _wconfig) name) (hywconfig-named-get-entries))) + +(defun hywconfig-named-get-entries () + "Get the selected frame's plist of named window configurations." + (frame-parameter (selected-frame) 'named-hywconfigs)) + +(defun hywconfig-named-put (name wconfig) + "Add NAMEd WCONFIG to selected frame's plist of named window configurations." + (hywconfig-named-set-entries (lax-plist-put (hywconfig-named-get-entries) name wconfig))) + +(defun hywconfig-named-remove (name) + "Remove the selected frame's stored window configuration with NAME." + (let ((plist (hywconfig-named-get-entries))) + (prog1 (hypb:remove-from-plist plist name) + (hywconfig-named-set-entries plist)))) -(defun hywconfig-set-names (names) - "Set the current frame's list of named window configurations." - (set-frame-parameter (selected-frame) 'hywconfig-names names)) +(defun hywconfig-named-set-entries (entries) + "Set the selected frame's plist of named window configuration ENTRIES." + (set-frame-parameter (selected-frame) 'named-hywconfigs entries)) (defun hywconfig-get-ring () - "Return the current frame's window configuration ring." + "Return the selected frame's window configuration ring." (let* ((frame (selected-frame)) (ring (frame-parameter frame 'hywconfig-ring))) (unless ring @@ -219,6 +237,7 @@ oldest one comes the newest one." ring)) (defun hywconfig-set-window-configuration (wconfig) + "Return window configureation WCONFIG within the selected frame." (when (window-configuration-p wconfig) (condition-case nil (progn (set-window-configuration wconfig) t) diff --git a/kotl/kotl-mode.el b/kotl/kotl-mode.el index a0b6a1501e..625533207d 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: 15-Dec-23 at 21:59:34 by Bob Weiner +;; Last-Mod: 23-Dec-23 at 01:28:38 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -103,6 +103,8 @@ It provides the following keys: (interactive) (mapc #'make-local-variable '(hyrolo-entry-regexp + hyrolo-entry-group-number + hyrolo-entry-trailing-space-group-number indent-line-function indent-region-function kotl-previous-mode @@ -145,8 +147,15 @@ It provides the following keys: (add-hook 'write-file-functions #'kotl-mode:update-buffer nil 'local) ;; Used by kimport.el functions. (unless (and (boundp 'kotl-previous-mode) kotl-previous-mode - (eq kotl-previous-mode #'kotl-mode)) - (setq hyrolo-entry-regexp (concat "^" kview:outline-regexp) + (eq kotl-previous-mode #'kotl-mode) + (not (string-prefix-p hyrolo-display-buffer (buffer-name)))) + (setq hyrolo-entry-regexp + (concat hyrolo-hdr-regexp + "\\|^" (if (boundp 'hbut:source-prefix) hbut:source-prefix "@loc> ") + "\\|^" kview:outline-regexp) + hyrolo-entry-group-number 2 + hyrolo-entry-trailing-space-group-number 3 + kotl-previous-mode major-mode ;; Override orgtbl-mode keys with kotl-mode-specific ones. minor-mode-overriding-map-alist (list (cons 'orgtbl-mode @@ -222,7 +231,8 @@ It provides the following keys: (hyperb:with-suppressed-warnings ((free-vars kotl-previous-mode)) (setq kotl-previous-mode 'kotl-mode)) (run-mode-hooks 'kotl-mode-hook) - (add-hook 'change-major-mode-hook #'kotl-mode:show-all nil t))) + (unless (string-prefix-p hyrolo-display-buffer (buffer-name)) + (add-hook 'change-major-mode-hook #'kotl-mode:show-all nil t)))) ;;;###autoload (defun kotl-mode:example (&optional example replace-flag) @@ -3414,8 +3424,14 @@ but always operates upon the current view." (kotl-mode:show-tree)) ;; Adapted from outline-reveal-toggle-invisible; called by isearch. (defun kotl-mode:reveal-toggle-invisible (o hidep) - (if (not (eq major-mode 'kotl-mode)) - (outline-reveal-toggle-invisible o hidep) + (if (not (derived-mode-p 'kotl-mode)) + (if (and (eq (current-buffer) hyrolo-display-buffer) + (eq (hyrolo-cache-get-major-mode-from-pos (point)) + 'kotl-mode)) + (hyrolo-funcall-match + (lambda () (outline-reveal-toggle-invisible o hidep)) + t) + (outline-reveal-toggle-invisible o hidep)) (save-excursion (goto-char (overlay-start o)) (if hidep diff --git a/kotl/kview.el b/kotl/kview.el index e3db327cb3..63f8a7edca 100644 --- a/kotl/kview.el +++ b/kotl/kview.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 6/30/93 -;; Last-Mod: 11-Dec-23 at 01:47:48 by Bob Weiner +;; Last-Mod: 20-Dec-23 at 17:27:44 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -88,7 +88,7 @@ Default value is \". \"." :type 'string :group 'hyperbole-koutliner) -(defconst kview:outline-regexp (concat "\\( *\\)[0-9][0-9a-z.]*\\(" +(defconst kview:outline-regexp (concat "\\( *\\)\\([0-9][0-9a-z.]*\\)\\(" (regexp-quote kview:default-label-separator) "\\)") "Koutline view `outline-regexp' value that handles all label formats.") diff --git a/man/hyperbole.texi b/man/hyperbole.texi index 31f875bb3a..562cf9861c 100644 --- a/man/hyperbole.texi +++ b/man/hyperbole.texi @@ -7,7 +7,7 @@ @c Author: Bob Weiner @c @c Orig-Date: 6-Nov-91 at 11:18:03 -@c Last-Mod: 3-Dec-23 at 09:46:58 by Bob Weiner +@c Last-Mod: 21-Dec-23 at 13:10:20 by Bob Weiner @c %**start of header (This is for running Texinfo on a region.) @setfilename hyperbole.info @@ -156,7 +156,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.</P> <PRE> Edition 9.0.0 -Printed December 3, 2023. +Printed December 21, 2023. Published by the Free Software Foundation, Inc. Author: Bob Weiner @@ -198,7 +198,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. @example Edition 9.0.0 -December 3, 2023 +December 21, 2023 Published by the Free Software Foundation, Inc. Author: Bob Weiner @@ -2498,6 +2498,14 @@ Jump to the source line associated with a debugger stack frame or breakpoint line. This works with gdb, dbx, and xdb. Such lines are recognized in any buffer. +@findex ibtypes hib-python-traceback +@cindex pdb +@cindex python traceback +@cindex python error +@cindex source line +@item hib-python-traceback +Test for and jump to line referenced in Python pdb, traceback, or pytype error. + @findex ibtypes grep-msg @cindex grep @cindex compiler error @@ -2506,6 +2514,12 @@ recognized in any buffer. Jump to the line associated with a grep or compilation error message. Messages are recognized in any buffer. +@findex hyrolo-stuck-msg +@cindex hyrolo error +@item hyrolo-stuck-msg +Jump to the position where a HyRolo search has become stuck from the error. +Such errors are recognized in any buffer. + @findex ibtypes ripgrep-msg @cindex grep @cindex ripgrep diff --git a/test/hyrolo-tests.el b/test/hyrolo-tests.el index 04f8c90f5f..6e989e486f 100644 --- a/test/hyrolo-tests.el +++ b/test/hyrolo-tests.el @@ -3,7 +3,7 @@ ;; Author: Mats Lidell <ma...@gnu.org> ;; ;; Orig-Date: 19-Jun-21 at 22:42:00 -;; Last-Mod: 13-Dec-23 at 00:53:18 by Bob Weiner +;; Last-Mod: 23-Dec-23 at 01:25:40 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -173,7 +173,7 @@ and {b} the previous same level cell." (should (hact 'kbd-key "<")) (should (equal (point) (point-min))) - (re-search-forward hyrolo-hdr-regexp nil t 2) + (hyrolo-hdr-move-after-p) (should (hact 'kbd-key "n")) (should (looking-at "\\*\\*\\s-+Strong")) @@ -197,7 +197,7 @@ and {b} the previous same level cell." (should (hact 'kbd-key "<")) (should (equal (point) (point-min))) - (re-search-forward hyrolo-hdr-regexp nil t 2) + (hyrolo-hdr-move-after-p) (should (hact 'kbd-key "n")) (should (looking-at "\\*\\*\\s-+Strong")) @@ -286,10 +286,10 @@ and {b} the previous same level cell." (ert-deftest hyrolo-fgrep-find-all-types-of-files () "Verify that all types of files are found in an fgrep search." (let* ((temporary-file-directory (make-temp-file "hypb" t)) - (org-file (make-temp-file "hypb" nil ".org" "string\n")) - (kotl-file (make-temp-file "hypb" nil ".kotl" "string")) - (md-file (make-temp-file "hypb" nil ".md" "string\n")) - (outl-file (make-temp-file "hypb" nil ".otl" "string\n")) + (org-file (make-temp-file "hypb" nil ".org" "* string\n")) + (kotl-file (make-temp-file "hypb" nil ".kotl" "1. string")) + (md-file (make-temp-file "hypb" nil ".md" "# string\n")) + (outl-file (make-temp-file "hypb" nil ".otl" "* string\n")) (hyrolo-file-list (list temporary-file-directory))) (unwind-protect (progn @@ -374,7 +374,6 @@ and {b} the previous same level cell." (ert-deftest hyrolo-fgrep-and-goto-next-visible-md-heading () "Verify move to next heading, then action-key to go to record for markdown mode." - :expected-result :failed (let* ((temporary-file-directory (make-temp-file "hypb" t)) (md-file (make-temp-file "hypb" nil ".md" "# heading\nstring\nmore\n")) (hyrolo-file-list (list temporary-file-directory))) @@ -385,7 +384,7 @@ and {b} the previous same level cell." (should (= (how-many "@loc>") 1)) (should (looking-at-p "===")) (hyrolo-next-visible-heading 1) - (should (looking-at-p "## heading"))) + (should (looking-at-p "# heading"))) (with-simulated-input "y RET" ; Do you want to revisit the file normally now? (action-key) (should (equal (current-buffer) (find-buffer-visiting md-file))) diff --git a/test/hywconfig-tests.el b/test/hywconfig-tests.el index 6c44ae8ded..82144e5fd1 100644 --- a/test/hywconfig-tests.el +++ b/test/hywconfig-tests.el @@ -3,7 +3,7 @@ ;; Author: Mats Lidell <ma...@gnu.org> ;; ;; Orig-Date: 30-Jan-21 at 12:00:00 -;; Last-Mod: 7-Dec-23 at 23:17:36 by Mats Lidell +;; Last-Mod: 23-Dec-23 at 01:21:53 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -27,7 +27,7 @@ (defun hywconfig-tests--remove-names () "Remove names from frame parameters." - (set-frame-parameter nil 'hywconfig-names nil)) + (set-frame-parameter nil 'named-hywconfigs nil)) (ert-deftest hywconfig--inital-ring-is-empty () "Verify an initial ring is empty." @@ -74,27 +74,19 @@ (ert-deftest hywconfig--add-by-name () "Verify config is added by name." - :expected-result :failed - ;; See backtrace for the error - (wrong-type-argument listp #<window-configuration>) - ;; set:member("config" (#<window-configuration>)) - ;; set:get("config" (#<window-configuration>)) - ;; (let ((wconfig (set:get name (hywconfig-get-names)))) (if wconfig (progn (hywconfig-set-window-configuration wconfig) (if (called-interactively-p 'interactive) (progn (message "Window configuration `%s' is now active." name)))) (error "(hywconfig-restore-by-name): No window configuration for this frame named `%s'" name))) - ;; (cond ((null name) (message "There is no named window configuration to restore.")) ((not (stringp name)) (error "(hywconfig-restore-by-name): `name' argument is not a string: %s" name)) (t (let ((wconfig (set:get name (hywconfig-get-names)))) (if wconfig (progn (hywconfig-set-window-configuration wconfig) (if (called-interactively-p 'interactive) (progn (message "Window configuration `%s' is now active." name)))) (error "(hywconfig-restore-by-name): No window configuration for this [...] - ;; hywconfig-restore-by-name("config") - ;; [...] (hywconfig-tests--remove-names) (hywconfig-add-by-name "config") + (should (hywconfig-named-get "config")) (should (hywconfig-restore-by-name "config"))) (ert-deftest hywconfig--delete-by-name () "Verify config can be deleted by name." - :expected-result :failed ;; Same error as above (hywconfig-tests--remove-names) - (hywconfig-add-by-name "config") - (hywconfig-delete-by-name "config") + (should (hywconfig-add-by-name "config")) + (should (hywconfig-delete-by-name "config")) (let ((err (should-error (hywconfig-restore-by-name "config") :type 'error))) - (should (string--p "No window configuration for this frame named" (cadr err))))) + (should (string-match-p "No window configuration for this frame named" (cadr err))))) (provide 'hywconfig-tests) ;;; hywconfig-tests.el ends here