Function: c-electric-pound

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

Signature

(c-electric-pound ARG)

Documentation

Insert a "#".

If c-electric-flag is set, handle it specially according to the variable c-electric-pound-behavior. If a numeric ARG is supplied, or if point is inside a literal or a macro, nothing special happens.

Probably introduced at or before Emacs version 19.23.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cc-cmds.el.gz
(defun c-electric-pound (arg)
  "Insert a \"#\".
If `c-electric-flag' is set, handle it specially according to the variable
`c-electric-pound-behavior'.  If a numeric ARG is supplied, or if point is
inside a literal or a macro, nothing special happens."
  (interactive "*P")
  (if (c-save-buffer-state ()
	(or arg
	    (not c-electric-flag)
	    (not (memq 'alignleft c-electric-pound-behavior))
	    (save-excursion
	      (skip-chars-backward " \t")
	      (not (bolp)))
	    (save-excursion
	      (and (= (forward-line -1) 0)
		   (progn (end-of-line)
			  (eq (char-before) ?\\))))
	    (c-in-literal)))
      ;; do nothing special
      (let (post-self-insert-hook)	; Disable random functionality.
	(self-insert-command (prefix-numeric-value arg)))
    ;; place the pound character at the left edge
    (let ((pos (- (point-max) (point)))
	  (bolp (bolp)))
      (beginning-of-line)
      (delete-horizontal-space)
      (insert (c-last-command-char))
      (and (not bolp)
	   (goto-char (- (point-max) pos)))
      ))
  (c--call-post-self-insert-hook-more-safely))