Skip to content

Commit 64d7daf

Browse files
authored
Merge pull request #982 from rswgnu/rsw
hui-select-get-syntax-table - Add and use default prog syntax tables
2 parents d7354c0 + 2d05810 commit 64d7daf

2 files changed

Lines changed: 16 additions & 13 deletions

File tree

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
2026-06-18 Bob Weiner <rsw@gnu.org>
22

3+
* hui-select.el (hui-select-get-syntax-table): Add and leave syntax-table
4+
unchanged when in a programming mode so that <> pair syntax does not
5+
interfere with {} region/sexp selection.
6+
37
* test/hibtypes-tests.el (ibtypes::ilink-test): Add and ensure only one
48
instance of this test.
59

hui-select.el

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
;; Author: Bob Weiner
44
;;
55
;; Orig-Date: 19-Oct-96 at 02:25:27
6-
;; Last-Mod: 7-Mar-26 at 18:39:40 by Bob Weiner
6+
;; Last-Mod: 18-Jun-26 at 13:05:12 by Bob Weiner
77
;;
88
;; SPDX-License-Identifier: GPL-3.0-or-later
99
;;
@@ -604,10 +604,7 @@ Also, add language-specific syntax setups to aid in thing selection."
604604

605605
(defun hui-select-get-region-boundaries ()
606606
"Return the (START . END) boundaries of region for `hui-select-thing'."
607-
(with-syntax-table
608-
(if (memq major-mode hui-select-ignore-quoted-sexp-modes)
609-
(syntax-table)
610-
hui-select-syntax-table)
607+
(with-syntax-table (hui-select-get-syntax-table)
611608
(or (hui-select-boundaries (point))
612609
(when (eq hui-select-previous 'punctuation)
613610
(hui-select-word (point))))))
@@ -633,10 +630,8 @@ Also, add language-specific syntax setups to aid in thing selection."
633630

634631
(defun hui-select-scan-sexps (from count)
635632
"Scan FROM point across COUNT sexpressions."
636-
(if (memq major-mode hui-select-ignore-quoted-sexp-modes)
637-
(scan-sexps from count)
638-
(with-syntax-table hui-select-syntax-table
639-
(scan-sexps from count))))
633+
(with-syntax-table (hui-select-get-syntax-table)
634+
(scan-sexps from count)))
640635

641636
;;;###autoload
642637
(defun hui-select-thing (&optional interactive-flag)
@@ -1060,10 +1055,7 @@ call to select that syntactic unit."
10601055
(unless (and (memq major-mode hui-select-ignore-quoted-sexp-modes)
10611056
;; Ignore quoted identifier sexpressions, like #'function
10621057
(char-after) (memq (char-after) '(?# ?\')))
1063-
(with-syntax-table
1064-
(if (memq major-mode hui-select-ignore-quoted-sexp-modes)
1065-
(syntax-table)
1066-
hui-select-syntax-table)
1058+
(with-syntax-table (hui-select-get-syntax-table)
10671059
(let ((hui-select-char-p)
10681060
(hui-select-whitespace)
10691061
(hui-select-syntax-alist '((?\" . hui-select-string)
@@ -1078,6 +1070,13 @@ call to select that syntactic unit."
10781070
(hui-select-reset)
10791071
(funcall func)))))
10801072

1073+
(defun hui-select-get-syntax-table ()
1074+
"Return syntax table to use for syntactic selection based on `major-mode'."
1075+
(if (or (derived-mode-p 'prog-mode)
1076+
(memq major-mode hui-select-ignore-quoted-sexp-modes))
1077+
(syntax-table)
1078+
hui-select-syntax-table))
1079+
10811080
(defun hui-select-region-bigger-p (old-region new-region)
10821081
"Non-nil means the new region is bigger than the old region.
10831082
Return t if OLD-REGION is smaller than NEW-REGION and NEW-REGION

0 commit comments

Comments
 (0)