Function: orgtbl-toggle-comment

orgtbl-toggle-comment is an interactive and byte-compiled function defined in org-table.el.gz.

Signature

(orgtbl-toggle-comment)

Documentation

Comment or uncomment the orgtbl at point.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-table.el.gz
(defun orgtbl-toggle-comment ()
  "Comment or uncomment the orgtbl at point."
  (interactive)
  (let* ((case-fold-search t)
	 (re1 (concat "^" (regexp-quote comment-start) orgtbl-line-start-regexp))
	 (re2 (concat "^" orgtbl-line-start-regexp))
	 (commented (save-excursion (beginning-of-line 1)
				    (cond ((looking-at re1) t)
					  ((looking-at re2) nil)
					  (t (user-error "Not at an org table")))))
	 (re (if commented re1 re2))
	 beg end)
    (save-excursion
      (beginning-of-line 1)
      (while (and (not (eq (point) (point-min)))
                  (looking-at re))
        (beginning-of-line 0))
      (unless (eq (point) (point-min)) (beginning-of-line 2))
      (setq beg (point))
      (while (and (not (eq (point) (point-max)))
                  (looking-at re))
        (beginning-of-line 2))
      (setq end (point)))
    (comment-region beg end (if commented '(4) nil))))