branch: externals/hyperbole commit 9e77bdf62ef5612a30cd0a55591a219d4824fb01 Author: Bob Weiner <r...@gnu.org> Commit: Bob Weiner <r...@gnu.org>
Fix cyclic call bug that made Elisp lookups slow in ChangeLog mode Make lisp mode boolean functions use derived-mode-p instead of direct major-mode comparisons. hsys-org-log-and-fix-version - Add to log state when fixing a mixed Org mode installation. hy-test-dependencies.el: Remove require of 'pp' library; move logging into "hsys-org.el". Improve log msgs for this function. hyrolo-map-matches, hyrolo-funcall-match - Move 'sit-for' to the end of the functions. Remove # quoting around function lists as edebug cannot handle this. --- ChangeLog | 28 ++++++++++++++++ hbut.el | 4 +-- hib-debbugs.el | 6 ++-- hmouse-tag.el | 23 +++++++------ hsys-org.el | 80 +++++++++++--------------------------------- hsys-xref.el | 4 +-- hui-menu.el | 4 +-- hui-mouse.el | 16 ++++----- hui-window.el | 4 +-- hyrolo.el | 20 +++++------ test/hy-test-dependencies.el | 18 +++------- 11 files changed, 93 insertions(+), 114 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0b28e17d38..4a2bf96125 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,31 @@ +2024-01-21 Bob Weiner <r...@gnu.org> + +* hmouse-tag.el (smart-emacs-lisp-mode-p ,smart-lisp-mode-p): Change to use + 'derived-mode-p' rather than checking for 'major-mode' matches directly. + (smart-emacs-lisp-mode-p): Add optional 'skip-identifier-flag'. + hsys-xref.el (hsys-xref-definitions): Use above flag to fix improper cyclic + calling of 'smart-emacs-lisp-mode-p'; visible as very slow Elisp tag finding + in ChangeLog mode. + +* hsys-org.el (hsys-org-log-and-fix-version): Add to log state when fixing a mixed + Org mode installation. + test/hy-test-dependencies.el: Remove require of 'pp' library and move logging + into "hsys-org.el". + +* hyrolo.el (hyrolo-map-matches, hyrolo-funcall-match): Move 'sit-for' to the end + of the function to ensure happens last. + +* hui-window.el (hmouse-alist-add-window-handlers): + hui-mouse.el (outline-mode-hook): + hui-menu.el (hui-menu-about): + hmouse-tag.el (smart-emacs-lisp-mode-p, smart-tags-noselect-function): + hib-debbugs.el (debbugs-gnu): + hbut.el (hbut:ibut-key-list): Remove # quoting around function lists as edebug + cannot handle this. + +* test/hy-test-dependencies.el (hsys-org-fix-version): Improve log msgs for + this function. + 2024-01-20 Bob Weiner <r...@gnu.org> * hsettings.el (hyperbole-web-search, hyperbole-read-web-search-arguments): Update diff --git a/hbut.el b/hbut.el index 8107abd944..fa09f5dd90 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: 20-Jan-24 at 00:21:10 by Mats Lidell +;; Last-Mod: 21-Jan-24 at 10:31:14 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -1686,7 +1686,7 @@ Keys in optional KEY-SRC or the current buffer." (when (hbut:key-src-set-buffer (or key-src (current-buffer))) (save-restriction (widen) - (ibut:label-map #'(lambda (label _start _end) (ibut:label-to-key label))))))) + (ibut:label-map (lambda (label _start _end) (ibut:label-to-key label))))))) ;;; ======================================================================== ;;; ibut class - Implicit Hyperbole Buttons diff --git a/hib-debbugs.el b/hib-debbugs.el index ca5ea6dfa0..f649fa8d5e 100644 --- a/hib-debbugs.el +++ b/hib-debbugs.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 21-Jun-16 at 14:24:53 -;; Last-Mod: 20-Jan-24 at 20:15:21 by Mats Lidell +;; Last-Mod: 21-Jan-24 at 10:32:46 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -90,8 +90,8 @@ ;;; ************************************************************************ (eval-after-load "debbugs-gnu" - #'(progn (push "hyperbole" debbugs-gnu-all-packages) - (push "oo-browser" debbugs-gnu-all-packages))) + '(progn (push "hyperbole" debbugs-gnu-all-packages) + (push "oo-browser" debbugs-gnu-all-packages))) ;;; ************************************************************************ ;;; Public implicit button types diff --git a/hmouse-tag.el b/hmouse-tag.el index 97876a242a..38c33d10d0 100644 --- a/hmouse-tag.el +++ b/hmouse-tag.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 24-Aug-91 -;; Last-Mod: 20-Jan-24 at 20:21:57 by Mats Lidell +;; Last-Mod: 21-Jan-24 at 12:43:04 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -395,19 +395,22 @@ When optional NO-FLASH, do not flash." (ignore-errors (require 'cc-mode) (c-initialize-cc-mode)) nil) -(defun smart-emacs-lisp-mode-p () +(defun smart-emacs-lisp-mode-p (&optional skip-identifier-flag) "Return non-nil if in a mode using Emacs Lisp symbols." ;; Beyond Lisp files, Emacs Lisp symbols appear frequently in Byte-Compiled ;; buffers, debugger buffers, program ChangeLog buffers, Help buffers, - ;; *Warnings*, *Flymake log* and *Flymake diagnostics... buffers. - (or (memq major-mode #'(emacs-lisp-mode lisp-interaction-mode - debugger-mode ert-results-mode)) + ;; *Warnings*, *Flymake log* and *Flymake diagnostics buffers. + (or (apply #'derived-mode-p '(emacs-lisp-mode lisp-interaction-mode + debugger-mode ert-results-mode)) (string-match-p (concat "\\`\\*\\(Warnings\\|Flymake log\\|Compile-Log\\(-Show\\)?\\)\\*" "\\|\\`\\*Flymake diagnostics") (buffer-name)) - (and (or (memq major-mode #'(help-mode change-log-mode)) + ;; Consider the following buffer types only if on an Emacs Lisp + ;; symbol that can be looked up, e.g. in a TAGS file or via a + ;; previous symbol load. + (and (or (apply #'derived-mode-p '(help-mode change-log-mode)) (string-match-p "\\`\\*Help\\|Help\\*\\'" (buffer-name))) - (smart-lisp-at-known-identifier-p)))) + (or skip-identifier-flag (smart-lisp-at-known-identifier-p))))) (defun smart-fortran (&optional identifier next) "Jump to the definition of optional Fortran IDENTIFIER or the one at point. @@ -761,7 +764,7 @@ Return matching Elisp tag name that point is within, else nil." (when (derived-mode-p 'change-log-mode) (let ((identifier (smart-lisp-at-tag-p))) (and identifier (intern-soft identifier) - (string-match "[^-]-[^-]" identifier) + (string-match-p "[^-]-[^-]" identifier) identifier)))) (defun smart-lisp-htype-tag (tag) @@ -837,7 +840,7 @@ on the first line of a non-alias Lisp definition." (defun smart-lisp-mode-p () "Return t if in a mode which use Lisp symbols." (or (smart-emacs-lisp-mode-p) - (memq major-mode '(lisp-mode scheme-mode)))) + (apply #'derived-mode-p '(lisp-mode scheme-mode)))) ;;;###autoload (defun smart-objc (&optional identifier next) @@ -1544,7 +1547,7 @@ to look. If no tags file is found, an error is signaled." "Return the best available function for finding a tag definition. The function does not select the tag definition." (car (delq nil (mapcar (lambda (func) (if (fboundp func) func)) - #'(hsys-xref-definition find-tag-noselect find-tag-internal))))) + '(hsys-xref-definition find-tag-noselect find-tag-internal))))) (provide 'hmouse-tag) diff --git a/hsys-org.el b/hsys-org.el index 651ad8839b..399d1196ec 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: 20-Jan-24 at 20:19:11 by Mats Lidell +;; Last-Mod: 21-Jan-24 at 11:47:53 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -226,66 +226,24 @@ Return t if Org is reloaded, else nil." builtin-org-files)))) builtin-org-libraries-loaded)) -;; !! Delete this after fully testing replacement version -(defun hsys-org-OLD-fix-version () - "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")))) - (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 (match-string 1 org-dir) ;; org-dir version - (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-log-and-fix-version () + "Log before/after state of Org libraries when fixing a mixed installation." + (terpri) + (princ (format "Org source dir = %S" (ignore-errors (org-find-library-dir "org")))) + (terpri) + (princ (format "Org load dir = %S" (ignore-errors (org-find-library-dir "org-loaddefs")))) + (terpri) + (princ (format "Org version = %S" (org-release))) + (terpri) + + (let ((org-reloaded (hsys-org-fix-version))) + (if org-reloaded + (princ (format "Mixed Org versions fixed and reloaded\n version is now %s\n source dir is now %S" + org-version (ignore-errors (org-find-library-dir "org")))) + (princ "The above is the active, single version of Org"))) + (terpri) + (terpri)) ;;;###autoload (defun hsys-org-meta-return-shared-p () diff --git a/hsys-xref.el b/hsys-xref.el index a7d72a11ad..4be90a04be 100644 --- a/hsys-xref.el +++ b/hsys-xref.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 24-Aug-91 -;; Last-Mod: 20-Jan-24 at 20:19:45 by Mats Lidell +;; Last-Mod: 21-Jan-24 at 12:42:59 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -34,7 +34,7 @@ (defun hsys-xref-definitions (identifier) "Return a list of all definitions of string IDENTIFIER." - (let* ((elisp-flag (smart-emacs-lisp-mode-p)) + (let* ((elisp-flag (smart-emacs-lisp-mode-p t)) (xref-backend (or (and elisp-flag (fboundp 'ert-test-boundp) (ert-test-boundp (intern-soft identifier)) diff --git a/hui-menu.el b/hui-menu.el index cb17050d1f..7d3bd8abbd 100644 --- a/hui-menu.el +++ b/hui-menu.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 28-Oct-94 at 10:59:44 -;; Last-Mod: 19-Jan-24 at 14:19:19 by Mats Lidell +;; Last-Mod: 21-Jan-24 at 10:31:58 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -206,7 +206,7 @@ Return t if cutoff, else nil." (if (= (aref hyperb:version 0) ?0) (substring hyperb:version 1) hyperb:version)) - #'(hypb:display-file-with-logo "HY-ABOUT") + '(hypb:display-file-with-logo "HY-ABOUT") t)) (defconst hui-menu-options diff --git a/hui-mouse.el b/hui-mouse.el index d9bbeb3fc8..73fd9014ae 100644 --- a/hui-mouse.el +++ b/hui-mouse.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 04-Feb-89 -;; Last-Mod: 20-Jan-24 at 20:19:54 by Mats Lidell +;; Last-Mod: 21-Jan-24 at 10:31:44 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -1948,13 +1948,13 @@ handled by the separate implicit button type, `org-link-outside-org-mode'." "Non-nil means outline region was cut and is ready to be pasted at point.") (eval-after-load "outline" - #'(mapc (lambda (mode) - (add-hook mode (lambda () - (make-local-variable 'smart-outline-cut) - ;; Non-nil means outline region was cut - ;; and is available to be pasted at point. - (setq smart-outline-cut nil)))) - '(outline-mode-hook outline-minor-mode-hook))) + '(mapc (lambda (mode) + (add-hook mode (lambda () + (make-local-variable 'smart-outline-cut) + ;; Non-nil means outline region was cut + ;; and is available to be pasted at point. + (setq smart-outline-cut nil)))) + '(outline-mode-hook outline-minor-mode-hook))) (defun smart-outline-level () "Return outline level if point is on a line that begins with `outline-regexp'. diff --git a/hui-window.el b/hui-window.el index 0ea79743cc..5cf2965f19 100644 --- a/hui-window.el +++ b/hui-window.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 21-Sep-92 -;; Last-Mod: 20-Jan-24 at 20:22:03 by Mats Lidell +;; Last-Mod: 21-Jan-24 at 10:32:38 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -183,7 +183,7 @@ and release to register a diagonal drag.") (defvar hmouse-alist) (defun hmouse-alist-add-window-handlers () "Add Smart Mouse Key drag actions to `hmouse-alist'." - (unless (assoc #'(hmouse-inactive-minibuffer-p) hmouse-alist) + (unless (assoc '(hmouse-inactive-minibuffer-p) hmouse-alist) (setq hmouse-alist (append '( diff --git a/hyrolo.el b/hyrolo.el index 8272339252..c054a11e35 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: 20-Jan-24 at 20:22:18 by Mats Lidell +;; Last-Mod: 21-Jan-24 at 10:54:37 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -1945,7 +1945,7 @@ When found, return the match start position." (match-beginning 0))) ;;; In `hyrolo-mode' replace `outline-minor-mode' bindings with hyrolo-* overrides. -;;; Wrap outline movement commands with a `hyrolo-funcall-match' call +;;; Wrap outline movement commands with a `hyrolo-funcall-match' call. ;;; Wrap outline whole buffer commands with a `hyrolo-map-matches' call. (defun hyrolo-outline-back-to-heading (&optional invisible-ok) "Move to previous heading line, or beg of this line if it's a heading. @@ -2917,13 +2917,13 @@ prior to applying FUNC." (when (and (fboundp 'orgtbl-mode) orgtbl-mode) ;; Disable as overrides single letter keys (orgtbl-mode 0)) - ;; This pause forces a window redisplay that maximizes the - ;; entries displayed for any final location of point. - (sit-for 0.001) ;; Need to leave point on a visible character or since ;; hyrolo uses reveal-mode, redisplay will rexpand ;; hidden entries to make point visible. - (hyrolo-back-to-visible-point))) + (hyrolo-back-to-visible-point) + ;; This pause forces a window redisplay that maximizes the + ;; entries displayed for any final location of point. + (sit-for 0.001))) (let ((outline-regexp hyrolo-hdr-and-entry-regexp)) (save-excursion (funcall func)))))) @@ -2976,13 +2976,13 @@ proper major mode." (when (and (fboundp 'orgtbl-mode) orgtbl-mode) ;; Disable as overrides single letter keys (orgtbl-mode 0)) - ;; This pause forces a window redisplay that maximizes the - ;; entries displayed for any final location of point. - (sit-for 0.0001) ;; Need to leave point on a visible character or since ;; hyrolo uses reveal-mode, redisplay will rexpand ;; hidden entries to make point visible. - (hyrolo-back-to-visible-point))))) + (hyrolo-back-to-visible-point) + ;; This pause forces a window redisplay that maximizes the + ;; entries displayed for any final location of point. + (sit-for 0.0001))))) (let ((outline-regexp hyrolo-hdr-and-entry-regexp)) (funcall func))))) diff --git a/test/hy-test-dependencies.el b/test/hy-test-dependencies.el index a7bcf2de9c..95762d0f19 100644 --- a/test/hy-test-dependencies.el +++ b/test/hy-test-dependencies.el @@ -3,7 +3,7 @@ ;; Author: Mats Lidell <ma...@gnu.org> ;; ;; Orig-Date: 20-Feb-21 at 23:16:00 -;; Last-Mod: 20-Jan-24 at 09:56:08 by Mats Lidell +;; Last-Mod: 21-Jan-24 at 11:42:52 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -33,21 +33,11 @@ (mapc (lambda (sym) (hy-test-ensure-package-installed sym)) '(el-mock with-simulated-input)) -;; Needed when `hypb:display-file-with-logo' uses `org-mode'. +;; Needed when `hypb:display-file-with-logo' uses `org-mode' (setq hsys-org-enable-smart-keys t) -(require 'pp) -(terpri) -(print (format "Org source dir = %S" (ignore-errors (org-find-library-dir "org")))) -(print (format "Org load dir = %S" (ignore-errors (org-find-library-dir "org-loaddefs")))) -(print (format "Org version = %S" (org-release))) -(terpri) - -(let ((org-reloaded (hsys-org-fix-version))) - (if org-reloaded - (message "Mixed Org versions fixed and reloaded\n version is now %s\n source dir is now %S" - org-version (ignore-errors (org-find-library-dir "org"))) - (message "Correct, single version of Org is active %s" org-version))) +;; Log and fix any mixed version Org installation +(hsys-org-log-and-fix-version) (provide 'hy-test-dependencies) ;;; hy-test-dependencies.el ends here