Function: hywiki--extend-region
hywiki--extend-region is a byte-compiled function defined in
hywiki.el.
Signature
(hywiki--extend-region START END)
Documentation
Extend range (START END) to include delimited regions; return the new range.
Ensure START and END are in increasing order.
Used to extend a region to fully include any strings or balanced pair delimiters.
Source Code
;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hywiki.el
(defun hywiki--extend-region (start end)
"Extend range (START END) to include delimited regions; return the new range.
Ensure START and END are in increasing order.
Used to extend a region to fully include any strings or balanced pair
delimiters."
(unless (integer-or-marker-p start)
(error "`start' arg must be an integer or marker, not '%s'" start))
(unless (integer-or-marker-p end)
(error "`end' arg must be an integer or marker, not '%s'" end))
(let ((maximum (max start end)))
(setq start (min start end)
end (max end maximum)))
(let ((result (list start end))
(in-string-flag (hypb:in-string-p)))
;; Skip past all double-quoted ranges and extend `start' and `end' as needed
(save-excursion
(goto-char start)
(condition-case nil
(while (and (<= (point) end)
(skip-syntax-forward "^\"" (unless in-string-flag end))
(not (zerop (skip-syntax-forward
"\"" (unless in-string-flag end))))
(= ?\" (char-syntax (preceding-char))))
(when (or (= (1- (point)) (point-min))
(/= ?\\ (char-before (1- (point)))))
(save-excursion
(if (hypb:in-string-p)
(setq end (max end (goto-char (scan-sexps (1- (point)) 1))))
;; after a string
(setq start (min start (goto-char (scan-sexps (point) -1)))))
(setq result (list start end)))))
(error nil)))
;; From `start', skip past the first closing delimiter and extend
;; region start to include its opening delimiter, if any.
(save-excursion
(goto-char start)
(condition-case nil
(while (and (<= (point) end)
(skip-syntax-forward "^\)")
(not (zerop (skip-syntax-forward "\)")))
(= ?\) (char-syntax (preceding-char))))
(when (or (= (1- (point)) (point-min))
(/= ?\\ (char-before (1- (point)))))
(save-excursion
(setq start (min start (goto-char (scan-sexps (point) -1)))
result (list start end)))))
(error nil)))
;; From `end', skip back past the first opening delimiter and
;; extend region end to include its closing delimiter, if any.
(save-excursion
(goto-char end)
(condition-case nil
(while (and (>= (point) start)
(skip-syntax-backward "^\(")
(not (zerop (skip-syntax-backward "\(")))
(= ?\( (char-syntax (following-char))))
(when (not (eq ?\\ (char-before (max (point) (point-min)))))
(save-excursion
(setq end (max end (goto-char (scan-sexps (point) 1)))
result (list start end)))))
(error nil)))
;; Extend any highlighting as `hywiki-word-at' dictates
(save-excursion
(cl-destructuring-bind (_ ref-start ref-end)
(hywiki-word-at :range)
(when (and ref-start ref-end)
(when (< ref-start start)
(setq start ref-start))
(when (> ref-end end)
(setq end ref-end)))))
;; Skip past any current word at start and end to extend if needed
(save-excursion
(goto-char start)
(skip-chars-forward " \t\n\r")
(skip-syntax-backward "w")
(setq start (point))
(goto-char end)
(setq result (nth 2 (hywiki-delimited-p))
end (or result end))
(unless result
(skip-chars-backward " \t\n\r")
(skip-syntax-forward "w")
(setq end (point)))
(setq result (list start end)))
result))