Function: haskell-lexeme--scan-string-literal
haskell-lexeme--scan-string-literal is a natively compiled function
defined in haskell-lexeme.el.
Signature
(haskell-lexeme--scan-string-literal QUOTES NEWLINE-TERMINATES)
Documentation
Scan the string literal at point delimited by QUOTES double quotes.
Point must be at a run of at least QUOTES double quotes. The literal ends at the earliest unescaped run of at least QUOTES double quotes; a shorter unescaped run is content. When NEWLINE-TERMINATES is non-nil an unescaped newline leaves the literal unterminated, and otherwise a newline is content.
Always return non-nil, with match data:
(match-text 1) matches the opening delimiter.
(match-text 2) matches the inside of the string.
(match-text 3) matches the closing delimiter, or is nil when
the literal is unterminated.
An unterminated literal ends before an unescaped newline when NEWLINE-TERMINATES is non-nil, and otherwise at the end of the buffer. When it ends at the end of the buffer, the whole match and the inside are guaranteed to extend to the end of the buffer.
Source Code
;; Defined in /nix/store/9lz2mhw95f9fqxr9mnq46k3f6qz3aq83-emacs-packages-deps/share/emacs/site-lisp/elpa/haskell-mode-20260904.1042/haskell-lexeme.el
(defun haskell-lexeme--scan-string-literal (quotes newline-terminates)
"Scan the string literal at point delimited by QUOTES double quotes.
Point must be at a run of at least QUOTES double quotes. The
literal ends at the earliest unescaped run of at least QUOTES
double quotes; a shorter unescaped run is content. When
NEWLINE-TERMINATES is non-nil an unescaped newline leaves the
literal unterminated, and otherwise a newline is content.
Always return non-nil, with match data:
(match-text 1) matches the opening delimiter.
(match-text 2) matches the inside of the string.
(match-text 3) matches the closing delimiter, or is nil when
the literal is unterminated.
An unterminated literal ends before an unescaped newline when
NEWLINE-TERMINATES is non-nil, and otherwise at the end of the
buffer. When it ends at the end of the buffer, the whole match
and the inside are guaranteed to extend to the end of the
buffer."
(save-excursion
(let* ((begin (point))
(content (+ begin quotes))
(closer-tail (make-string (1- quotes) ?\"))
(terminators (if newline-terminates "[\"\n\\]" "[\"\\]"))
finish)
(goto-char content)
(while (and (not finish)
(re-search-forward terminators nil 'goto-eob))
(cond
((equal (match-string 0) "\\")
(if (looking-at "[ \t\n\r\v\f]+\\\\?")
(goto-char (match-end 0))
(goto-char (1+ (point)))))
((equal (match-string 0) "\"")
(let ((q (match-beginning 0)))
(if (looking-at closer-tail)
(progn
(set-match-data
(list begin (+ q quotes)
begin content
content q
q (+ q quotes)))
(setq finish t))
(skip-chars-forward "\""))))
((equal (match-string 0) "\n")
(set-match-data
(list begin (match-beginning 0)
begin content
content (match-beginning 0)
nil nil))
(setq finish t))))
(unless finish
;; string closed by end of buffer
(set-match-data
(list begin (point)
begin content
content (point)
nil nil)))))
t)