branch: externals/hyperbole
commit 5e6e10dd6e61ae1940dca41114087e9e19db21f3
Author: Bob Weiner <[email protected]>
Commit: Bob Weiner <[email protected]>
elisp-compiler-msg: Add Smart Key support for ERT "Test <symbol>"
Such lines jump to the def of the symbol. Also add support for
symbol and pathname references from backtraces in ERT output.
---
ChangeLog | 4 ++++
hibtypes.el | 40 ++++++++++++++++++++++++++++++----------
2 files changed, 34 insertions(+), 10 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3364aafea8..317b847ea9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+* hibtypes.el (elisp-compiler-msg): Add support for ERT "Test <symbol>"
+ lines to jump to the def of the symbol and for symbol and pathname
+ references from backtraces in ERT output.
+
* hib-debbugs.el (debbugs-version-sufficient-p): Handle if version
is nil due to edebug mocking of 'find-file-noselect'.
test/hui-tests.el (hui-gibut-create-link-to-file,
diff --git a/hibtypes.el b/hibtypes.el
index 384d0cd858..ac1811c6f5 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: 23-Jul-22 at 01:30:20 by Bob Weiner
+;; Last-Mod: 23-Jul-22 at 18:26:19 by Bob Weiner
;;
;; Copyright (C) 1991-2022 Free Software Foundation, Inc.
;; See the "HY-COPY" file for license information.
@@ -38,6 +38,7 @@
(require 'cl-lib) ;; for cl-count
(require 'subr-x) ;; For string-trim
(require 'hactypes)
+(require 'thingatpt)
;;; ************************************************************************
;;; Public variables
@@ -1066,23 +1067,42 @@ This works with JavaScript and Python tracebacks, gdb,
dbx, and xdb. Such lines
;;; ========================================================================
(defib elisp-compiler-msg ()
- "Jump to source code for definition associated with an Emacs Lisp error
message.
-The error may from the Emacs byte compiler, the Emacs Lisp native
+ "Jump to definition of an Emacs Lisp symbol in an error or test message.
+The message may come from the Emacs byte compiler, the Emacs Lisp native
compiler or the Emacs regression test system (ERT).
-This works when activated anywhere within the file line references."
+This works when activated anywhere within file line references."
(when (or (member (buffer-name) '("*Compile-Log-Show*" "*Compile-Log*"
"*compilation*"
"*Async-native-compile-log*" "*ert*"))
(save-excursion
(and (re-search-backward "^[^ \t\n\r]" nil t)
(looking-at "While compiling\\|In \\([^ \n]+\\):$"))))
- (let (src buffer-p label)
+ (let (src buffer-p label start-end
+ lbl-start-end)
(or
;; Emacs Regression Test (ERT) output lines
- (save-excursion
- (forward-line 0)
- (when (looking-at
"\\s-+\\(passed\\|failed\\|skipped\\)\\s-+[0-9]+/[0-9]+\\s-+\\(\\S-+\\)\\s-+(")
- (setq label (match-string-no-properties 2))
- (ibut:label-set label (match-beginning 2) (match-end 2))
+ (when (or (save-excursion
+ (forward-line 0)
+ (or (looking-at
"\\s-+\\(passed\\|failed\\|skipped\\)\\s-+[0-9]+/[0-9]+\\s-+\\(\\S-+\\)\\s-+(")
+ (looking-at
"\\(Test\\)\\s-+\\(\\S-+\\)\\s-+\\(backtrace\\|condition\\):")))
+ ;; Handle symbols and pathnames in a backtrace from an ERT
test exception
+ (save-match-data
+ (and (save-excursion
+ (re-search-backward "^$\\|^Test
\\(\\S-+\\)\\s-+\\(backtrace\\|condition\\):" nil t)
+ (looking-at "Test "))
+ (or
+ ;; Handle double-quoted pathnames
+ (and (setq lbl-start-end
(hpath:delimited-possible-path nil t)
+ label (nth 0 lbl-start-end))
+ (ibut:label-set label (nth 1 lbl-start-end) (nth
2 lbl-start-end)))
+ ;; Handle symbols
+ (and (setq label (thing-at-point 'symbol)
+ start-end (bounds-of-thing-at-point
'symbol))
+ (ibut:label-set label (car start-end) (cdr
start-end)))))))
+ (unless label
+ (setq label (match-string-no-properties 2))
+ (ibut:label-set label (match-beginning 2) (match-end 2)))
+ (if (hpath:is-p label)
+ (hact 'link-to-file label)
;; Remove prefix generated by actype and ibtype definitions.
(setq label (hypb:replace-match-string "[^:]+::" label "" t))
(hact 'smart-tags-display label nil)))