Function: idlwave-in-quote
idlwave-in-quote is a byte-compiled function defined in idlwave.el.gz.
Signature
(idlwave-in-quote)
Documentation
Return location of the opening quote if point is in a IDL string constant, nil otherwise. Ignores comment delimiters on the current line. Properly handles nested quotation marks and octal constants - a double quote followed by an octal digit.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/idlwave.el.gz
(defun idlwave-in-quote ()
"Return location of the opening quote
if point is in a IDL string constant, nil otherwise.
Ignores comment delimiters on the current line.
Properly handles nested quotation marks and octal
constants - a double quote followed by an octal digit."
;; Treat an octal inside an apostrophe to be a normal string. Treat a
;; double quote followed by an octal digit to be an octal constant
;; rather than a string. Therefore, there is no terminating double
;; quote.
(save-excursion
;; Because single and double quotes can quote each other we must
;; search for the string start from the beginning of line.
(let* ((start (point))
(eol (line-end-position))
(bq (progn (beginning-of-line) (point)))
(endq (point))
(data (match-data))
delim
found)
(while (< endq start)
;; Find string start
;; Don't find an octal constant beginning with a double quote
(if (re-search-forward "[\"']" eol 'lim)
;; Find the string end.
;; In IDL, two consecutive delimiters after the start of a
;; string act as an
;; escape for the delimiter in the string.
;; Two consecutive delimiters alone (i.e., not after the
;; start of a string) is the null string.
(progn
;; Move to position after quote
(goto-char (1+ (match-beginning 0)))
(setq bq (1- (point)))
;; Get the string delimiter
(setq delim (char-to-string (preceding-char)))
;; Check for null string
(if (looking-at delim)
(progn (setq endq (point)) (forward-char 1))
;; Look for next unpaired delimiter
(setq found (search-forward delim eol 'lim))
(while (looking-at delim)
(forward-char 1)
(setq found (search-forward delim eol 'lim)))
(setq endq (if found (1- (point)) (point)))
))
(progn (setq bq (point)) (setq endq (point)))))
(store-match-data data)
;; return string beginning position or nil
(if (> start bq) bq))))