From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.devel Subject: RE: [PATCH] newcomment.el (comment-line): New command. Date: Mon, 26 Jan 2015 18:53:45 -0800 (PST) Message-ID: <68eca5a1-04b6-462a-bf70-4abb02b72460@default> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1422327245 21423 80.91.229.3 (27 Jan 2015 02:54:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 27 Jan 2015 02:54:05 +0000 (UTC) Cc: emacs-devel To: bruce.connor.am@gmail.com, Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jan 27 03:54:00 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YFwHv-0002AK-EE for ged-emacs-devel@m.gmane.org; Tue, 27 Jan 2015 03:53:59 +0100 Original-Received: from localhost ([::1]:45045 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFwHu-0004VM-Qo for ged-emacs-devel@m.gmane.org; Mon, 26 Jan 2015 21:53:58 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49593) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFwHp-0004MD-U3 for emacs-devel@gnu.org; Mon, 26 Jan 2015 21:53:54 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YFwHm-0002qp-Og for emacs-devel@gnu.org; Mon, 26 Jan 2015 21:53:53 -0500 Original-Received: from aserp1040.oracle.com ([141.146.126.69]:50345) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFwHm-0002qZ-J4 for emacs-devel@gnu.org; Mon, 26 Jan 2015 21:53:50 -0500 Original-Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t0R2rlTi009483 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 27 Jan 2015 02:53:48 GMT Original-Received: from aserz7022.oracle.com (aserz7022.oracle.com [141.146.126.231]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id t0R2rkdV024182 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Tue, 27 Jan 2015 02:53:46 GMT Original-Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by aserz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id t0R2rjUl027124; Tue, 27 Jan 2015 02:53:45 GMT In-Reply-To: X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.8.2 (807160) [OL 12.0.6691.5000 (x86)] X-Source-IP: ucsinet21.oracle.com [156.151.31.93] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 141.146.126.69 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:181816 Archived-At: >> =C2=A0 =C2=A0C-a C-SPC C-n M-; >> >> works for me when I need it.=C2=A0 M-x comment-line RET is much longer (= even >> if you shorten it with something like partial-completion), so for such >> a command to make sense, you'd need a key binding for it. >=20 > Yes, you would. I didn't mention keybinds yet, because I was tackling thi= s by parts.=20 >=20 > I bind it to `C-;'. Another viable key might be `C-M-;'. But it definitel= y > needs a key.=20 > > When you want to comment/uncomment something between 1 and 9 lines, it > always requires less keypresses than the M-; alternative. > Besides, commenting a single line is such a common scenario, I find it > deserves a single key instead of a 4 key combo.=20 > It's also something that a lot of IDE's assign to a hotkey, so I'm sure > I'm not the only one that finds it useful. :-) And people who come from > other editors are sure to miss it. FWIW, I use a variant of `comment-region' (below). I bind it to `C-x C-;'. (The other, repeatable, keys you mention are too good to waste on a non-repeating command.) (defun comment-region-lines (beg end &optional arg) "Like `comment-region' (which see), but comment/uncomment whole lines." (interactive "*r\nP") (if (> beg end) (let (mid) (setq mid beg beg end end mid))) (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))) If the region is empty then it comments the current line. (But it does not distinguish active from inactive region. That would be another possible behavior choice.) I use this all the time. I use `M-;' (`comment-dwim') only for an end-of-line comment (as in the good old days). I find that `M-;' is quite poor for commenting and uncommenting the region (including nesting and unnesting comment levels etc.). `comment-region' is much better for that, IMO. And as enhanced above, it comments whole lines, which is what I typically want.