[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/hyperbole 871391f368 103/143: Add test for hargs:sexpre
From: |
ELPA Syncer |
Subject: |
[elpa] externals/hyperbole 871391f368 103/143: Add test for hargs:sexpression-p (#451) |
Date: |
Mon, 19 Feb 2024 15:59:18 -0500 (EST) |
branch: externals/hyperbole
commit 871391f36840ba144407bbfd0d1f00361593c426
Author: Mats Lidell <mats.lidell@lidells.se>
Commit: GitHub <noreply@github.com>
Add test for hargs:sexpression-p (#451)
* Add test for hargs:sexpression-p
* Fix hargs:sexpression-p when eval triggers an error
Add test hargs-tests--sexpression-p
---
hargs.el | 38 ++++++++++++++++++++------------------
test/hargs-tests.el | 22 +++++++++++++++++++++-
2 files changed, 41 insertions(+), 19 deletions(-)
diff --git a/hargs.el b/hargs.el
index f5ec41e0b3..e5367f00b8 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: 20-Jan-24 at 15:37:06 by Mats Lidell
+;; Last-Mod: 20-Jan-24 at 19:43:53 by Mats Lidell
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -508,23 +508,25 @@ If point follows an sexpression end character, the
preceding sexpression
is returned. If point precedes an sexpression start character, the
following sexpression is returned. Otherwise, the innermost sexpression
that point is within is returned or nil if none."
- (save-excursion
- (ignore-errors
- (let ((not-quoted
- '(not (and (eq (char-syntax (char-after (- (point) 2))) ?\\)
- (not (eq (char-syntax (char-after (- (point) 3)))
?\\))))))
- (cond ((and (eq (char-syntax (preceding-char)) ?\))
- ;; Ignore quoted end chars.
- (eval not-quoted))
- (buffer-substring (point)
- (progn (forward-sexp -1) (point))))
- ((and (eq (char-syntax (following-char)) ?\()
- ;; Ignore quoted begin chars.
- (eval not-quoted))
- (buffer-substring (point)
- (progn (forward-sexp) (point))))
- (no-recurse nil)
- (t (save-excursion (up-list 1) (hargs:sexpression-p t))))))))
+ (let ((not-quoted
+ '(condition-case ()
+ (not (and (eq (char-syntax (char-after (- (point) 2))) ?\\)
+ (not (eq (char-syntax (char-after (- (point) 3)))
?\\))))
+ (error t))))
+ (save-excursion
+ (ignore-errors
+ (cond ((and (eq (char-syntax (preceding-char)) ?\))
+ ;; Ignore quoted end chars.
+ (eval not-quoted))
+ (buffer-substring (point)
+ (progn (forward-sexp -1) (point))))
+ ((and (eq (char-syntax (following-char)) ?\()
+ ;; Ignore quoted begin chars.
+ (eval not-quoted))
+ (buffer-substring (point)
+ (progn (forward-sexp) (point))))
+ (no-recurse nil)
+ (t (save-excursion (up-list 1) (hargs:sexpression-p t))))))))
;;; ************************************************************************
;;; Public functions
diff --git a/test/hargs-tests.el b/test/hargs-tests.el
index 8f74d689cb..7fe53d852d 100644
--- a/test/hargs-tests.el
+++ b/test/hargs-tests.el
@@ -3,7 +3,7 @@
;; Author: Mats Lidell <matsl@gnu.org>
;;
;; Orig-Date: 04-Feb-22 at 23:00:00
-;; Last-Mod: 28-May-23 at 23:14:18 by Mats Lidell
+;; Last-Mod: 20-Jan-24 at 19:38:11 by Mats Lidell
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -47,6 +47,26 @@
(cl-letf (((symbol-function 'hargs:read) (lambda (prompt &optional a b c d)
"xyz")))
(should (string= (hargs:get "+K: ") "xyz"))))
+(ert-deftest hargs-tests--sexpression-p ()
+ "Verify behavior of `hargs:sexpression-p'."
+ (with-temp-buffer
+ (insert " (setq var (+ 1 2)) ")
+ ;; pos ->123456789012345678901
+ (dolist (v '((1 nil nil)
+ (2 "(setq var (+ 1 2))" "(setq var (+ 1 2))")
+ (3 "(setq var (+ 1 2))" nil)
+ (4 "(setq var (+ 1 2))" nil)
+ (11 "(setq var (+ 1 2))" nil)
+ (12 "(+ 1 2)" "(+ 1 2)")
+ (13 "(+ 1 2)" nil)
+ (18 "(+ 1 2)" nil)
+ (19 "(+ 1 2)" "(+ 1 2)")
+ (20 "(setq var (+ 1 2))" "(setq var (+ 1 2))")
+ (21 nil nil)))
+ (goto-char (car v))
+ (should (string= (cadr v) (hargs:sexpression-p)))
+ (should (string= (caddr v) (hargs:sexpression-p t))))))
+
;; This file can't be byte-compiled without `with-simulated-input' which
;; is not part of the actual dependencies, so:
;; Local Variables:
- [elpa] externals/hyperbole 6009912456 128/143: Add type of but in error message, renamed but parameter, (continued)
- [elpa] externals/hyperbole 6009912456 128/143: Add type of but in error message, renamed but parameter, ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole 7d485ab5ff 136/143: hbut:act-label: Add to match same func for ebuts and ibuts, ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole 9a39300fcb 135/143: Merge branch 'rsw' of hyperbole into rsw, ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole d55d57664c 139/143: Remove ad hoc flycheck warnings (#468), ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole ce463d27c9 143/143: Merge to rsw branch in prep for V8.0.2pre release, ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole 21c93a0c70 137/143: Reorder load of `org-macs', ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole da8fd61747 099/143: Remove package-lint dependency and string-replace compatibility code, ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole 74ba1fd580 104/143: Cleanup of flycheck/flymake info and warning messages (#449), ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole 9e77bdf62e 108/143: Fix cyclic call bug that made Elisp lookups slow in ChangeLog mode, ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole dd2e0884ee 100/143: Merge pull request #450 from rswgnu/matsl-rsw-cleanup-package-lint-dependencies, ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole 871391f368 103/143: Add test for hargs:sexpression-p (#451),
ELPA Syncer <=
- [elpa] externals/hyperbole 4291c14138 115/143: Add hyrolo reveal mode test (#459), ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole f4e323542d 116/143: Disable three failing tests for Emacs older than 29 (#461), ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole a7a7f74859 125/143: Add i- and ebut:act functions and tests, ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole f1fa9363e8 119/143: Matsl rsw silence warnings again (#463), ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole 4bf1bc3ca2 126/143: Check ebut:act and ibut:act is called with the right but category, ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole 18ae76fa49 132/143: Merge pull request #462 from rswgnu/matsl-rsw-fix-ebut-act, ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole 85b31fed86 130/143: Remove inconsistent dash in test data, ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole a8cdad694b 141/143: Fix `hyrolo-min-matched-level' and hyrolo-top-level test, ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole 0e242bc1ae 031/143: Merge remote branch 'rsw' of hyperbole into rsw, ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole a7efb9be79 042/143: FAST-DEMO include ert test in file to avoid loading all test files, ELPA Syncer, 2024/02/19