Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
2026-07-27 Bob Weiner <rsw@gnu.org>

* test/hywiki-tests.el (hywiki-tests--potential-buffer-p): Fix test to
exclude python-mode requires it not be in the include list.

* hypb.el (hypb:in-string-check): Rename to 'hypb:in-string-no-cache-p'.

2026-07-26 Bob Weiner <rsw@gnu.org>

* hywiki.el (hywiki-exclude-major-modes): Rename to 'hypb:exclude-major-modes'.
(hywiki-include-special-modes): Rename to 'hypb:include-major-modes'
Because now these are used for both HyWiki and compose mail button mode checks.
(hywiki-potential-buffer-p): If 'hypb:include-major-modes' is nil, then
HyWikiWords are allowed in all major-modes.
test/hywiki-tests.el (hywiki-tests--potential-buffer-p): Rename above.
hibtypes.el (mail-address): Replace 'hypb:mail-address-mode-list' with
'hypb:include-major-modes'.

2026-07-27 Mats Lidell <matsl@gnu.org>

* test/hypb-tests.el (hypb--string-count-matches):
(hypb--package-el-install): Removed. Moved to hy-string-tests.el.

* test/hy-string-tests.el (hy-string-tests--strings-with-quotes):
(hy-string-tests--strings-with-quotes-extended):
(hy-string-tests--max-lines): Add tests.
(hy-string-tests--gen-response-list): Helper for creating a response
list.

2026-07-25 Mats Lidell <matsl@gnu.org>

* hibtypes.el (hywiki-non-hook-context-p):
Expand Down
2 changes: 1 addition & 1 deletion DEMO
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ or without quotes.

An Action Key press on an email address of any common domain name will
start composing an email message to that name within Emacs. This is
limited to major modes listed in the variable, hypb:mail-address-mode-list.
limited to major modes listed in the variable, hypb:include-major-modes.
If that variable is nil, then email addresses are active in every
buffer.

Expand Down
11 changes: 6 additions & 5 deletions HY-NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
* **Section Linking**: HyWikiWord links now support internal section jumps using the **`#` character** (e.g., `WikiWord#Section-Name`), allowing direct navigation to specific Org headlines within a wiki page.
* **Web Publishing**: Added the `hywiki-publish-to-html` command (bound to `{C-h h h p}`) which utilizes Org mode’s publishing framework to export an entire HyWiki directory to HTML for web use.
* **Interactive Search**: Added `hywiki-consult-grep` (bound to `{C-h h h g}`) for interactive, live-narrowing searches across all HyWiki pages using the Consult package.
* **Customizable Highlighting**: Added `hywiki-word-highlight-flag` to toggle auto-highlighting and `hywiki-exclude-major-modes` to define a list of modes where HyWikiWord recognition should be disabled.
* **Customizable Highlighting**: Added `hywiki-word-highlight-flag` and
`hypb:include-major-modes' to toggle auto-highlighting and `hypb:exclude-major-modes` to define a list of modes where HyWikiWord recognition should be disabled.
* **Link Requirements**: New variable `hywiki-org-link-type-required` allows users to control whether the `hy:` prefix is required for HyWikiWords when used inside Org-style double square brackets outside of the wiki directory.

* **Smart Keys**
Expand Down Expand Up @@ -652,7 +653,7 @@

*** hypb:mail-address-tld-regexp: Renamed from 'hypb-mail-address-tld-regexp'.
hypb:mail-address-regexp: Renamed from 'hypb-mail-address-regexp'.
hypb:mail-address-mode-list: Renamed from 'mail-address-mode-list'.
hypb:include-major-modes: Renamed from 'mail-address-mode-list'.
Make all of these variables have a common prefix.

*** (hypb:devdocs-lookup): Install and load devdocs package and then call its
Expand Down Expand Up @@ -1396,7 +1397,7 @@
pressed individually, i.e. the same as the key series, {string}.

*** Mail Address Activation Everywhere: Email addresses act as implicit
buttons in major modes derived from `hypb:mail-address-mode-list'. If
buttons in major modes derived from `hypb:include-major-modes'. If
you set that to nil, however, they will be recognized in all major
modes.

Expand Down Expand Up @@ -2661,7 +2662,7 @@ are new in 2016 and you should look through them all.
MAIL

- Implicit mail address buttons are recognized in many more programming
modes. See the value of `hypb:mail-address-mode-list'.
modes. See the value of `hypb:include-major-modes'.

VARIABLES

Expand Down Expand Up @@ -3650,7 +3651,7 @@ are new in 2016 and you should look through them all.
- Image files may be displayed within the editor if the editor supports
this and image-mode is available.

- The new variable, hypb:mail-address-mode-list, determines the major modes
- The new variable, hypb:include-major-modes, determines the major modes
in which Action Key presses on <delimited> mail addresses start
composing mail to that address.

Expand Down
10 changes: 5 additions & 5 deletions hibtypes.el
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 19-Sep-91 at 20:45:31
;; Last-Mod: 25-Jul-26 at 22:57:10 by Mats Lidell
;; Last-Mod: 26-Jul-26 at 21:44:19 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
Expand Down Expand Up @@ -292,16 +292,16 @@ To restore to using Emacs to compose mail:
(setq mail-user-agent \\='message-user-agent)

This implicit button type applies in any major mode listed in
`hypb:mail-address-mode-list', the HyRolo match buffer, any buffer
`hypb:include-major-modes', the HyRolo match buffer, any buffer
attached to a file in `hyrolo-file-list', or any buffer with \"mail\" or
\"rolo\" (case-insensitive) within its name.

If `hypb:mail-address-mode-list' is set to nil, this button type is active
If `hypb:include-major-modes' is set to nil, this button type is active
in all buffers."
(when (let ((case-fold-search t))
(or
(and (or (null hypb:mail-address-mode-list)
(apply #'derived-mode-p hypb:mail-address-mode-list))
(and (or (null hypb:include-major-modes)
(apply #'derived-mode-p hypb:include-major-modes))
(not (string-match "-Elements\\'" (buffer-name)))
;; Don't want this to trigger within an OOBR-FTR buffer.
(not (string-match "\\`\\(OOBR.*-FTR\\|oobr.*-ftr\\)"
Expand Down
70 changes: 49 additions & 21 deletions hypb.el
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 6-Oct-91 at 03:42:38
;; Last-Mod: 20-Jul-26 at 01:52:50 by Bob Weiner
;; Last-Mod: 27-Jul-26 at 10:18:42 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
Expand Down Expand Up @@ -69,6 +69,33 @@
;;; Public variables
;;; ************************************************************************

(defcustom hypb:exclude-major-modes nil
"List of major modes to exclude from HyWikiWord and mail address recognition.
Any `special' major mode, like Dired, is automatically excluded unless
included in the list, `hypb:include-major-modes'."
:type '(list symbol)
:group 'hyperbole-commands)

(defcustom hypb:include-major-modes
'(csv-mode
elfeed-search-mode elfeed-show-mode
eww-mode
fundamental-mode
gnus-article-edit-mode gnus-article-mode
kotl-mode
mh-letter-mode mh-show-mode
mu4e-headers-mode mu4e-main-mode
prog-mode
rmail-edit-mode rmail-mode
text-mode)
"List of major modes with HyWikiWord and mail address recognition.
If the value is nil, then include all major modes.

By default, all special modes, like Dired, are excluded. A major mode
included here will override its inclusion in `hypb:exclude-major-modes'."
:type '(list symbol)
:group 'hyperbole-commands)

(defconst hypb:help-buf-prefix "*Help: Hyperbole "
"Prefix attached to all native Hyperbole help buffer names.
This should end with a space.")
Expand Down Expand Up @@ -98,11 +125,6 @@ delimiter."
:type 'boolean
:group 'hyperbole-commands)

(defvar hypb:mail-address-mode-list
'(fundamental-mode prog-mode text-mode)
"List of major modes in which mail address implicit buttons are active.
Also active in any Decendent modes of those listed.")

(defconst hypb:mail-address-tld-regexp
(format "\\.%s\\'"
(regexp-opt
Expand Down Expand Up @@ -750,19 +772,24 @@ This will this install the Emacs helm package when needed."
help-file))))

(defun hypb:in-string-p (&optional max-lines range-flag)
"Return non-nil iff point is within a string and not on the closing quote.
This is cached by buffer & modified time for speed.
"Return non-nil iff point is within a string.
Point is within the string if it is after the end of the opening
quote and before the start of the closing quote, not on it. This
is cached by buffer & modified time for speed.

With optional MAX-LINES, an integer, match only within that many
lines from point. With optional RANGE-FLAG when there is a
match, return list of (in-string-flag start-pos end-pos), where
in-string-flag is t or nil and the positions exclude the delimiters.
in-string-flag is t or nil and the positions exclude the delimiters;
the difference between end and start is the length of the string.

To prevent searching back to the buffer start and producing slow
performance, this limits its count of quotes found prior to point
to the beginning of the first line prior to point that contains a
non-backslashed quote mark and limits string length to a maximum
of 9000 characters.
When no buffer edits have occurred, this uses cached results to
determine whether in or outside of a string. When no cache hit is
found, to prevent searching back to the buffer start and producing
slow performance, this limits its count of quotes found prior to
point to the beginning of the first line prior to point that
contains a non-backslashed quote mark and limits string length to a
maximum of 9000 characters.

Quoting conventions recognized are:
double-quotes: \"str\";
Expand Down Expand Up @@ -807,8 +834,8 @@ Quoting conventions recognized are:
;; to be used in the cache.
;; To call it with the buffer narrowed to
;; according to `max-lines', use:
;; (hypb:narrow-to-max-lines max-lines #'hypb:in-string-check t)
(hypb:in-string-check t)))
;; (hypb:narrow-to-max-lines max-lines #'hypb:in-string-no-cache-p t)
(hypb:in-string-no-cache-p t)))
(in-str (nth 0 entry))
(str-start (max (point-min) (or (nth 1 entry) 0)))
(str-end (min (point-max) (or (nth 2 entry) 0))))
Expand Down Expand Up @@ -867,17 +894,18 @@ prior point."
(line-end-position (1+ max-lines)))))
(apply func args))))

(defun hypb:in-string-check (&optional range-flag)
(defun hypb:in-string-no-cache-p (&optional range-flag)
"Return non-nil iff point is within a string and not on the closing quote.

With optional RANGE-FLAG when there is a match, return list of (in-string-flag
start-pos end-pos), where in-string-flag is t or nil and the positions exclude
the delimiters.

To prevent searching back to the buffer start and producing slow
performance, this limits its count of quotes found prior to point to the
beginning of the first line prior to point that contains a non-backslashed
quote mark and limits string length to a maximum of 9000 characters.
This does not use caching. To prevent searching back to the buffer start
and producing slow performance, this limits its count of quotes found prior
to point to the beginning of the first line prior to point that contains a
non-backslashed quote mark and limits string length to a maximum of 9000
characters.

Quoting conventions recognized are:
double-quotes: \"str\";
Expand Down
2 changes: 1 addition & 1 deletion hyperbole.el
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
;; Maintainer: Robert Weiner <rsw@gnu.org>
;; Mats Lidell <matsl@gnu.org>
;; Created: 06-Oct-92 at 11:52:51
;; Last-Mod: 25-Jul-26 at 22:44:16 by Mats Lidell
;; Last-Mod: 26-Jul-26 at 21:46:00 by Bob Weiner
;; Released: 10-Mar-24
;; Version: 9.0.2pre
;; Keywords: comm, convenience, files, frames, hypermedia, languages, mail, matching, mouse, multimedia, outlines, tools, wp
Expand Down
42 changes: 11 additions & 31 deletions hywiki.el
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 21-Apr-24 at 22:41:13
;; Last-Mod: 23-Jul-26 at 11:38:51 by Bob Weiner
;; Last-Mod: 27-Jul-26 at 10:43:32 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
Expand Down Expand Up @@ -77,7 +77,7 @@
;; auto-highlight hooks use {C-u C-h h h m} to toggle `hywiki-mode';
;; this also enables auto-highlighting when `hywiki-mode' is non-nil.

;; The custom setting, `hywiki-exclude-major-modes' (default = nil), is
;; The custom setting, `hypb:exclude-major-modes' (default = nil), is
;; a list of major modes to exclude from HyWikiWord auto-highlighting
;; and recognition.
;;
Expand Down Expand Up @@ -147,7 +147,8 @@
(eval-when-compile (require 'consult nil t))
(require 'hui) ;; For `hui:actype'
(require 'hui-mini) ;; For `hui:menu-act'
(require 'hypb) ;; Requires `seq'
(require 'hypb) ;; Requires `seq', hypb:exclude-major-modes,
;; hypb:include-major-modes
(require 'hyrolo)
(require 'outline) ;; For `outline-mode-syntax-table'
(require 'seq) ;; For `seq-contains-p', `seq-difference' and `seq-intersection'
Expand Down Expand Up @@ -318,13 +319,6 @@ Group 1 is the entire HyWikiWord#section:Lnum:Cnum expression.")
(add-variable-watcher 'global-map
#'hywiki--clear-buttonize-characters-cache)

(defcustom hywiki-exclude-major-modes nil
"List of major modes to exclude from HyWikiWord highlighting and recognition.
Any `special' major mode, like Dired, is automatically excluded unless
included in the list, `hywiki-include-special-modes'."
:type '(list symbol)
:group 'hyperbole-hywiki)

(defvar hywiki-glossary-display-buffer "*HyWiki Glossary*"
"Buffer used to display the last match to a HyWiki glossary definition.")

Expand All @@ -333,21 +327,6 @@ included in the list, `hywiki-include-special-modes'."
:type '(list symbol)
:group 'hyperbole-hywiki)

(defcustom hywiki-include-special-modes
'(csv-mode
elfeed-search-mode elfeed-show-mode
eww-mode
gnus-article-edit-mode gnus-article-mode
kotl-mode
mh-letter-mode mh-show-mode
mu4e-headers-mode mu4e-main-mode
rmail-edit-mode rmail-mode)
"List of `special' major modes with HyWikiWord highlighting and recognition.
By default, all special modes, like Dired, are excluded. A major mode
included here will override its inclusion in `hywiki-exclude-major-modes'."
:type '(list symbol)
:group 'hyperbole-hywiki)

(defcustom hywiki-mode-lighter " HyWiki"
"String to display in mode line when the HyWiki global minor mode is enabled.
Use nil for no HyWiki mode indicator."
Expand Down Expand Up @@ -974,7 +953,7 @@ with the default state when interactively enabled set by the value of
if off.

- :all - highlight HyWikiWords in all editable buffers except those
with a major mode in `hywiki-exclude-major-modes'; also
with a major mode in `hypb:exclude-major-modes'; also
enable `hyperbole-mode' minor mode if off.

- nil - no highlighting, the `hywiki-mode' is disabled.
Expand Down Expand Up @@ -1234,9 +1213,10 @@ This does not mean `hywiki-mode' is presently active in that buffer;
use `hywiki-active-in-current-buffer-p' for that."
(and (not (minibufferp))
;; (not (and (boundp 'edebug-active) edebug-active))
(or (apply #'derived-mode-p hywiki-include-special-modes)
(or (null hypb:include-major-modes) ;; means all modes allowed
(apply #'derived-mode-p hypb:include-major-modes)
(and (not (eq (get major-mode 'mode-class) 'special))
(not (apply #'derived-mode-p hywiki-exclude-major-modes))))))
(not (apply #'derived-mode-p hypb:exclude-major-modes))))))

(defun hywiki-add-activity (wikiword)
"Make WIKIWORD resume a prompted for, existing activity.
Expand Down Expand Up @@ -4690,14 +4670,14 @@ a HyWikiWord at point."
(let* ((range
(save-restriction
;; Limit balanced pair checks to current through next lines for speed.
;; Point must be either on the opening line.
;; Point must be on the opening line.
(narrow-to-region (line-beginning-position) (line-end-position 2))
(or (hypb:in-string-p nil t)
(hargs:delimited "[\[<\(\{]" "[\]\}\)\>]" t t t))))
(str-start (nth 1 range))
(str-end (nth 2 range))
;; Call to 'hypb:in-string-p' may have returned t
;; as its first element
;; Call to 'hypb:in-string-p' may have returned t as its first
;; element
(wikiword (when str-start
(if (stringp (car range))
(car range)
Expand Down
2 changes: 1 addition & 1 deletion hywiki/HyWiki.org
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Hyperbole's Action Key does the right thing in this context.
By default, HyWikiWords are auto-highlighted within HyWiki pages.
Outside of such pages, 'hywiki-mode' must be set to `:all' to enable
auto-highlighting in programming and text buffers. The custom
setting, 'hywiki-exclude-major-modes' (default = 'nil'), is a list of
setting, 'hypb:exclude-major-modes' (default = 'nil'), is a list of
major modes to exclude from HyWikiWord auto-highlighting and
recognition.

Expand Down
Loading