unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: PEDRO ANDRES ARANDA GUTIERREZ <paranda@it.uc3m.es>, emacs-devel@gnu.org
Subject: RE: Just a thought about comment-line
Date: Sun, 31 May 2020 09:53:09 -0700 (PDT)	[thread overview]
Message-ID: <8f0555f1-4989-47ef-a990-aabddf50d595@default> (raw)
In-Reply-To: <CAPoMwp3rxz+oBGM=aHnPPqT_cvDzT7-b+sMK9-PbRMKVt7zjJg@mail.gmail.com>

> 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



  parent reply	other threads:[~2020-05-31 16:53 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-31  7:39 Just a thought about comment-line PEDRO ANDRES ARANDA GUTIERREZ
2020-05-31  9:57 ` Yuri Khan
2020-05-31 16:58   ` Drew Adams
2020-05-31 17:15     ` Stefan Monnier
2020-05-31 18:05       ` Drew Adams
2020-05-31 19:05         ` Stefan Monnier
2020-05-31 21:53           ` Drew Adams
2020-05-31 17:42     ` Dmitry Gutov
2020-05-31 18:08       ` Drew Adams
2020-05-31 18:31         ` Dmitry Gutov
2020-05-31 21:54           ` Drew Adams
2020-06-01  5:18             ` PEDRO ANDRES ARANDA GUTIERREZ
2020-06-01  5:29               ` PEDRO ANDRES ARANDA GUTIERREZ
2020-05-31 14:40 ` Eli Zaretskii
2020-05-31 16:53 ` Drew Adams [this message]
2020-06-01  6:14 ` Clément Pit-Claudel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8f0555f1-4989-47ef-a990-aabddf50d595@default \
    --to=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    --cc=paranda@it.uc3m.es \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).