Function: c-literal-type

c-literal-type is a byte-compiled function defined in cc-engine.el.gz.

Signature

(c-literal-type RANGE)

Documentation

Convenience function that given the result of c-literal-limits, returns nil or the type of literal that the range surrounds, one of the symbols c, c++ or string. It's much faster than using c-in-literal and is intended to be used when you need both the type of a literal and its limits.

Note that this function might do hidden buffer changes. See the comment at the start of cc-engine.el for more info.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cc-engine.el.gz
(defun c-literal-type (range)
  "Convenience function that given the result of `c-literal-limits',
returns nil or the type of literal that the range surrounds, one
of the symbols `c', `c++' or `string'.  It's much faster than using
`c-in-literal' and is intended to be used when you need both the
type of a literal and its limits.

Note that this function might do hidden buffer changes.  See the
comment at the start of cc-engine.el for more info."

  (if (consp range)
      (save-excursion
	(goto-char (car range))
	(cond ((looking-at c-string-limit-regexp) 'string)
	      ((or (looking-at "//") ; c++ line comment
		   (and (looking-at "\\s<") ; comment starter
			(looking-at "#"))) ; awk comment.
               'c++)
	      (t 'c)))			; Assuming the range is valid.
    range))