From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Will Farrington Newsgroups: gmane.emacs.devel Subject: comment-dwim has no behavior to comment out the current line without a region Date: Tue, 9 Dec 2008 01:06:56 -0500 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v929.2) Content-Type: multipart/mixed; boundary=Apple-Mail-3--759970304 X-Trace: ger.gmane.org 1228826228 20137 80.91.229.12 (9 Dec 2008 12:37:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 9 Dec 2008 12:37:08 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Dec 09 13:38:13 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LA1qu-00045i-Lp for ged-emacs-devel@m.gmane.org; Tue, 09 Dec 2008 13:38:13 +0100 Original-Received: from localhost ([127.0.0.1]:42866 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LA1pj-0000Gp-J9 for ged-emacs-devel@m.gmane.org; Tue, 09 Dec 2008 07:36:59 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L9vkO-0002ve-9U for emacs-devel@gnu.org; Tue, 09 Dec 2008 01:07:04 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L9vkL-0002vS-BJ for emacs-devel@gnu.org; Tue, 09 Dec 2008 01:07:02 -0500 Original-Received: from [199.232.76.173] (port=40507 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L9vkL-0002vP-3J for emacs-devel@gnu.org; Tue, 09 Dec 2008 01:07:01 -0500 Original-Received: from yx-out-1718.google.com ([74.125.44.155]:7032) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1L9vkK-0002pI-QH for emacs-devel@gnu.org; Tue, 09 Dec 2008 01:07:01 -0500 Original-Received: by yx-out-1718.google.com with SMTP id 34so646705yxf.66 for ; Mon, 08 Dec 2008 22:06:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:from:to :content-type:mime-version:subject:date:x-mailer; bh=9nm9SMBkq1Z4Db3e+mjrUxRu+LqkfDq7NPtuVZHRF84=; b=kyhmzVAcXG2wKfSXoxrmkHlqXAiDFffz0EvaoYDVh8TCXTBz9dEfI23eJQFpN4Ublr WdQGLcoEGTZ5Q8GqxSjMWLLEGc8fhb12ve0appWS1ciNavFPKvl6OCeAfDQMhZcbQ68I gHRZPXfuRwRn5T7XIVZ/fOJ4RNlcP08TwV2KA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:content-type:mime-version:subject:date:x-mailer; b=ixdaG3aLkSB2kOaKiKWRyeBx/QkIs9W+RkyWCPDhe5ALYkSSLuXhCXBy5atlgMt1IZ kNa/SGG9qw1cv1HRB4D4b9UJ/GQV5bWgR3RdbD5RiFMRgIKzfZ1UJhCMVrfzNJqSU31L HymstZ30OAz2nf5iAf+hRXefd7tyWko9EK2zk= Original-Received: by 10.100.105.13 with SMTP id d13mr1955425anc.102.1228802818535; Mon, 08 Dec 2008 22:06:58 -0800 (PST) Original-Received: from r76h135.res.gatech.edu (r76h135.res.gatech.edu [128.61.76.135]) by mx.google.com with ESMTPS id b32sm1633773ana.54.2008.12.08.22.06.57 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 08 Dec 2008 22:06:57 -0800 (PST) X-Mailer: Apple Mail (2.929.2) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) X-Mailman-Approved-At: Tue, 09 Dec 2008 07:36:56 -0500 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:106714 Archived-At: --Apple-Mail-3--759970304 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit The subject states my specific objection to the current behavior. Yes, for many languages, it takes the same number of keystrokes to insert a comment character; however, there are languages/modes where this is *not* true (for example, C89 or anything based on XML). Additionally, it makes sense to have comment-dwim handle all cases of managing commented material and comments. The proposed diff adds the following additional behavior: If the point is at `line-beginning-position' (and the region is inactive), call `comment-region' on the whole line (unless the line consists of comments, in which case it calls `uncomment-region'). The patch is attached below: --Apple-Mail-3--759970304 Content-Disposition: attachment; filename=0001-Change-comment-dwim-behavior-to-comment-out-the-curr.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Change-comment-dwim-behavior-to-comment-out-the-curr.patch" Content-Transfer-Encoding: quoted-printable =46rom=20b3a783075ad4eafe9e2303442d68f6bec41cfaa6=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Will=20Farrington=20=0A= Date:=20Tue,=209=20Dec=202008=2001:00:18=20-0500=0ASubject:=20[PATCH]=20= Change=20comment-dwim=20behavior=20to=20comment=20out=20the=20current=20= line=20when=20region=20is=20inactive=20and=20point=20is=20at=20the=20= line-beginning-position.=0A=0A=0Adiff=20--git=20a/lisp/newcomment.el=20= b/lisp/newcomment.el=0Aindex=2091ece5a..acac17b=20100644=0A---=20= a/lisp/newcomment.el=0A+++=20b/lisp/newcomment.el=0A@@=20-1159,6=20= +1159,9=20@@=20is=20passed=20on=20to=20the=20respective=20function."=0A=20= If=20the=20region=20is=20active=20and=20`transient-mark-mode'=20is=20on,=20= call=0A=20=20=20`comment-region'=20(unless=20it=20only=20consists=20of=20= comments,=20in=20which=0A=20=20=20case=20it=20calls=20= `uncomment-region').=0A+Else,=20if=20the=20point=20is=20at=20= `line-beginning-position',=20call=20`comment-region'=0A+=20=20on=20the=20= whole=20line=20(unless=20the=20line=20consists=20of=20comments,=20in=20= which=0A+=20=20case=20it=20calls=20`uncomment-region').=0A=20Else,=20if=20= the=20current=20line=20is=20empty,=20call=20= `comment-insert-comment-function'=0A=20if=20it=20is=20defined,=20= otherwise=20insert=20a=20comment=20and=20indent=20it.=0A=20Else=20if=20a=20= prefix=20ARG=20is=20specified,=20call=20`comment-kill'.=0A@@=20-1168,23=20= +1171,25=20@@=20You=20can=20configure=20`comment-style'=20to=20change=20= the=20way=20regions=20are=20commented."=0A=20=20=20= (comment-normalize-vars)=0A=20=20=20(if=20(and=20mark-active=20= transient-mark-mode)=0A=20=20=20=20=20=20=20(comment-or-uncomment-region=20= (region-beginning)=20(region-end)=20arg)=0A-=20=20=20=20(if=20= (save-excursion=20(beginning-of-line)=20(not=20(looking-at=20"\\s-*$")))=0A= -=09;;=20FIXME:=20If=20there's=20no=20comment=20to=20kill=20on=20this=20= line=20and=20ARG=20is=0A-=09;;=20specified,=20calling=20comment-kill=20= is=20not=20very=20clever.=0A-=09(if=20arg=20(comment-kill=20(and=20= (integerp=20arg)=20arg))=20(comment-indent))=0A-=20=20=20=20=20=20;;=20= Inserting=20a=20comment=20on=20a=20blank=20line.=20comment-indent=20= calls=0A-=20=20=20=20=20=20;;=20c-i-c-f=20if=20needed=20in=20the=20= non-blank=20case.=0A-=20=20=20=20=20=20(if=20= comment-insert-comment-function=0A-=20=20=20=20=20=20=20=20=20=20= (funcall=20comment-insert-comment-function)=0A-=20=20=20=20=20=20=20=20= (let=20((add=20(comment-add=20arg)))=0A-=20=20=20=20=20=20=20=20=20=20;;=20= Some=20modes=20insist=20on=20keeping=20column=200=20comment=20in=20= column=200=0A-=20=20=20=20=20=20=20=20=20=20;;=20so=20we=20need=20to=20= move=20away=20from=20it=20before=20inserting=20the=20comment.=0A-=20=20=20= =20=20=20=20=20=20=20(indent-according-to-mode)=0A-=20=20=20=20=20=20=20=20= =20=20(insert=20(comment-padright=20comment-start=20add))=0A-=20=20=20=20= =20=20=20=20=20=20(save-excursion=0A-=20=20=20=20=20=20=20=20=20=20=20=20= (unless=20(string=3D=20""=20comment-end)=0A-=20=20=20=20=20=20=20=20=20=20= =20=20=20=20(insert=20(comment-padleft=20comment-end=20add)))=0A-=20=20=20= =20=20=20=20=20=20=20=20=20(indent-according-to-mode)))))))=0A+=20=20=20=20= (if=20(eq=20(point)=20(line-beginning-position))=0A+=20=20=20=20=20=20=20= =20(comment-or-uncomment-region=20(line-beginning-position)=20= (line-end-position))=0A+=20=20=20=20=20=20(if=20(save-excursion=20= (beginning-of-line)=20(not=20(looking-at=20"\\s-*$")))=0A+=20=20=20=20=20= =20=20=20=20=20;;=20FIXME:=20If=20there's=20no=20comment=20to=20kill=20= on=20this=20line=20and=20ARG=20is=0A+=20=20=20=20=20=20=20=20=20=20;;=20= specified,=20calling=20comment-kill=20is=20not=20very=20clever.=0A+=20=20= =20=20=20=20=20=20=20=20(if=20arg=20(comment-kill=20(and=20(integerp=20= arg)=20arg))=20(comment-indent))=0A+=20=20=20=20=20=20=20=20;;=20= Inserting=20a=20comment=20on=20a=20blank=20line.=20comment-indent=20= calls=0A+=20=20=20=20=20=20=20=20;;=20c-i-c-f=20if=20needed=20in=20the=20= non-blank=20case.=0A+=20=20=20=20=20=20=20=20(if=20= comment-insert-comment-function=0A+=20=20=20=20=20=20=20=20=20=20=20=20= (funcall=20comment-insert-comment-function)=0A+=20=20=20=20=20=20=20=20=20= =20(let=20((add=20(comment-add=20arg)))=0A+=20=20=20=20=20=20=20=20=20=20= =20=20;;=20Some=20modes=20insist=20on=20keeping=20column=200=20comment=20= in=20column=200=0A+=20=20=20=20=20=20=20=20=20=20=20=20;;=20so=20we=20= need=20to=20move=20away=20from=20it=20before=20inserting=20the=20= comment.=0A+=20=20=20=20=20=20=20=20=20=20=20=20= (indent-according-to-mode)=0A+=20=20=20=20=20=20=20=20=20=20=20=20= (insert=20(comment-padright=20comment-start=20add))=0A+=20=20=20=20=20=20= =20=20=20=20=20=20(save-excursion=0A+=20=20=20=20=20=20=20=20=20=20=20=20= =20=20(unless=20(string=3D=20""=20comment-end)=0A+=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20(insert=20(comment-padleft=20comment-end=20= add)))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (indent-according-to-mode))))))))=0A=20=0A=20;;;###autoload=0A=20= (defcustom=20comment-auto-fill-only-comments=20nil=0A--=20=0A1.6.0.4=0A=0A= --Apple-Mail-3--759970304 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit --Apple-Mail-3--759970304--