Function: c-electric-star

c-electric-star is an interactive and byte-compiled function defined in cc-cmds.el.gz.

Signature

(c-electric-star ARG)

Documentation

Insert a star character.

If c-electric-flag and c-syntactic-indentation are both non-nil, and the star is the second character of a C style comment starter on a comment-only-line, indent the line as a comment. If a numeric ARG is supplied, point is inside a literal, or c-syntactic-indentation is nil, this indentation is inhibited.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cc-cmds.el.gz
(defun c-electric-star (arg)
  "Insert a star character.
If `c-electric-flag' and `c-syntactic-indentation' are both non-nil, and
the star is the second character of a C style comment starter on a
comment-only-line, indent the line as a comment.  If a numeric ARG is
supplied, point is inside a literal, or `c-syntactic-indentation' is nil,
this indentation is inhibited."

  (interactive "*P")
  (c-with-string-fences
   (let (post-self-insert-hook)		; Disable random functionality.
     (self-insert-command (prefix-numeric-value arg)))
   ;; if we are in a literal, or if arg is given do not reindent the
   ;; current line, unless this star introduces a comment-only line.
   (if (c-save-buffer-state ()
	 (and c-syntactic-indentation
	      c-electric-flag
	      (not arg)
	      (eq (c-in-literal) 'c)
	      (eq (char-before) ?*)
	      (save-excursion
		(forward-char -1)
		(skip-chars-backward "*")
		(if (eq (char-before) ?/)
		    (forward-char -1))
		(skip-chars-backward " \t")
		(bolp))))
       (let (c-echo-syntactic-information-p) ; shut this up
	 (indent-according-to-mode))))
  (c--call-post-self-insert-hook-more-safely))