-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #650 from rswgnu/rsw
ert-should ibtype; hypb:with-macro; rewrite of Hyperbole {C-w} and {M-w} commands and updates to tests
- Loading branch information
Showing
11 changed files
with
371 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,54 @@ | ||
2025-01-20 Bob Weiner <[email protected]> | ||
|
||
* hsys-ert.el (require 'hbut): For 'defib'. | ||
|
||
* test/hui-tests.el (hui--kill-highlighted-region, | ||
hui--kill-non-highlighted-region): Separate and rename | ||
these tests. Rearrange letters in each subtest so can find which should | ||
is being called. | ||
|
||
* hui.el (hui:validate-region): Add to check for valid region args. | ||
(hui-kill-ring-save): Call above function. | ||
|
||
* test/hui-tests.el (hui--kill-region, | ||
hui--kill-region-multiple-kill): Add let of | ||
'mark-even-if-inactive'. Also, interactively, set beg and end only | ||
if 'mark-active' is non-nil. | ||
|
||
2025-01-19 Bob Weiner <[email protected]> | ||
|
||
* hui.el (hui:kill-region): Complete doc string. Set 'region' arg to nil when | ||
killing a delimited region at point. Also use 'hui-select-at-delimited-thing-p' | ||
instead of 'hui-select-delimited-thing'. | ||
(hui:delimited-selectable-thing) | ||
hui:delimited-selectable-thing-and-bounds): Fix so doesn't create an | ||
in-memory Hyperbole button at point if already doing so in a prior stack frame. | ||
The latter is used in 'hui-kill-ring-save' bound to {M-w} in 'hyperbole-mode'. | ||
(require 'hversion): Since 'hyperb:stack-frame' is defined there and | ||
used herein. | ||
|
||
* hsys-ert.el (ert-should): Add this new file and implicit button type. | ||
See the Commentary therein for details. | ||
hibtypes.el (load "hsys-ert"): Load above ibtype at near lowest priority. | ||
hui-mouse.el (hkey-alist): Move priority of ert-results-mode to after | ||
(hbut:at-p) so can define implicit buttons in this mode that override | ||
the standard behavior. | ||
man/hyperbole.texi (Smart Key - ERT Results Mode): Update order in the | ||
Hyperbole manual. Also add `ert-should' ibtype. | ||
MANIFEST, Makefile (EL_COMPILE): Add "hsys-ert.el". | ||
|
||
* hypb.el (hypb:with-marker): Add context macro for setting a buffer marker | ||
and automatically setting it to nil at the end of the context. | ||
|
||
* hui.el (hui:kill-region): Update to only apply completion behavior when | ||
'dynamic-completion-mode' is enabled and call subfunctions interactively | ||
in interactive flag is set. | ||
(hui-kill-region): Simplify 'hui-select-delimited-thing'. | ||
|
||
2025-01-19 Mats Lidell <[email protected]> | ||
|
||
* test/hui-tests.el (hui--kill-region-multiple-kill, hui--kill-region): | ||
Test hui-kill-region. | ||
Test hui-kill-region. | ||
|
||
2025-01-18 Bob Weiner <[email protected]> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
;;; hsys-ert.el --- Hyperbole support for jumping to ert 'should' source lines -*- lexical-binding: t -*- | ||
;; | ||
;; Author: Bob Weiner | ||
;; | ||
;; Orig-Date: 19-Jan-25 | ||
;; Last-Mod: 20-Jan-25 at 02:00:12 by Bob Weiner | ||
;; | ||
;; SPDX-License-Identifier: GPL-3.0-or-later | ||
;; | ||
;; Copyright (C) 2025 Free Software Foundation, Inc. | ||
;; See the "HY-COPY" file for license information. | ||
;; | ||
;; This file is part of GNU Hyperbole. | ||
|
||
;;; Commentary: | ||
;; | ||
;; ERT is the Emacs Regression Test framework in "ert.el". Hyperbole uses | ||
;; it for all of its regression testing as well. | ||
;; | ||
;; Sometimes when building Emacs Lisp tests with the ERT package, multiple | ||
;; tests are added to a single test fixture/function. Each subtest | ||
;; has its own `should'-type clause. But if one of these subtests fails, | ||
;; ERT shows you the test name and the should clause in its results buffer | ||
;; but if there are 12 subtests, it is difficult to match the displayed | ||
;; should clause to the source line that ran it. | ||
;; | ||
;; The `ert-should' implicit button type defined herein solves this problem. | ||
;; Hyperbole loads this and then a press of the Action Key within an ert | ||
;; results buffer (or another buffer to which the results have been copied) | ||
;; produces the following: | ||
;; | ||
;; - If on the first line of the result with the test name, jump to the | ||
;; test definition. | ||
;; | ||
;; - If on a highlighted button, activate the button. | ||
;; | ||
;; - Otherwise if not at the end of a line and within a failed test result, | ||
;; find the `should' clause and go to the matching line within the test | ||
;; source code. An easy way to use it is to put point at the beginning | ||
;; of a line other than the first within an ert result and press the | ||
;; Action Key. | ||
|
||
;;; Code: | ||
|
||
;;; ************************************************************************ | ||
;;; Other required Elisp libraries | ||
;;; ************************************************************************ | ||
|
||
(require 'hbut) ;; For defib | ||
|
||
;;; ************************************************************************ | ||
;;; Implicit button types | ||
;;; ************************************************************************ | ||
|
||
(defib ert-should () | ||
"Jump to the source code definition of a should expr from an ert test failure. | ||
If on the first line of a failure, jump to the source definition of the | ||
associated test." | ||
(when (or (derived-mode-p 'ert-results-mode) | ||
(save-excursion | ||
(forward-line 0) | ||
(or (search-backward "(ert-test-failed\n" nil t) | ||
(search-forward "(ert-test-failed\n" nil t)))) | ||
(catch 'exit | ||
(save-excursion | ||
(save-restriction | ||
(forward-line 0) | ||
(cond ((looking-at "\\`\\|^[AFPS] ") | ||
;; On a result line with a test name, jump to the test | ||
(goto-char (match-end 0)) | ||
;; Use the test definition name as the ibut label | ||
(ibut:label-set (buffer-substring-no-properties | ||
(+ 2 (line-beginning-position)) | ||
(line-end-position)) | ||
(+ 2 (line-beginning-position)) | ||
(line-end-position)) | ||
(let ((major-mode 'emacs-lisp-mode)) | ||
(if (button-at (point)) | ||
;; jump to source buffer | ||
(push-button) | ||
(throw 'exit (hact 'smart-lisp))))) | ||
((looking-at "\\s-*(ert-test-failed\\s-") | ||
(when (re-search-forward "^\\s-+(\\((should\\)\\(-\\|\\s-\\)" nil t) | ||
(goto-char (match-beginning 1)))) | ||
((looking-at "\\s-*(\\((should\\)\\(-\\|\\s-\\)") | ||
(goto-char (match-beginning 1))) | ||
((re-search-backward "\\`\\|^[AFPS] " nil t) | ||
(let ((start (point))) | ||
(goto-char (1+ (point))) | ||
(when (re-search-forward "^[AFPS] \\|\\'" nil t) | ||
(goto-char (1- (match-beginning 0))) | ||
(narrow-to-region start (point)) | ||
(goto-char start) | ||
(when (re-search-forward "^\\s-+(\\((should\\)\\(-\\|\\s-\\)" nil t) | ||
(goto-char (match-beginning 1))))))) | ||
(when (looking-at "(should\\(-\\|\\s-\\)") | ||
(let ((should-regexp (regexp-quote (thing-at-point 'sexp)))) | ||
(setq should-regexp (replace-regexp-in-string | ||
"[ \t\n\r\f]+" "\\s-+" (string-trim should-regexp) | ||
t t)) | ||
;; follow the function link to the source file of the function | ||
(when (re-search-backward "^[AFPS] " nil t) | ||
(goto-char (match-end 0)) | ||
(let ((major-mode 'emacs-lisp-mode)) | ||
(if (button-at (point)) | ||
;; jump to source buffer | ||
(push-button) | ||
(smart-lisp)) | ||
;; re-search-forward for should-regexp | ||
(when (re-search-forward should-regexp nil t) | ||
(goto-char (match-beginning 0)) | ||
(ibut:label-set "(should" (point) (+ (point) 7)) | ||
(hact 'identity t))))))))))) | ||
|
||
(provide 'hsys-ert) | ||
|
||
;;; hsys-ert.el ends here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.