Function: c-electric-pragma

c-electric-pragma is a byte-compiled function defined in cc-cmds.el.gz.

Signature

(c-electric-pragma)

Documentation

Reindent the current line if appropriate.

This function is used to reindent a preprocessor line when the symbol for the directive, typically "pragma", triggers this function as a hook function of an abbreviation.

The "#" of the preprocessor construct is aligned under the first anchor point of the line's syntactic context.

The line is reindented if the construct is not in a string or comment, there is exactly one "#" contained in optional whitespace before it on the current line, and c-electric-flag and c-syntactic-indentation are both non-nil.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cc-cmds.el.gz
(defun c-electric-pragma ()
  "Reindent the current line if appropriate.

This function is used to reindent a preprocessor line when the
symbol for the directive, typically \"pragma\", triggers this
function as a hook function of an abbreviation.

The \"#\" of the preprocessor construct is aligned under the
first anchor point of the line's syntactic context.

The line is reindented if the construct is not in a string or
comment, there is exactly one \"#\" contained in optional
whitespace before it on the current line, and `c-electric-flag'
and `c-syntactic-indentation' are both non-nil."
  (save-excursion
    (save-match-data
      (when
	  (and
	   c-cpp-indent-to-body-flag
	   c-electric-flag
	   c-syntactic-indentation
	   last-abbrev-location
	   c-opt-cpp-symbol		; "#" or nil.
	   (progn (back-to-indentation)
		  (looking-at (concat c-opt-cpp-symbol "[ \t]*")))
	   (>= (match-end 0) last-abbrev-location)
	   (not (c-literal-limits)))
	(c-indent-line (delete '(cpp-macro) (c-guess-basic-syntax)))))))