Function: c-show-syntactic-information

c-show-syntactic-information is an interactive and byte-compiled function defined in cc-cmds.el.gz.

Signature

(c-show-syntactic-information ARG)

Documentation

Show syntactic information for current line.

With universal argument, inserts the analysis as a comment on that line.

Probably introduced at or before Emacs version 22.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cc-cmds.el.gz
(defun c-show-syntactic-information (arg)
  "Show syntactic information for current line.
With universal argument, inserts the analysis as a comment on that line."
  (interactive "P")
  (let* ((c-parsing-error nil)
	 (syntax (if (boundp 'c-syntactic-context)
		     ;; Use `c-syntactic-context' in the same way as
		     ;; `c-indent-line', to be consistent.
		     c-syntactic-context
		   (c-save-buffer-state nil
		     (c-guess-basic-syntax)))))
    (if (not (consp arg))
	(let (elem pos ols)
	  (message "Syntactic analysis: %s" syntax)
	  (unwind-protect
	      (progn
		(while syntax
		  (setq elem (pop syntax))
		  (when (setq pos (c-langelem-pos elem))
		    (push (c-put-overlay pos (1+ pos)
					 'face 'highlight)
			  ols))
		  (when (setq pos (c-langelem-2nd-pos elem))
		    (push (c-put-overlay pos (1+ pos)
					 'face 'secondary-selection)
			  ols)))
		(sit-for 10))
	    (while ols
	      (c-delete-overlay (pop ols)))))
      (indent-for-comment)
      (insert-and-inherit (format "%s" syntax))
      ))
  (c-keep-region-active))