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 03:28:29 -0500 Message-ID: <492E5CDD-4C3A-4995-97DD-C2A65133F8D5@gmail.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v929.2) Content-Type: multipart/mixed; boundary=Apple-Mail-6--751477669 X-Trace: ger.gmane.org 1228811328 7420 80.91.229.12 (9 Dec 2008 08:28:48 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 9 Dec 2008 08:28:48 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Dec 09 09:29:54 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 1L9xyZ-0004hf-Vt for ged-emacs-devel@m.gmane.org; Tue, 09 Dec 2008 09:29:53 +0100 Original-Received: from localhost ([127.0.0.1]:35673 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L9xxO-000663-Sn for ged-emacs-devel@m.gmane.org; Tue, 09 Dec 2008 03:28:38 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L9xxK-00065y-EE for emacs-devel@gnu.org; Tue, 09 Dec 2008 03:28:34 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L9xxJ-00065m-0Z for emacs-devel@gnu.org; Tue, 09 Dec 2008 03:28:34 -0500 Original-Received: from [199.232.76.173] (port=47589 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L9xxI-00065j-RA for emacs-devel@gnu.org; Tue, 09 Dec 2008 03:28:32 -0500 Original-Received: from yw-out-1718.google.com ([74.125.46.158]:4770) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1L9xxI-00065M-Cl for emacs-devel@gnu.org; Tue, 09 Dec 2008 03:28:32 -0500 Original-Received: by yw-out-1718.google.com with SMTP id 9so657205ywk.66 for ; Tue, 09 Dec 2008 00:28:31 -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 :in-reply-to:content-type:mime-version:subject:date:references :x-mailer; bh=ENA54wzjm601Cco7DryNxrE/7RIdCmlwArrh+H47Rr8=; b=MYTXXv4VASh8CzlC9muLudgkPoLCiC55zMptxSDiwOiX+AdlebjpHHVcF8W5AE/v0c rXZ+IKhykcbrhdMhSFlo8aa4yHsV9ofbH7piDIGFW5c921+/T7D3C+nMlYsCKdVmXbmT mGh6sIYf8chrQwJIqY4wqZL8BqK6Eg55XXkIA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:in-reply-to:content-type:mime-version:subject :date:references:x-mailer; b=eXbuFlIyw/VEW2jgR/a2f5yj/z/PZMsKBerEynjWFbzsRFUelv4Vqfp4lARZZuGYG4 PrBkWehfBhuqzC3se0DWM5PnToc6VKpoAdLXeB58ltdhfRmKJy2p6/c4Po+59Ib8EXwZ ccTGD+AvgsciTMHJQZbokuhWkYj1FtwMJVRMU= Original-Received: by 10.100.3.13 with SMTP id 13mr2020375anc.26.1228811311767; Tue, 09 Dec 2008 00:28:31 -0800 (PST) Original-Received: from lawn-128-61-25-5.lawn.gatech.edu (lawn-128-61-25-5.lawn.gatech.edu [128.61.25.5]) by mx.google.com with ESMTPS id c9sm20676685ana.59.2008.12.09.00.28.30 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 09 Dec 2008 00:28:30 -0800 (PST) In-Reply-To: X-Mailer: Apple Mail (2.929.2) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) 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:106709 Archived-At: --Apple-Mail-6--751477669 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Resending this because it seems to have gotten lost along the way (at least from what I could tell): -------------- 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-6--751477669 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-6--751477669--