Function: org-insert-comment

org-insert-comment is a byte-compiled function defined in org.el.gz.

Signature

(org-insert-comment)

Documentation

Insert an empty comment above current line.

If the line is empty, insert comment at its beginning. When point is within a source block, comment according to the related major mode.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org.el.gz
(defun org-insert-comment ()
  "Insert an empty comment above current line.
If the line is empty, insert comment at its beginning.  When
point is within a source block, comment according to the related
major mode."
  (if (let ((element (org-element-at-point)))
	(and (org-element-type-p element 'src-block)
	     (< (save-excursion
		  (goto-char (org-element-post-affiliated element))
		  (line-end-position))
		(point))
	     (> (save-excursion
		  (goto-char (org-element-end element))
		  (skip-chars-backward " \r\t\n")
		  (line-beginning-position))
		(point))))
      (org-babel-do-in-edit-buffer (call-interactively 'comment-dwim))
    (forward-line 0)
    (if (looking-at "\\s-*$") (delete-region (point) (line-end-position))
      (open-line 1))
    (org-indent-line)
    (insert "# ")))