[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: finding the hork point in ~/.emacs
From: |
Drew Adams |
Subject: |
RE: finding the hork point in ~/.emacs |
Date: |
Wed, 26 Aug 2020 19:58:23 -0700 (PDT) |
[I really must remember that Reply All to you doesn't
send to the list, for some reason. Sending again,
ccing it explicitly.]
> > If you use `C-u M-x comment-region' it UNcomments.
>
> Try M-; for `comment-dwim'. It comments and then
> uncomments if the region contains a comment.
... which is not as good as `comment-region', IMHO.
I use `M-;' only for eol comments. IMO, it's not
really made for block (un)commenting.
`comment-region' works well with nesting comment
blocks - it unnests a given level of nesting.
(Almost like having Common Lisp's `#|' and `|#'.)
`M-;' commenting or uncommenting a line in the
region, depending on whether the line is commented,
is never what I want. It's a poor substitute for
uncommenting a given level of commenting. YMMV.
> Also, this preserves comments already there. So if you have
> ... do M-;
> ... do M-; again ...
`comment-region' does all of that, & more, & better.
I actually use my `comment-region-lines', which I
bind to `C-x C-;':
(defun comment-region-lines (beg end &optional arg)
"Like `comment-region', but comment/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)))
> M-; is also one of the most ergonomic keystrokes on
> the keyboard, so make sure to use it often :)
`M-;' has been there forever for eol comments, long
before they added half-baked region-(un)commenting
behavior to it.
Re: finding the hork point in ~/.emacs, Emanuel Berg, 2020/08/26
Re: finding the hork point in ~/.emacs, Carson Chittom, 2020/08/26
Message not available
Re: finding the hork point in ~/.emacs, Emanuel Berg, 2020/08/26