Function: idlwave-toggle-comment-region

idlwave-toggle-comment-region is an interactive and byte-compiled function defined in idlwave.el.gz.

Signature

(idlwave-toggle-comment-region BEG END &optional N)

Documentation

Comment the lines in the region if the first non-blank line is commented, and conversely, uncomment region. If optional prefix arg N is non-nil, then for N positive, add N comment delimiters or for N negative, remove N comment delimiters. Uses comment-region which does not place comment delimiters on blank lines.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/obsolete/idlwave.el.gz
(defun idlwave-toggle-comment-region (beg end &optional n)
  "Comment the lines in the region if the first non-blank line is
commented, and conversely, uncomment region.  If optional prefix arg
N is non-nil, then for N positive, add N comment delimiters or for N
negative, remove N comment delimiters.
Uses `comment-region' which does not place comment delimiters on
blank lines."
  (interactive "r\nP")
  (if n
      (comment-region beg end (prefix-numeric-value n))
    (save-excursion
      (goto-char beg)
      (beginning-of-line)
      ;; skip blank lines
      (skip-chars-forward " \t\n")
      (if (looking-at (concat "[ \t]*\\(" comment-start "+\\)"))
          (uncomment-region beg end)
	(comment-region beg end)))))