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) where these positions exclude the delimiters. 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-20260822.1645/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)
where these positions exclude the delimiters.  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
    (when (natnump pos)
      (goto-char pos))
    (let* ((range
            (save-restriction
              ;; Limit balanced pair checks to current through next lines for speed.
              ;; 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
	   (wikiword (when str-start
                       (if (stringp (car range))
                           (car range)
                         (buffer-substring-no-properties str-start str-end))))
	   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))))