Function: hywiki-delimited-p

hywiki-delimited-p is a byte-compiled function defined in hywiki.el.

Signature

(hywiki-delimited-p &optional POS)

Documentation

Return non-nil if optional POS or point is surrounded by delimiters.

Any non-nil value returned is a list of (hywikiword-ref start-pos end-pos). The delimited range must be two lines or less with point on the first line.

Use hywiki-word-at, which calls this, to determine whether there is a HyWikiWord at point.

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hywiki.el
(defun hywiki-delimited-p (&optional pos)
  "Return non-nil if optional POS or point is surrounded by delimiters.
Any non-nil value returned is a list of (hywikiword-ref start-pos end-pos).
The delimited range must be two lines or less with point on the first line.

Use `hywiki-word-at', which calls this, to determine whether there is
a HyWikiWord at point."
  (save-excursion
    (save-restriction
      (when (natnump pos)
	(goto-char pos))
      ;; Limit balanced pair checks to current through next lines for speed.
      ;; Point must be either on the opening line.
      (narrow-to-region (line-beginning-position) (line-end-position 2))
      (let* ((range (or (hypb:in-string-p nil t)
			(hargs:delimited "[\[<\(\{]" "[\]\}\)\>]" t t t)))
	     (wikiword (car range))
             (str-start (nth 1 range))
             (str-end (nth 2 range))
	     range-trimmed
	     wikiword-trimmed)
	(if (and wikiword (string-match "[ \t\n\r\f]+\\'" wikiword))
	    ;; Strip any trailing whitespace
	    (setq wikiword-trimmed (substring wikiword 0 (match-beginning 0))
		  range-trimmed (when (car range)
                                  (list wikiword-trimmed str-start
                                        (- str-end (length (match-string
								  0 wikiword))))))
	  (setq range-trimmed (when (car range) range)))
	(and range-trimmed str-start str-end
	     ;; Ensure closing delimiter is a match for the opening one
	     (or (eq (matching-paren (or (char-before str-start)
                                         0))
		     (char-after str-end))
		 ;; May be string quotes where matching-paren returns nil.
		 (and (eq (char-before str-start)
			  (char-after str-end ))
		      (eq (char-syntax (char-before str-start)) ?\")))
	     range-trimmed)))))