Function: hywiki-maybe-highlight-balanced-pairs
hywiki-maybe-highlight-balanced-pairs is an autoloaded and
byte-compiled function defined in hywiki.el.
Signature
(hywiki-maybe-highlight-balanced-pairs)
Documentation
Before or after a balanced delimiter, highlight HyWikiWords within.
Include: (), {}, <>, [] and "" (double quotes). Exclude Org links and radio targets.
Range is limited to the previous, current and next lines, as HyWikiWord references are limited to two lines maximum.
Return t if no errors and a pair was found, else nil.
Source Code
;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hywiki.el
;;;###autoload
(defun hywiki-maybe-highlight-balanced-pairs ()
"Before or after a balanced delimiter, highlight HyWikiWords within.
Include: (), {}, <>, [] and \"\" (double quotes). Exclude Org links
and radio targets.
Range is limited to the previous, current and next lines, as HyWikiWord
references are limited to two lines maximum.
Return t if no errors and a pair was found, else nil."
(save-excursion
(save-restriction
(if (hywiki--buttonized-region-p)
(narrow-to-region hywiki--buttonize-start hywiki--buttonize-end)
;; Limit balanced pair checks to two lines around point for speed
(narrow-to-region (line-beginning-position 0) (line-end-position 2)))
(let ((result t))
(condition-case nil
;; char-before
(cond ((memq (char-before) '(?\[ ?\<))
(goto-char (1- (point)))
;; Highlight any HyWikiWords within single opening
;; square or angle brackets
;; Dehighlight HyWikiWords within double opening square
;; or angle brackets, as these are Org links and targets
(hywiki-maybe-highlight-org-element-forward))
((memq (char-before) '(?\( ?\{))
;; Highlight any HyWikiWords within opening parens or braces
(goto-char (1- (point)))
(hywiki-maybe-highlight-sexp 1))
((and (eq (char-before) ?\")
(hypb:in-string-p))
(goto-char (1- (point)))
(hywiki-maybe-highlight-sexp 1))
((memq (char-before) '(?\] ?\>))
;; Dehighlight HyWikiWords within double closing square
;; or angle brackets, as these are Org links and targets
(hywiki-maybe-highlight-org-element-backward))
((memq (char-before) '(?\) ?\}))
;; Highlight any HyWikiWords within closing parens or braces
(hywiki-maybe-highlight-sexp -1))
((and (eq (char-before) ?\")
(not (hypb:in-string-p)))
;; Highlight HyWikiWords in any string preceding point
(hywiki-maybe-highlight-sexp -1))
(t (setq result nil)))
(error (setq result nil)))
(when result
(condition-case nil
;; char-after
(cond ((memq (char-after) '(?\[ ?\<))
;; Highlight any HyWikiWords within single opening
;; square or angle brackets
;; Dehighlight HyWikiWords within double opening square
;; or angle brackets, as these are Org links and targets
(hywiki-maybe-highlight-org-element-forward))
((memq (char-after) '(?\( ?\{))
;; Highlight any HyWikiWords within opening parens or braces
(hywiki-maybe-highlight-sexp 1))
((and (eq (char-after) ?\")
(hypb:in-string-p))
(goto-char (1+ (point)))
(hywiki-maybe-highlight-sexp -1))
((memq (char-after) '(?\] ?\>))
(goto-char (1+ (point)))
;; Highlight any HyWikiWords within single closing
;; square or angle brackets
;; Dehighlight HyWikiWords within double closing square
;; or angle brackets, as these are Org links and targets
(hywiki-maybe-highlight-org-element-backward))
((memq (char-after) '(?\) ?\}))
;; Highlight any HyWikiWords within closing parens or braces
(goto-char (1+ (point)))
(hywiki-maybe-highlight-sexp -1))
((and (eq (char-after) ?\")
(not (hypb:in-string-p)))
;; Highlight HyWikiWords in any string following point
(hywiki-maybe-highlight-sexp 1))
(t (setq result nil)))
(error (setq result nil))))
(when result t)))))