Skip to content

Commit 158a407

Browse files
authored
Merge pull request #407 from rswgnu/rsw
Improve tag/symbol finding, <> and {} handling
2 parents 3692855 + 7b1cd4a commit 158a407

18 files changed

+334
-169
lines changed

ChangeLog

+69-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,36 @@
1+
2023-12-01 Bob Weiner <[email protected]>
2+
3+
* hargs.el (hargs:delimited): Remove use of 'bounds-of-thing-at-point'
4+
and (require 'thingatpt) since it doesn't use the delimiters given
5+
and returns wrong results. This fixes defal tests that were failing.
6+
7+
* hyrolo.el (hyrolo-grep): Fix to ensure 'outline-regexp' setting for all
8+
matching file types is set locally in the match buffer only.
9+
(hyrolo-mode): Use 'setq-local' instead of 'make-local-variable'.
10+
(require 'outline): Add and remove its function declarations.
11+
12+
* hpath.el (hpath:expand): Fix to allow return of paths with file wildcards
13+
that are not yet expanded. Use 'hpath:expand-list' to expand them.
14+
(hpath:expand-list): Fix to call 'hpath:expand' before resolving
15+
wildcards, so that variables are resolved first. Also make 'match-regexp'
16+
argument optional, in which case all files are matched. Improve doc string.
17+
18+
2023-11-30 Bob Weiner <[email protected]>
19+
20+
* hyrolo.el (hyrolo-grep-file): Add 'backward-search-limit' to minimize
21+
backward searches to the end of the last match and to prevent
22+
forward search stalls in some contexts.
23+
24+
* hypb.el (hypb:insert-hyperbole-banner): Keep any initial line of
25+
variable settings (starts with -*-, e.g. for Org mode as the first
26+
line.
27+
128
2023-11-30 Mats Lidell <[email protected]>
229

330
* test/hui-tests.el (hui--ebut-link-directly-to-file)
431
(hui--ebut-link-directly-to-dired, hui--buf-writable-err)
532
(hui--gbut-link-directly-ibut, hui--gbut-link-directly-ebut): Add
6-
tests for ebut-link-directly.
33+
tests for ebut-link-directly.
734

835
2023-11-29 Mats Lidell <[email protected]>
936

@@ -26,11 +53,52 @@
2653

2754
* Remove warnings for unknown functions by using declare-function.
2855

56+
2023-11-23 Bob Weiner <[email protected]>
57+
58+
* hui-select.el (hui-select-syntax-table): Change to copy syntax
59+
table so changes do not affect the parent.
60+
61+
* hbut.el (hbut:modify-syntax): Add <> and {} pair support in text
62+
and fundamental modes.
63+
(require 'mode-local): Use in 'hbut:modify-syntax'.
64+
hib-kbd.el (defib kbd-key): Remove explicit syntax setting of braces
65+
and just temporarily use Hyperbole-modified text-mode syntax table.
66+
hyrolo.el (hyrolo-mode-syntax-table): Remove explicit syntax setting
67+
of < > delimiters; inherit from 'text-mode-syntax-table' instead.
68+
69+
* test/hui-select-tests.el (hui-select--thing): Fix to skip 'indent-def
70+
by removing final newline. Label each test section with the type
71+
of match expected.
72+
(hui-select--thing-interactive-prints-type-of-match): Make similar
73+
fixes as in above function.
74+
2975
2023-11-22 Mats Lidell <[email protected]>
3076

3177
* test/demo-tests.el (fast-demo-key-series-dired-other-window): Add test
3278
from demo key series.
3379

80+
2023-11-22 Bob Weiner <[email protected]>
81+
82+
* hui-mouse.el (hkey-alist): Add clause to handle Smart Key when in
83+
a vertico minibuffer window; make it behave like standard vertico
84+
which exits and selects the first minibuffer line, not the candidate
85+
presently selected.
86+
87+
* hargs.el (hargs:delimited):
88+
(require 'thingatpt): For 'bounds-of-thing-at-point'
89+
used in 'hargs:delimited' on single char matching delims.
90+
91+
* hui-select.el (hui-select-scan-sexps): Add to fix brace handling
92+
as a matching pair when selecting things by using previously
93+
unused 'hui-select-syntax-table'.
94+
95+
* hmouse-tag.el (smart-lisp-bound-symbol-def): Rewrite to support
96+
Hyperbole type defs like defib, etc. This improves finding
97+
the proper definition of a Hyperbole type.
98+
(find-defact-regexp, find-defal-regexp,
99+
find-defib-regexp, find-defil-regexp): Add these
100+
entries to 'find-function-regexp-alist'.
101+
34102
2023-11-21 Bob Weiner <[email protected]>
35103

36104
* hui-select.el (hui-select-initialize): Fix to set 'syntax-table-sym'

DEMO

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
-*- Mode: org; org-cycle-global-at-bob: t; hsys-org-enable-smart-keys: t -*-
2+
13
* GNU Hyperbole Full Demo/Tutorial by Bob Weiner
24

35
Send an email or a testimonial if you like Hyperbole to <[email protected]>.

FAST-DEMO

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
;;; -*- Mode: org; org-cycle-global-at-bob: t; hsys-org-enable-smart-keys: t -*-
1+
-*- Mode: org; org-cycle-global-at-bob: t; hsys-org-enable-smart-keys: t -*-
22

33
* GNU Hyperbole Fast Demo by Bob Weiner
44

@@ -191,11 +191,11 @@
191191
Press {C-h A} when over any Hyperbole button for an explanation of
192192
what it does.
193193

194-
{M-x dired-other-window RET ${hyperb:dir}/*.el RET}
194+
{M-x dired-other-window RET ${hyperb:dir}/*.el M-RET}
195195

196196
Hyperbole home directory Dired listing of Emacs Lisp files only
197197

198-
{C-c @ 22 RET}
198+
{C-22 C-c @}
199199

200200
Display a 2x2 windows grid in the current frame of the 4 most recently
201201
used buffers. Before you try this, remember the binding {C-h h h} for
@@ -207,15 +207,16 @@
207207
Find the Hyperbole Koutliner source files that begin with 'kotl' and
208208
display them in an auto-sized grid of windows.
209209

210-
{C-u 0 C-c @ emacs-lisp-mode RET 33 RET}
210+
{C-0 C-c @ emacs-lisp-mode RET 33 RET}
211211

212212
Display the 9 mostly recently used Emacs Lisp buffers in a 3x3 grid.
213213
A BLANK buffer fills in the grid if there are not enough Emacs Lisp
214214
ones.
215215

216216
{C-x 4 d ${hyperb:dir} RET}
217217

218-
Dired the Hyperbole home directory based on its variable.
218+
Dired the Hyperbole home directory based on its variable. {M-RET} on
219+
the directory itself will display the directory's value in the minibuffer.
219220

220221
Within this dired buffer, mark a few files with {m} and then press {@}
221222
to display a window grid of those files only. That works in Buffer

HY-NEWS

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
-*- Mode: org; org-cycle-global-at-bob: t; hsys-org-enable-smart-keys: t -*-
2+
13
* What's New in GNU Hyperbole
24
by Bob Weiner
35

README

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
# Author: Bob Weiner
44
#
55
# Orig-Date: 19-Oct-91 at 03:27:47
6-
# Last-Mod: 24-Jan-22 at 00:19:12 by Bob Weiner
6+
# Last-Mod: 24-Jan-23 at 00:19:12 by Bob Weiner
77
#
8-
# Copyright (C) 1989-2021 Free Software Foundation, Inc.
8+
# Copyright (C) 1989-2023 Free Software Foundation, Inc.
99
# See the "HY-COPY" file for license information.
1010
#
1111
# This file is part of GNU Hyperbole.

hargs.el

+16-11
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
;; Author: Bob Weiner
44
;;
55
;; Orig-Date: 31-Oct-91 at 23:17:35
6-
;; Last-Mod: 25-Nov-23 at 16:38:50 by Mats Lidell
6+
;; Last-Mod: 1-Dec-23 at 11:23:52 by Bob Weiner
77
;;
88
;; SPDX-License-Identifier: GPL-3.0-or-later
99
;;
@@ -128,7 +128,9 @@ START-DELIM is treated as a regular expression. END-REGEXP-FLAG
128128
is similar. With optional LIST-POSITIONS-FLAG, return list
129129
of (string-matched start-pos end-pos). Optional
130130
EXCLUDE-REGEXP is compared against the match string with its delimiters
131-
included; any string that matches this regexp is ignored."
131+
included; any string that matches this regexp is ignored. Optional
132+
AS-KEY non-nil means return the string normalized as a Hyperbole
133+
button key (no spaces)."
132134
(let* ((opoint (point))
133135
;; This initial limit is the forward search limit for start delimiters
134136
(limit (if start-regexp-flag
@@ -140,12 +142,13 @@ included; any string that matches this regexp is ignored."
140142
(end-search-func (if end-regexp-flag 're-search-forward 'search-forward))
141143
(count 0)
142144
first
143-
start
144-
end
145+
start ;; excludes delimiter
146+
end ;; excludes delimiter
145147
start-pos
146148
end-pos
147149
start-with-delim
148150
end-with-delim)
151+
149152
(if (string-equal start-delim end-delim)
150153
(save-excursion
151154
(beginning-of-line)
@@ -205,14 +208,16 @@ included; any string that matches this regexp is ignored."
205208
(goto-char opoint)
206209
(and (funcall end-search-func end-delim limit t)
207210
(setq end (match-beginning 0)
208-
end-with-delim (match-end 0))
211+
end-with-delim (match-end 0)))))
209212

210-
;; Ignore any preceding backslash, e.g. when a double-quoted
211-
;; string is embedded within a doc string, except when
212-
;; the string starts with 2 backslashes or an MSWindows
213-
;; disk drive prefix, in which case the backslash is
214-
;; considered part of a pathname.
215-
(if (and (> end (point-min))
213+
(when (and start end)
214+
(save-excursion
215+
;; Ignore any preceding backslash, e.g. when a double-quoted
216+
;; string is embedded within a doc string, except when
217+
;; the string starts with 2 backslashes or an MSWindows
218+
;; disk drive prefix, in which case the backslash is
219+
;; considered part of a pathname.
220+
(and (if (and (> end (point-min))
216221
(= (char-before end) ?\\)
217222
(not (string-match (concat "\\(\\`[\\][\\]\\)\\|"
218223
hpath:mswindows-mount-prefix)

hbut.el

+17-9
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
;; Author: Bob Weiner
44
;;
55
;; Orig-Date: 18-Sep-91 at 02:57:09
6-
;; Last-Mod: 25-Nov-23 at 17:10:28 by Mats Lidell
6+
;; Last-Mod: 30-Nov-23 at 23:23:53 by Bob Weiner
77
;;
88
;; SPDX-License-Identifier: GPL-3.0-or-later
99
;;
10-
;; Copyright (C) 1991-2022 Free Software Foundation, Inc.
10+
;; Copyright (C) 1991-2023 Free Software Foundation, Inc.
1111
;; See the "HY-COPY" file for license information.
1212
;;
1313
;; This file is part of GNU Hyperbole.
@@ -1503,24 +1503,32 @@ non-nil)."
15031503
(nreverse result)))
15041504

15051505
(defvar hbut:syntax-table (copy-syntax-table emacs-lisp-mode-syntax-table)
1506-
"Modified Elisp syntax table for use with Action and Key Series buttons.
1507-
Makes < > and { } into syntactically matching pairs after `hyperb:init'
1506+
"Syntax table copied from Elisp for use with Action and Key Series buttons.
1507+
Make < > and { } into syntactically matching pairs after `hyperb:init'
15081508
calls `hbut:modify-syntax'.")
15091509

15101510
;;;###autoload
15111511
(defun hbut:modify-syntax ()
1512-
"Modify syntactic character pairs in syntax tables.
1513-
Modify `hbut:syntax-table' and `help-mode-syntax-table'. For use
1514-
with implicit button activations."
1515-
;; Treat angle brackets as opening and closing delimiters for ease
1516-
;; of matching.
1512+
"Make <> and {} behave as syntactic character pairs in major syntax tables.
1513+
Modify `hbut:syntax-table' and `help-mode-syntax-table' to include <> and {}.
1514+
Modify `text-mode-syntax-table' and `fundamental-mode's syntax table
1515+
to include {} only. For use with implicit button activations."
1516+
;; Treat angle brackets and braces as opening and closing delimiters
1517+
;; for ease of matching.
15171518
(mapc (lambda (syntax-table)
15181519
(modify-syntax-entry ?\< "(>" syntax-table)
15191520
(modify-syntax-entry ?\> ")<" syntax-table)
15201521
;; Treat braces as opening and closing delimiters for ease of matching.
15211522
(modify-syntax-entry ?\{ "(}" syntax-table)
15221523
(modify-syntax-entry ?\} "){" syntax-table))
15231524
(list hbut:syntax-table help-mode-syntax-table))
1525+
(mapc (lambda (syntax-table)
1526+
;; Treat braces as opening and closing delimiters for ease of matching.
1527+
(modify-syntax-entry ?\{ "(}" syntax-table)
1528+
(modify-syntax-entry ?\} "){" syntax-table))
1529+
(list text-mode-syntax-table
1530+
;; fundamental-mode syntax table
1531+
(standard-syntax-table)))
15241532
nil)
15251533

15261534
(defun hbut:outside-comment-p ()

hib-kbd.el

+39-45
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
;; Author: Bob Weiner
44
;;
55
;; Orig-Date: 22-Nov-91 at 01:37:57
6-
;; Last-Mod: 19-Nov-23 at 17:55:29 by Bob Weiner
6+
;; Last-Mod: 23-Nov-23 at 01:51:41 by Bob Weiner
77
;;
88
;; SPDX-License-Identifier: GPL-3.0-or-later
99
;;
@@ -117,50 +117,44 @@ Any key sequence within the series must be a string of one of the following:
117117
(and (looking-at "[{}]") (/= ?\\ (preceding-char))))
118118
;; Temporarily make open and close braces have list syntax for
119119
;; matching purposes.
120-
(let ((open-brace-syntax (hypb:get-raw-syntax-descriptor ?\{))
121-
(close-brace-syntax (hypb:get-raw-syntax-descriptor ?\})))
122-
(unwind-protect
123-
(progn (modify-syntax-entry ?\{ "(}" (syntax-table))
124-
(modify-syntax-entry ?\} "){" (syntax-table))
125-
;; Handle long series, e.g. eval-elisp actions
126-
(let* ((hbut:max-len (max 3000 (hbut:max-len)))
127-
(seq-and-pos (or
128-
;; (kbd) calls but only if point is between double quotes
129-
(and (hbut:label-p t "(kbd \"" "\"\)" t)
130-
(hbut:label-p t "\"" "\"\)" t))
131-
;; braces delimiters
132-
(hbut:label-p t "{`" "'}" t)
133-
(hbut:label-p t "{" "}" t)
134-
;; Regular dual single quotes (Texinfo smart quotes)
135-
(hbut:label-p t "``" "''" t)
136-
;; Typical GNU manual key sequences; note
137-
;; these are special quote marks, not the
138-
;; standard ASCII characters.
139-
(hbut:label-p t "" "" t)))
140-
;; This excludes delimiters
141-
(key-series (car seq-and-pos))
142-
(start (cadr seq-and-pos))
143-
binding)
144-
;; Match only when start delimiter is preceded by whitespace,
145-
;; double quotes or is the 1st buffer character, so do not
146-
;; match to things like ${variable}.
147-
(when (memq (char-before start) '(nil ?\ ?\t ?\n ?\r ?\f ?\"))
148-
(when (and (stringp key-series)
149-
(not (string-equal key-series "")))
150-
;; Replace any ${} internal or env vars; leave
151-
;; $VAR untouched for the shell to evaluate.
152-
(let ((hpath:variable-regexp "\\${\\([^}]+\\)}"))
153-
(setq key-series (hpath:substitute-value key-series)))
154-
155-
(setq key-series (kbd-key:normalize key-series)
156-
binding (kbd-key:binding key-series)))
157-
(and (stringp key-series)
158-
(or (and binding (not (integerp binding)))
159-
(kbd-key:special-sequence-p key-series))
160-
(ibut:label-set seq-and-pos)
161-
(hact 'kbd-key key-series)))))
162-
(hypb:set-raw-syntax-descriptor ?\{ open-brace-syntax)
163-
(hypb:set-raw-syntax-descriptor ?\} close-brace-syntax)))))
120+
(with-syntax-table text-mode-syntax-table
121+
;; Handle long series, e.g. eval-elisp actions
122+
(let* ((hbut:max-len (max 3000 (hbut:max-len)))
123+
(seq-and-pos (or
124+
;; (kbd) calls but only if point is between double quotes
125+
(and (hbut:label-p t "(kbd \"" "\"\)" t)
126+
(hbut:label-p t "\"" "\"\)" t))
127+
;; braces delimiters
128+
(hbut:label-p t "{`" "'}" t)
129+
(hbut:label-p t "{" "}" t)
130+
;; Regular dual single quotes (Texinfo smart quotes)
131+
(hbut:label-p t "``" "''" t)
132+
;; Typical GNU manual key sequences; note
133+
;; these are special quote marks, not the
134+
;; standard ASCII characters.
135+
(hbut:label-p t "" "" t)))
136+
;; This excludes delimiters
137+
(key-series (car seq-and-pos))
138+
(start (cadr seq-and-pos))
139+
binding)
140+
;; Match only when start delimiter is preceded by whitespace,
141+
;; double quotes or is the 1st buffer character, so do not
142+
;; match to things like ${variable}.
143+
(when (memq (char-before start) '(nil ?\ ?\t ?\n ?\r ?\f ?\"))
144+
(when (and (stringp key-series)
145+
(not (string-equal key-series "")))
146+
;; Replace any ${} internal or env vars; leave
147+
;; $VAR untouched for the shell to evaluate.
148+
(let ((hpath:variable-regexp "\\${\\([^}]+\\)}"))
149+
(setq key-series (hpath:substitute-value key-series)))
150+
151+
(setq key-series (kbd-key:normalize key-series)
152+
binding (kbd-key:binding key-series)))
153+
(and (stringp key-series)
154+
(or (and binding (not (integerp binding)))
155+
(kbd-key:special-sequence-p key-series))
156+
(ibut:label-set seq-and-pos)
157+
(hact 'kbd-key key-series)))))))
164158

165159
;;; ************************************************************************
166160
;;; Public functions

0 commit comments

Comments
 (0)