[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Just a thought about comment-line
From: |
Drew Adams |
Subject: |
RE: Just a thought about comment-line |
Date: |
Sun, 31 May 2020 09:53:09 -0700 (PDT) |
> you comment the region with M-x comment-line.
> You will have the line at the point:
> 1.- not highlighted before M-x comment-line
> 2.- commented after M-x comment-line
>
> ...it doesn't happen on other "popular" editors.
> Could we consider a variable customise the behaviour
> and allow the last line not to be commented when the
> mark is at the start of line?
Yes, you can. (And yes, Emacs should offer this
behavior out of the box, IMO.)
I use this command (I bind it to `C-x C-;). It's
from library `misc-cmds.el'.
(defun comment-region-lines (beg end &optional arg)
"Like `comment-region' (which see), but comment or uncomment whole lines."
(interactive "*r\nP")
(when (> beg end)
(setq beg (prog1 end (setq end beg))))
(let ((bol (save-excursion
(goto-char beg)
(line-beginning-position)))
(eol (save-excursion
(goto-char end)
(if (bolp)
(point)
(line-end-position)))))
(comment-region bol eol arg)))
https://www.emacswiki.org/emacs/download/misc-cmds.el