branch: externals/hyperbole commit d5a9715ef0425d9ba9b7fe3e2d399b5cdc0bd7d6 Author: Bob Weiner <r...@gnu.org> Commit: Bob Weiner <r...@gnu.org>
Fix hyrolo-org-mode to conditionalize ref to org-fold if unbound Fix to repair mixed version Org installation so Hyperbole works by calling new function `hsys-org-fix-version' from `hyperb:init'. --- ChangeLog | 26 ++++++++++++++++++++++++-- hargs.el | 10 +++++----- hmouse-drv.el | 8 ++++---- hsys-org.el | 44 +++++++++++++++++++++++++++++++++++++++++++- hsys-xref.el | 4 ++-- hyperbole.el | 14 +++++++++++--- hyrolo.el | 29 +++++++++++++++++++---------- test/demo-tests.el | 1 - test/hui-tests.el | 22 ++-------------------- test/hy-test-helpers.el | 4 ++-- 10 files changed, 112 insertions(+), 50 deletions(-) diff --git a/ChangeLog b/ChangeLog index 84c4bfd58d..2bc78a0195 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,12 +1,34 @@ 2024-01-13 Bob Weiner <r...@gnu.org> +* hsys-org.el (hsys-org-fix-version): Add. Add .org suffix to + 'auto-mode-alist' as it may be removed in this function. + 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. + +* hargs.el (hargs:at-p): Fix 'no-default' arg handling to not select + non-existent dirs and files when no-default is true. + +* hsys-xref.el (hsys-xref-definitions): Fix to pass symbol, not string to + 'ert-test-boundp'. + +* hmouse-drv.el (hkey-help-show): Rename local var from 'org-help' to + 'hkey-org-help' to eliminate any confusion that this is an Org variable. + +* hyrolo.el (hyrolo-any-file-type-problem-p): Print error buffer to stdout + when run noninteractively (batch mode). + +* hyrolo.el (hyrolo-org-mode): Conditionalize org-fold usage as it is only + available in newer Org versions. Add missing forward declarations. + * hyrolo.el (hyrolo-org-mode): Add newer Org 9.7-pre hide/show support. test/hyrolo-tests.el (hyrolo-tests--outline-hide-show-heading, hyrolo-tests--outline-show-when-moving-out-of-hidden-line): The above change fixes these tests, so they have been re-enabled. -* hmouse-tag.el (smart-lisp-identifier-chars): Add @ char as advised functions - use the orig-function@advice-wrapper-name to refer to the advice. +* hmouse-tag.el (smart-lisp-identifier-chars): Add @ char as advised + functions use the orig-function@advice-wrapper-name to refer to the + advice. * hpath.el (hpath:variables): Move 'load-path' and 'exec-path' before 'Info-directory-list' as they should be higher priority matches. diff --git a/hargs.el b/hargs.el index fb58c616a3..355a01007b 100644 --- a/hargs.el +++ b/hargs.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 31-Oct-91 at 23:17:35 -;; Last-Mod: 1-Dec-23 at 11:23:52 by Bob Weiner +;; Last-Mod: 13-Jan-24 at 16:09:00 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -658,9 +658,9 @@ Handles all of the interactive argument types that `hargs:iform-read' does." ((hpath:at-p 'file)) ;; Unquoted remote file name. ((hpath:is-p (hpath:remote-at-p) 'file)) - ;; Possibly non-existent file name - ((when no-default (hpath:at-p 'file 'non-exist))) (no-default nil) + ;; Possibly non-existent file name + ((hpath:at-p 'file 'non-exist)) ((buffer-file-name)))) ((eq hargs:reading-type 'directory) (cond ((derived-mode-p 'dired-mode) @@ -672,9 +672,9 @@ Handles all of the interactive argument types that `hargs:iform-read' does." ((hpath:at-p 'directory)) ;; Unquoted remote directory name. ((hpath:is-p (hpath:remote-at-p) 'directory)) - ;; Possibly non-existent directory name - ((when no-default (hpath:at-p 'directory 'non-exist))) (no-default nil) + ;; Possibly non-existent directory name + ((hpath:at-p 'directory 'non-exist)) (default-directory))) ((eq hargs:reading-type 'string) (or (hargs:delimited "\"" "\"") (hargs:delimited "'" "'") diff --git a/hmouse-drv.el b/hmouse-drv.el index fa7f3822f4..fb40cad7ef 100644 --- a/hmouse-drv.el +++ b/hmouse-drv.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 04-Feb-90 -;; Last-Mod: 3-Jan-24 at 02:24:39 by Bob Weiner +;; Last-Mod: 13-Jan-24 at 15:32:40 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -1240,7 +1240,7 @@ the current window. By default, it is displayed according to the setting of `hpath:display-where'." (if (bufferp buffer) (setq buffer (buffer-name buffer))) (if (null buffer) (setq buffer (buffer-name (current-buffer)))) - (let ((org-help (and (stringp buffer) (string-match "\\`\\*Org Help\\*" buffer))) + (let ((hkey-org-help (and (stringp buffer) (string-match "\\`\\*Org Help\\*" buffer))) (owind (selected-window))) (and (stringp buffer) (string-match "^\\*Help\\|Help\\*$" buffer) @@ -1262,7 +1262,7 @@ the current window. By default, it is displayed according to the setting of (selected-window)) (t (hpath:display-buffer buf))))) ;; Ignore org-mode's temp help buffers which it handles on its own. - (when (and wind (not org-help)) + (when (and wind (not hkey-org-help)) (setq minibuffer-scroll-window wind) ;; Don't use help-mode in buffers already set up with a ;; quit-key to bury the buffer, e.g. minibuffer completions, @@ -1275,7 +1275,7 @@ the current window. By default, it is displayed according to the setting of (when (derived-mode-p 'help-mode) (local-set-key "q" #'hkey-help-hide))))) ;; If in an *Org Help* buffer, reselect the Org buffer. - (when org-help + (when hkey-org-help (select-window owind)) ;; If in a *Completions* buffer, re-select the window that ;; generated the completions. diff --git a/hsys-org.el b/hsys-org.el index 2b3e0c1fba..d4bf3bf9ee 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 02:28:50 by Bob Weiner +;; Last-Mod: 13-Jan-24 at 16:28:29 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -152,6 +152,48 @@ an error." ;;; Public functions ;;; ************************************************************************ +;;;###autoload +(defun hsys-org-fix-version () + "If multiple Org versions are loaded, use the one first on `load-path'." + (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))))) + ;;;###autoload (defun hsys-org-meta-return-shared-p () "Return non-nil if hyperbole-mode is active and shares the org-meta-return key." diff --git a/hsys-xref.el b/hsys-xref.el index 13b441e6af..e02fff0609 100644 --- a/hsys-xref.el +++ b/hsys-xref.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 24-Aug-91 -;; Last-Mod: 9-Jan-24 at 12:07:34 by Bob Weiner +;; Last-Mod: 13-Jan-24 at 15:55:13 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -31,7 +31,7 @@ (let* ((elisp-flag (smart-emacs-lisp-mode-p)) (xref-backend (or (and elisp-flag (fboundp 'ert-test-boundp) - (ert-test-boundp identifier) + (ert-test-boundp (intern-soft identifier)) (boundp 'xref-etags-mode) 'etags) (xref-find-backend))) diff --git a/hyperbole.el b/hyperbole.el index 6e7e7f8dc1..ee11cbf1bf 100644 --- a/hyperbole.el +++ b/hyperbole.el @@ -8,7 +8,7 @@ ;; 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-Jan-24 at 02:27:05 by Bob Weiner +;; Last-Mod: 13-Jan-24 at 16:28:45 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 @@ -496,6 +496,13 @@ frame, those functions by default still return the prior frame." 'buttons t))) ;; + ;; This next function call must be run before any tests involving Org + ;; in case the user has installed a new version of Org but Emacs has + ;; loaded parts of Org before his load path is finalized. It loads + ;; the newer version of Org, if any, assuming `load-path' is configured + ;; correctly. + (hsys-org-fix-version) + ;; ;; When vertico-mode is used, vertico-mouse-mode is needed for the ;; Action Key to properly select completions from the candidate ;; list, so force its usage when vertico-mode is invoked. @@ -505,9 +512,10 @@ frame, those functions by default still return the prior frame." ;; ;; Hyperbole initialization is complete. (message "Initializing Hyperbole...done")) + -;; This call loads the rest of the Hyperbole system. -(require 'hinit) + ;; This call loads the rest of the Hyperbole system. + (require 'hinit) (defun hyperbole--enable-mode () "Enable Hyperbole global minor mode." diff --git a/hyrolo.el b/hyrolo.el index 849325033c..8740c4d6f3 100644 --- a/hyrolo.el +++ b/hyrolo.el @@ -62,9 +62,12 @@ (defvar helm-org-rifle-show-level-stars) (defvar hproperty:but-emphasize-flag) (defvar markdown-regex-header) +(defvar org-fold-core-style) +(defvar org-link--link-folding-spec) (defvar org-roam-db-autosync-mode) (defvar org-roam-directory) (defvar plstore-cache-passphrase-for-symmetric-encryption) +(defvar reveal-auto-hide) (declare-function consult-grep "ext:consult") (declare-function consult-ripgrep "ext:consult") @@ -79,6 +82,8 @@ (declare-function helm-org-rifle-org-directory "ext:helm-org-rifle") (declare-function helm-org-rifle-show-full-contents "ext:helm-org-rifle") (declare-function kotl-mode:to-valid-position "kotl/kotl-mode") +(declare-function org-fold-initialize "org-fold") +(declare-function org-fold-core-set-folding-spec-property "org-fold") (declare-function org-roam-db-autosync-mode "ext:org-roam") (declare-function xml-node-child-string "ext:google-contacts") (declare-function xml-node-get-attribute-type "ext:google-contacts") @@ -2446,6 +2451,9 @@ package is not installed." (terpri) ;; (setq backtrace-view (plist-put backtrace-view :show-locals t)) (backtrace))) + (when noninteractive + (princ (with-current-buffer (get-buffer "*HyRolo Errors*") + (buffer-string)))) t))) (defun hyrolo-buffer-exists-p (hyrolo-buf) @@ -2605,16 +2613,17 @@ Any non-nil value returned is a cons of (<entry-name> . <entry-source>)." ;; checks will pass. (put 'hyrolo-org-mode 'derived-mode-parent 'org-mode) - (when (and org-link-descriptive - (eq org-fold-core-style 'overlays)) - (add-to-invisibility-spec '(org-link))) - (org-fold-initialize (or (and (stringp org-ellipsis) (not (equal "" org-ellipsis)) org-ellipsis) - "...")) - (make-local-variable 'org-link-descriptive) - (when (eq org-fold-core-style 'overlays) (add-to-invisibility-spec '(org-hide-block . t))) - (if org-link-descriptive - (org-fold-core-set-folding-spec-property (car org-link--link-folding-spec) :visible nil) - (org-fold-core-set-folding-spec-property (car org-link--link-folding-spec) :visible t)) + (when (featurep 'org-fold) ;; newer Org versions + (when (and org-link-descriptive + (eq org-fold-core-style 'overlays)) + (add-to-invisibility-spec '(org-link))) + (org-fold-initialize (or (and (stringp org-ellipsis) (not (equal "" org-ellipsis)) org-ellipsis) + "...")) + (make-local-variable 'org-link-descriptive) + (when (eq org-fold-core-style 'overlays) (add-to-invisibility-spec '(org-hide-block . t))) + (if org-link-descriptive + (org-fold-core-set-folding-spec-property (car org-link--link-folding-spec) :visible nil) + (org-fold-core-set-folding-spec-property (car org-link--link-folding-spec) :visible t))) (setq-local hyrolo-entry-regexp "^\\(\\*+\\)\\([ ]+\\)" hyrolo-hdr-and-entry-regexp (concat hyrolo-hdr-prefix-regexp hyrolo-entry-regexp) diff --git a/test/demo-tests.el b/test/demo-tests.el index 0b1c328de8..8414396d6e 100644 --- a/test/demo-tests.el +++ b/test/demo-tests.el @@ -274,7 +274,6 @@ (should (not (org-check-for-hidden 'headlines))) (save-excursion (action-key)) -;;; (org-hide-entry) (should (org-check-for-hidden 'headlines))))) ;; Manifest diff --git a/test/hui-tests.el b/test/hui-tests.el index a6dbac09bd..28e51208af 100644 --- a/test/hui-tests.el +++ b/test/hui-tests.el @@ -3,7 +3,7 @@ ;; Author: Mats Lidell <ma...@gnu.org> ;; ;; Orig-Date: 30-Jan-21 at 12:00:00 -;; Last-Mod: 30-Dec-23 at 00:00:18 by Bob Weiner +;; Last-Mod: 13-Jan-24 at 16:30:08 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -935,25 +935,7 @@ With point on label suggest that ibut for rename." (ert-deftest hui--link-possible-types () "Verify right type is selected from referent buffer." - ;; 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)) - (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) - (load "org-keys") ;; Otherwise, {M-RET} may not be bound to a key - (load "org-compat") ;; Otherwise, `org-file-name-concat' may be undefined - (load "org-macs") ;; Otherwise, `org--inhibit-version-check' may be undefined - (load "org-list") ;; Otherwise, `org-list-allow-alphabetical' may be undefined - (load "ol") ;; Otherwise, `org-link--description-folding-spec' may be undefined - (cl-flet ((require (lambda (lib-sym &optional _filename _noerror) - (load (symbol-name lib-sym))))) - (require 'org)) + (hsys-org-fix-version) ;; Org Roam or Org Id link-to-org-id (let ((file (make-temp-file "hypb" nil ".org"))) diff --git a/test/hy-test-helpers.el b/test/hy-test-helpers.el index 80bd4814f3..1ac28dd1a4 100644 --- a/test/hy-test-helpers.el +++ b/test/hy-test-helpers.el @@ -3,7 +3,7 @@ ;; Author: Mats Lidell <ma...@gnu.org> ;; ;; Orig-Date: 30-Jan-21 at 12:00:00 -;; Last-Mod: 7-Jan-24 at 00:56:08 by Mats Lidell +;; Last-Mod: 13-Jan-24 at 16:21:45 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -19,7 +19,7 @@ ;;; Code: (require 'ert) -(require 'hmouse-drv) ;For `action-key'. +(require 'hmouse-drv) ; For `action-key' (eval-when-compile (require 'cl-lib)) (defun hy-test-helpers:consume-input-events ()