Function: c-in-literal

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

Signature

(c-in-literal &optional LIM DETECT-CPP)

Documentation

Return the type of literal point is in, if any.

The return value is c if in a C-style comment, c++ if in a C++ style comment, string if in a string literal, pound if DETECT-CPP is non-nil and in a preprocessor line, or nil if somewhere else. Optional LIM is used as the backward limit of the search. If omitted, or nil, c-beginning-of-defun is used.

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
;; Tools for handling comments and string literals.

(defun c-in-literal (&optional _lim detect-cpp)
  "Return the type of literal point is in, if any.
The return value is `c' if in a C-style comment, `c++' if in a C++
style comment, `string' if in a string literal, `pound' if DETECT-CPP
is non-nil and in a preprocessor line, or nil if somewhere else.
Optional LIM is used as the backward limit of the search.  If omitted,
or nil, `c-beginning-of-defun' is used.

Note that this function might do hidden buffer changes.  See the
comment at the start of cc-engine.el for more info."
  (save-restriction
    (widen)
    (let ((lit (c-semi-pp-to-literal (point))))
      (or (cadr lit)
	  (and detect-cpp
	       (save-excursion (c-beginning-of-macro))
	       'pound)))))