emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [PATCH] newcomment.el (comment-line): New command.


From: Drew Adams
Subject: RE: [PATCH] newcomment.el (comment-line): New command.
Date: Sun, 1 Feb 2015 13:40:28 -0800 (PST)

> FWIW, the command I suggested is indeed repeatable because it moves
> `forward-line' after commenting the line. So you can just invoke it
> repeatedly to comment several lines (for those who don't use prefix
> arguments).

My bad; I didn't notice that it was repeatable.

Yes, that's useful, and yes, it makes sense to use a repeatable key.
Maybe `C-;'.  (Fits with the repeatable versions of `C-a' and `C-e'
that I use. ;-))

Consider letting a negative prefix arg be carried over to
repetitions, so you can do C-- C-; C-; C-; ... to do it
backwards.  Currently you need to do C-- C-; C-- C-; C-- C-; ...

E.g., something like this:

(defun comment-line (n)
  "Comment or uncomment current line and leave point after it.
With positive prefix arg, apply to N lines including current one.
With negative prefix arg, apply to -N lines above.
When repeated, a negative prefix arg switches direction."
  (interactive "p")
  (when (eq last-command 'comment-line-backward) (setq n (- n)))
  (let ((range (list (line-beginning-position)
                     (goto-char (line-end-position n)))))
    (comment-or-uncomment-region
     (apply #'min range)
     (apply #'max range)))
  (forward-line 1)
  (back-to-indentation)
  (unless (natnump n) (setq this-command 'comment-line-backward)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]