branch: externals/hyperbole commit 3940e00d12da2e0a16db4ae781b84004b1f5abc4 Author: Bob Weiner <r...@gnu.org> Commit: Bob Weiner <r...@gnu.org>
Fix mult-version/mixed Org installations and hyrolo improvements --- ChangeLog | 25 +++++++++++- Makefile | 22 +++++----- hsys-org.el | 96 ++++++++++++++++++++++++++------------------ hui.el | 12 +++--- hyrolo.el | 69 +++++++++++++++---------------- test/hy-test-dependencies.el | 23 ++++++++--- test/hyrolo-tests.el | 5 ++- 7 files changed, 157 insertions(+), 95 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2bc78a0195..dd7c7c39cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,30 @@ 2024-01-13 Bob Weiner <r...@gnu.org> +* test/hy-test-dependencies.el: Print status of resolving any + multi-version/mixed Org installations. + +* hyrolo.el (hyrolo-any-file-type-problem-p): Disable printing + output if 'hyrolo-boolean-only-flag' is non-nil, used in + testing. + test/hyrolo-tests.el (hyrolo-tests--get-file-list-wrong-suffix): + Use above flag. + +* Makefile (test-ert): Do not ellide any stack traces, i.e. set + 'ert-batch-print-length' to nil. + Change test SELECTOR= to test= and document how to run. + +* hyrolo.el (hyrolo-any-file-type-problem-p): Disable printing of + any output when 'hyrolo-boolean-only-flag' is non-nil, typically + used for testing purposes. + +* hui.el (hui:ebut-unmark): Fix to handle a non-file-based buffer as + 'key-src'. + * hsys-org.el (hsys-org-fix-version): Add. Add .org suffix to - 'auto-mode-alist' as it may be removed in this function. + 'auto-mode-alist' as it may be removed in this function. Return + t when Org is reloaded, nil if not. Require Org libraries even + when no reload is done. Handle when 'org-version' differs from + version number in 'org-dir'. hyperbole.el (hyperb:init): Add call to 'hsys-org-fix-version' when detect a mixed version installation of Org, typically part of built-in Org loaded before loading a newer packaged version. diff --git a/Makefile b/Makefile index e58eae5ad5..5fc7426c91 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ # Author: Bob Weiner # # Orig-Date: 15-Jun-94 at 03:42:38 -# Last-Mod: 7-Jan-24 at 14:27:34 by Bob Weiner +# Last-Mod: 13-Jan-24 at 19:12:58 by Bob Weiner # # Copyright (C) 1994-2023 Free Software Foundation, Inc. # See the file HY-COPY for license information. @@ -70,8 +70,9 @@ # * Developer targets # # To run unit tests: -# make test - run not interactive tests in batch mode -# make test-all - run all tests starting an Emacs in windowed mode +# make test - run non-interactive tests in batch mode +# make test-all - run all tests starting an interactive Emacs +# make test test=<test-name> - run a single test or tests matching the name # # Verify hyperbole installation using different sources: # make install-<source> @@ -459,7 +460,7 @@ packageclean: cd $(pkg_hyperbole)/man/im && $(RM) -r .DS_Store core .place* ._* .*~ *~ \ *.ps *\# *- *.orig *.rej .nfs* CVS .cvsignore; fi -# Ert test +# ERT test .PHONY: tests test test-ert all-tests test-all tests: test test: test-ert @@ -469,10 +470,10 @@ test: test-ert LET_VARIABLES = (auto-save-default) (enable-local-variables :all) LOAD_TEST_ERT_FILES=$(patsubst %,(load-file \"%\"),${TEST_ERT_FILES}) -# Run make test SELECTOR=<ert-test-selector> to limit batch test to +# Run make test test=<ert-test-selector> to limit batch test to # tests specified by the selector. See "(ert)test selectors" -ifeq ($(origin SELECTOR), command line) -HYPB_ERT_BATCH = (ert-run-tests-batch-and-exit \"${SELECTOR}\") +ifeq ($(origin test), command line) +HYPB_ERT_BATCH = (ert-run-tests-batch-and-exit \"${test}\") else HYPB_ERT_BATCH = (ert-run-tests-batch-and-exit) endif @@ -487,9 +488,10 @@ endif test-ert: @echo "# Tests: $(TEST_ERT_FILES)" $(EMACS_BATCH) --eval "(load-file \"test/hy-test-dependencies.el\")" \ - --eval "(let ((auto-save-default) (ert-batch-print-level 10) (ert-batch-print-length 20) \ - $(HYPB_ERT_BATCH_BT) (ert-batch-backtrace-right-margin 2048)) \ - $(LOAD_TEST_ERT_FILES) $(HYPB_ERT_BATCH))" + --eval "(let ((auto-save-default) (ert-batch-print-level 10) \ + (ert-batch-print-length nil) (backtrace-line-length 5000) \ + $(HYPB_ERT_BATCH_BT) (ert-batch-backtrace-right-margin 2048)) \ + $(LOAD_TEST_ERT_FILES) $(HYPB_ERT_BATCH))" all-tests: test-all test-all: diff --git a/hsys-org.el b/hsys-org.el index d4bf3bf9ee..910b0682d9 100644 --- a/hsys-org.el +++ b/hsys-org.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 2-Jul-16 at 14:54:14 -;; Last-Mod: 13-Jan-24 at 16:28:29 by Bob Weiner +;; Last-Mod: 13-Jan-24 at 19:50:40 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -154,45 +154,65 @@ an error." ;;;###autoload (defun hsys-org-fix-version () - "If multiple Org versions are loaded, use the one first on `load-path'." + "If multiple Org versions are loaded, use the one first on `load-path'. +Always ensure Org libraries have been required. +Return t if Org is reloaded, else nil." + ;; Not all versions of org include this variable, so set it + (setq org--inhibit-version-check nil + org-list-allow-alphabetical nil) (let ((org-dir (ignore-errors (org-find-library-dir "org"))) (org-install-dir - (ignore-errors (org-find-library-dir "org-loaddefs")))) - (unless (and org-dir org-install-dir (string-equal org-dir org-install-dir)) - ;; Ensure using any local available packaged version of Org mode - ;; rather than built-in which may have been activated before - ;; load-path was set correctly. Avoids mixed version load of Org. - (mapc (lambda (lib-sym) (when (featurep lib-sym) (unload-feature lib-sym t))) - '(org org-version org-keys org-compat ol org-table org-macs org-id org-element org-list - org-element org-src org-fold)) - (package-initialize) - (let ((pkg-desc (car (cdr (assq 'org package-archive-contents))))) - (package-activate pkg-desc t)) - ;; Not all versions of org include this variable, so set it - (setq org--inhibit-version-check nil - org-list-allow-alphabetical nil) - ;; Otherwise, `font-lock-ensure' make invoke an undefined matcher - ;; function, `org-fontify-inline-src-blocks'. - (load "org-src") - ;; Otherwise, `org-id-get-create' may call undefined - ;; `org-element-cache-active-p' - (load "org-element") - ;; Otherwise, {M-RET} may not be bound to a key - (load "org-keys") - ;; Otherwise, `org-file-name-concat' may be undefined - (load "org-compat") - ;; Otherwise, `org--inhibit-version-check' may be undefined - (load "org-macs") - ;; Otherwise, `org-list-allow-alphabetical' may be undefined - (load "org-list") - ;; Otherwise, `org-fold--advice-edit-commands' may be undefined - (load "org-fold") - ;; Otherwise, `org-link--description-folding-spec' may be undefined - (load "ol") - (cl-flet ((require (lambda (lib-sym &optional _filename _noerror) - (load (symbol-name lib-sym))))) - (require 'org)) - (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))))) + (ignore-errors (org-find-library-dir "org-loaddefs"))) + org-dir-version) + (cond ((and org-dir org-install-dir (string-equal org-dir org-install-dir) + ;; Still may have a situation where the Org version matches the + ;; builtin Org but the directories are for a newer Org + ;; package version. + (if (string-match "[\\/]org-\\([0-9.]+-?[a-z]*\\)" org-dir) + (string-equal (setq org-dir-version (match-string 1 org-dir)) + (remove ?- (org-release))) + t)) + ;; Just require these libraries used for testing to ensure + ;; they are loaded from the single Org version used. + (mapc (lambda (lib-sym) (require lib-sym nil t)) + '(org-version org-keys org-compat ol org-table org-macs org-id + org-element org-list org-element org-src org-fold org)) + nil) + (t + ;; Ensure using any local available packaged version of Org mode + ;; rather than built-in which may have been activated before + ;; load-path was set correctly. Avoids mixed version load of Org. + (mapc (lambda (lib-sym) (when (featurep lib-sym) (unload-feature lib-sym t))) + '(org org-version org-keys org-compat ol org-table org-macs org-id + org-element org-list org-element org-src org-fold)) + (package-initialize) + (let ((pkg-desc (car (cdr (assq 'org package-archive-contents))))) + (package-activate pkg-desc t)) + ;; Otherwise, `font-lock-ensure' make invoke an undefined matcher + ;; function, `org-fontify-inline-src-blocks'. + (load "org-src") + ;; Otherwise, `org-id-get-create' may call undefined + ;; `org-element-cache-active-p' + (load "org-element") + ;; Otherwise, {M-RET} may not be bound to a key + (load "org-keys") + ;; Otherwise, `org-file-name-concat' may be undefined + (load "org-compat") + ;; Otherwise, `org--inhibit-version-check' may be undefined + (load "org-macs") + ;; Otherwise, `org-list-allow-alphabetical' may be undefined + (load "org-list") + ;; Otherwise, `org-fold--advice-edit-commands' may be undefined + (load "org-fold") + ;; Otherwise, `org-link--description-folding-spec' may be undefined + (load "ol") + (cl-flet ((require (lambda (lib-sym &optional _filename _noerror) + (load (symbol-name lib-sym))))) + (require 'org)) + ;; Next setting may have been deleted with the library + ;; unloading, so restore it. + (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode)) + t)))) ;;;###autoload (defun hsys-org-meta-return-shared-p () diff --git a/hui.el b/hui.el index a2d7db4bd5..3d64713b7a 100644 --- a/hui.el +++ b/hui.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 19-Sep-91 at 21:42:03 -;; Last-Mod: 3-Jan-24 at 23:42:18 by Mats Lidell +;; Last-Mod: 13-Jan-24 at 18:55:34 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -1522,10 +1522,12 @@ With a prefix argument, also delete the button text between the delimiters." (when (search-forward ebut:label-end nil t) (funcall form))) ;; Non-interactive invocation. (let (cur-flag) - (if (and (or (null key-src) (eq key-src buffer-file-name)) - (or (null directory) (eq directory default-directory))) - (setq cur-flag t) - (set-buffer (find-file-noselect (expand-file-name key-src directory)))) + (cond ((and (or (null key-src) (eq key-src buffer-file-name)) + (or (null directory) (eq directory default-directory))) + (setq cur-flag t)) + ((bufferp key-src) + (set-buffer key-src)) + (t (set-buffer (find-file-noselect (expand-file-name key-src directory))))) (unless (stringp but-key) (setq but-key (hbut:label-p)) (unless (stringp but-key) diff --git a/hyrolo.el b/hyrolo.el index 8740c4d6f3..a199de2a88 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: 13-Jan-24 at 02:25:54 by Bob Weiner +;; Last-Mod: 13-Jan-24 at 20:04:26 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -2420,40 +2420,41 @@ package is not installed." ;; 6. if not, display a buffer with the invalid file types and return t (when (or files-invalid-suffix-list files-no-mode-list) - (with-help-window "*HyRolo Errors*" - (princ "`hyrolo-file-list' gets its files from these patterns:\n") - (mapc (lambda (spec) (princ (format "\t%S\n" spec))) - hyrolo-file-list) - (terpri) - (princ "When expanded, it includes the following files that HyRolo cannot process:\n\n") - - (when files-invalid-suffix-list - (princ (format "Files with invalid or no suffixes:\n (valid suffixes: %S)\n" - hyrolo-file-suffix-regexp)) - (mapc (lambda (file) (princ (format "\t%S\n" file))) - files-invalid-suffix-list) + (unless (and (boundp 'hyrolo-boolean-only-flag) hyrolo-boolean-only-flag) + (with-help-window "*HyRolo Errors*" + (princ "`hyrolo-file-list' gets its files from these patterns:\n") + (mapc (lambda (spec) (princ (format "\t%S\n" spec))) + hyrolo-file-list) (terpri) - (princ "Please remove the above files from `hyrolo-file-list'.\n") - (terpri)) - - (when files-no-mode-list - (princ "Files with invalid modes (file suffixes not in `auto-mode-alist'):\n") - (mapc (lambda (file) (princ (format "\t%S\n" file))) - files-no-mode-list) - (terpri) - (princ "Please add appropriate entries for the above files to `auto-mode-alist'.\n") - (terpri)) - - (when (hyperb:stack-frame '(hyrolo-file-list-changed)) - ;; Errors occurred with a let of `hyrolo-file-list' so - ;; include backtrace of where this occurred. - (princ "Stack trace of where invalid files were referenced:\n") - (terpri) - ;; (setq backtrace-view (plist-put backtrace-view :show-locals t)) - (backtrace))) - (when noninteractive - (princ (with-current-buffer (get-buffer "*HyRolo Errors*") - (buffer-string)))) + (princ "When expanded, it includes the following files that HyRolo cannot process:\n\n") + + (when files-invalid-suffix-list + (princ (format "Files with invalid or no suffixes:\n (valid suffixes: %S)\n" + hyrolo-file-suffix-regexp)) + (mapc (lambda (file) (princ (format "\t%S\n" file))) + files-invalid-suffix-list) + (terpri) + (princ "Please remove the above files from `hyrolo-file-list'.\n") + (terpri)) + + (when files-no-mode-list + (princ "Files with invalid modes (file suffixes not in `auto-mode-alist'):\n") + (mapc (lambda (file) (princ (format "\t%S\n" file))) + files-no-mode-list) + (terpri) + (princ "Please add appropriate entries for the above files to `auto-mode-alist'.\n") + (terpri)) + + (when (hyperb:stack-frame '(hyrolo-file-list-changed)) + ;; Errors occurred with a let of `hyrolo-file-list' so + ;; include backtrace of where this occurred. + (princ "Stack trace of where invalid files were referenced:\n") + (terpri) + ;; (setq backtrace-view (plist-put backtrace-view :show-locals t)) + (backtrace)) + + (when noninteractive + (princ (buffer-string))))) t))) (defun hyrolo-buffer-exists-p (hyrolo-buf) diff --git a/test/hy-test-dependencies.el b/test/hy-test-dependencies.el index ecf59675c7..7fc56087c5 100644 --- a/test/hy-test-dependencies.el +++ b/test/hy-test-dependencies.el @@ -3,11 +3,11 @@ ;; Author: Mats Lidell <ma...@gnu.org> ;; ;; Orig-Date: 20-Feb-21 at 23:16:00 -;; Last-Mod: 2-Oct-23 at 04:48:58 by Bob Weiner +;; Last-Mod: 13-Jan-24 at 20:08:39 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; -;; Copyright (C) 2021 Free Software Foundation, Inc. +;; Copyright (C) 2021-2024 Free Software Foundation, Inc. ;; See the "HY-COPY" file for license information. ;; ;; This file is part of GNU Hyperbole. @@ -18,12 +18,13 @@ ;;; Code: +(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/")) +(package-initialize) + (require 'hload-path) +(require 'hyperbole) (add-to-list 'load-path (expand-file-name "test" hyperb:dir)) -(package-initialize) -(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/")) - (defun hy-test-ensure-package-installed (pkg-symbol) (unless (package-installed-p pkg-symbol) (package-refresh-contents) @@ -35,5 +36,17 @@ ;; Needed when `hypb:display-file-with-logo' uses `org-mode'. (setq hsys-org-enable-smart-keys t) +(require 'pp) +(terpri) +(print (format "org-directory = %S" (ignore-errors (org-find-library-dir "org")))) +(print (format "ord-load-dir = %S" (ignore-errors (org-find-library-dir "org-loaddefs")))) +(print (format "version = %S" (org-release))) +(terpri) + +(let ((org-reloaded (hsys-org-fix-version))) + (if org-reloaded + (message "Mixed Org versions fixed and reloaded; version is now %s" org-version) + (message "Correct, single version of Org is active %s" org-version))) + (provide 'hy-test-dependencies) ;;; hy-test-dependencies.el ends here diff --git a/test/hyrolo-tests.el b/test/hyrolo-tests.el index 0b3a956164..4ede38fa42 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-Jan-24 at 02:32:45 by Bob Weiner +;; Last-Mod: 13-Jan-24 at 20:05:16 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -464,7 +464,8 @@ Match a string in the second cell." (let ((tmp-file (make-temp-file "hypb" nil))) (unwind-protect (should-error - (let ((hyrolo-file-list (list tmp-file))) + (let* ((hyrolo-boolean-only-flag t) + (hyrolo-file-list (list tmp-file))) ())) (hy-delete-file-and-buffer tmp-file))))