From cjm@cjmweb.net Wed Jun 11 10:11:31 2008 X-Spam-Checker-Version: SpamAssassin 3.2.3-bugs.debian.org_2005_01_02 (2007-08-08) on rzlab.ucr.edu X-Spam-Level: X-Spam-Status: No, score=-5.0 required=4.0 tests=BAYES_00,FVGT_m_MULTI_ODD, MURPHY_DRUGS_REL8,RCVD_IN_DNSWL_LOW autolearn=ham version=3.2.3-bugs.debian.org_2005_01_02 Received: (at submit) by emacsbugs.donarmstrong.com; 11 Jun 2008 17:11:31 +0000 Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m5BHBO6q032594 for ; Wed, 11 Jun 2008 10:11:25 -0700 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K6Tr1-0003Ey-SJ for bug-gnu-emacs@gnu.org; Wed, 11 Jun 2008 13:11:23 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K6Tqy-0003DT-Qk for bug-gnu-emacs@gnu.org; Wed, 11 Jun 2008 13:11:23 -0400 Received: from [199.232.76.173] (port=34187 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K6Tqy-0003DQ-Mh for bug-gnu-emacs@gnu.org; Wed, 11 Jun 2008 13:11:20 -0400 Received: from a-sasl-quonix.sasl.smtp.pobox.com ([208.72.237.25]:47180 helo=sasl.smtp.pobox.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1K6Tqy-0007RT-Jf for bug-gnu-emacs@gnu.org; Wed, 11 Jun 2008 13:11:20 -0400 Received: from localhost.localdomain (localhost [127.0.0.1]) by a-sasl-quonix.sasl.smtp.pobox.com (Postfix) with ESMTP id 9E08F24B9 for ; Wed, 11 Jun 2008 13:11:15 -0400 (EDT) Received: from orthanc.cjmweb.net (cpe-24-175-86-179.tx.res.rr.com [24.175.86.179]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-sasl-quonix.sasl.smtp.pobox.com (Postfix) with ESMTPSA id 3B8DB24B8 for ; Wed, 11 Jun 2008 13:11:13 -0400 (EDT) Received: (qmail 7262 invoked by uid 1000); 11 Jun 2008 17:11:02 -0000 Date: 11 Jun 2008 17:11:02 -0000 Message-ID: <20080611171102.7261.qmail@byte.local> From: "Christopher J. Madsen" To: bug-gnu-emacs@gnu.org Subject: [PATCH] comment-indent doesn't respect comment-indent-function X-Pobox-Relay-ID: 6665F4FE-37D9-11DD-910D-B8BFEAD4C077-09214675!a-sasl-quonix.pobox.com X-detected-kernel: by monty-python.gnu.org: Solaris 10 (beta) Please describe exactly what actions triggered the bug and the precise symptoms of the bug: It appears that comment-indent changed in 22.1. It gained some code to attempt to align the comment with those on surrounding lines. Unfortunately, this made it impossible to do certain things with comment-indent-function. For example, I had a custom indent function that placed comments immediately after a closing brace. However, in Emacs 22, I'd see this: while (1) { while (2) { } # end 2 <-- this comment placed correctly } # end 1 <-- this comment was aligned with the previous one instead of this: while (1) { while (2) { } # end 2 } # end 1 <-- here's where comment-indent-function placed it On the other hand, I do like the idea of automatically aligning comments. I had code in my custom indent functions to do that, but it would be nice if I didn't need to handle that in every indent function. I think what's needed is a way for comment-indent-function to distinguish between "Here's where the comment goes, and that's final" and "I suggest this position, but make it blend in with the neighborhood". Ideally, this would be backwards-compatible with older versions of Emacs. Here's a patch I came up with to provide that. If comment-indent-function sets comment-indent-fixed to non-nil, then the return value will be used as-is. Otherwise, it behaves like Emacs 22.2 did. Perhaps the sense should be reversed, and it should always respect the value of comment-indent-function unless told it's ok to adjust it. *** orig/newcomment.el Fri Mar 07 18:01:12 2008 --- new/newcomment.el Wed Jun 11 11:13:24 2008 *************** (defvar comment-indent-function 'comment *** 135,140 **** --- 135,143 ---- This function is called with no args with point at the beginning of the comment's starting delimiter and should return either the desired column indentation or nil. + The returned value may be adjusted by `comment-choose-indent'. + To prevent that, the function should set `comment-indent-fixed' + to a non-nil value. If nil is returned, indentation is delegated to `indent-according-to-mode'.") ;;;###autoload *************** (defun comment-indent (&optional continu *** 585,591 **** (beginning-of-line) (let* ((eolpos (line-end-position)) (begpos (comment-search-forward eolpos t)) ! cpos indent) ;; An existing comment? (if begpos (progn --- 588,594 ---- (beginning-of-line) (let* ((eolpos (line-end-position)) (begpos (comment-search-forward eolpos t)) ! cpos indent comment-indent-fixed) ;; An existing comment? (if begpos (progn *************** (defun comment-indent (&optional continu *** 622,636 **** (if (not indent) ;; comment-indent-function refuses: delegate to line-indent. (indent-according-to-mode) ! ;; If the comment is at the right of code, adjust the indentation. ! (unless (save-excursion (skip-chars-backward " \t") (bolp)) ! (setq indent (comment-choose-indent indent))) ! ;; Update INDENT to leave at least one space ! ;; after other nonwhite text on the line. ! (save-excursion ! (skip-chars-backward " \t") ! (unless (bolp) ! (setq indent (max indent (1+ (current-column)))))) ;; If that's different from comment's current position, change it. (unless (= (current-column) indent) (delete-region (point) (progn (skip-chars-backward " \t") (point))) --- 625,640 ---- (if (not indent) ;; comment-indent-function refuses: delegate to line-indent. (indent-according-to-mode) ! (unless comment-indent-fixed ! ;; If the comment is at the right of code, adjust the indentation. ! (unless (save-excursion (skip-chars-backward " \t") (bolp)) ! (setq indent (comment-choose-indent indent))) ! ;; Update INDENT to leave at least one space ! ;; after other nonwhite text on the line. ! (save-excursion ! (skip-chars-backward " \t") ! (unless (bolp) ! (setq indent (max indent (1+ (current-column))))))) ;; If that's different from comment's current position, change it. (unless (= (current-column) indent) (delete-region (point) (progn (skip-chars-backward " \t") (point))) In GNU Emacs 22.2.1 (i386-mingw-nt5.1.2600) of 2008-03-26 on RELEASE Windowing system distributor `Microsoft Corp.', version 5.1.2600 configured using `configure --with-gcc (3.4)' -- Chris Madsen cjm cjmweb.net -------------------- http://www.cjmweb.net -------------------- From monnier@iro.umontreal.ca Wed Jun 11 11:05:16 2008 X-Spam-Checker-Version: SpamAssassin 3.2.3-bugs.debian.org_2005_01_02 (2007-08-08) on rzlab.ucr.edu X-Spam-Level: X-Spam-Status: No, score=-6.0 required=4.0 tests=AWL,BAYES_00,HAS_BUG_NUMBER, MURPHY_DRUGS_REL8,RCVD_IN_DNSWL_LOW autolearn=ham version=3.2.3-bugs.debian.org_2005_01_02 Received: (at submit) by emacsbugs.donarmstrong.com; 11 Jun 2008 18:05:16 +0000 Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m5BI5CEv013352 for ; Wed, 11 Jun 2008 11:05:14 -0700 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K6Uh6-0004LX-E5 for bug-gnu-emacs@gnu.org; Wed, 11 Jun 2008 14:05:12 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K6Uh5-0004L9-R0 for bug-gnu-emacs@gnu.org; Wed, 11 Jun 2008 14:05:12 -0400 Received: from [199.232.76.173] (port=49404 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K6Uh5-0004Kw-KP for bug-gnu-emacs@gnu.org; Wed, 11 Jun 2008 14:05:11 -0400 Received: from mercure.iro.umontreal.ca ([132.204.24.67]:48451) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1K6Uh5-0002QT-JO for bug-gnu-emacs@gnu.org; Wed, 11 Jun 2008 14:05:11 -0400 Received: from hidalgo.iro.umontreal.ca (hidalgo.iro.umontreal.ca [132.204.27.50]) by mercure.iro.umontreal.ca (Postfix) with ESMTP id EBD712CFE75; Wed, 11 Jun 2008 14:05:10 -0400 (EDT) Received: from faina.iro.umontreal.ca (faina.iro.umontreal.ca [132.204.26.177]) by hidalgo.iro.umontreal.ca (Postfix) with ESMTP id CE2E03FE1; Wed, 11 Jun 2008 14:04:57 -0400 (EDT) Received: by faina.iro.umontreal.ca (Postfix, from userid 20848) id B370841BEC; Wed, 11 Jun 2008 14:04:57 -0400 (EDT) From: Stefan Monnier To: "Christopher J. Madsen" Cc: 385@debbugs.gnu.org, bug-gnu-emacs@gnu.org Subject: Re: bug#385: [PATCH] comment-indent doesn't respect comment-indent-function Message-ID: References: <20080611171102.7261.qmail@byte.local> Date: Wed, 11 Jun 2008 14:04:57 -0400 In-Reply-To: <20080611171102.7261.qmail@byte.local> (Christopher J. Madsen's message of "11 Jun 2008 17:11:02 -0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-DIRO-MailScanner-Information: Please contact the ISP for more information X-DIRO-MailScanner: Found to be clean X-DIRO-MailScanner-SpamCheck: n'est pas un polluriel, SpamAssassin (score=-2.82, requis 5, autolearn=not spam, ALL_TRUSTED -2.82) X-DIRO-MailScanner-From: monnier@iro.umontreal.ca X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) X-CrossAssassin-Score: 2 > It appears that comment-indent changed in 22.1. It gained some code Indeed, and it changed further in 22.2. > to attempt to align the comment with those on surrounding lines. > Unfortunately, this made it impossible to do certain things with > comment-indent-function. > For example, I had a custom indent function that placed comments > immediately after a closing brace. However, in Emacs 22, I'd see this: > while (1) { > while (2) { > } # end 2 <-- this comment placed correctly > } # end 1 <-- this comment was aligned with the previous one > instead of this: > while (1) { > while (2) { > } # end 2 > } # end 1 <-- here's where comment-indent-function placed it I'm not sure I understand. Are you saying that you don't want comments to be aligned in that case? If you need more control over the placement, rather than a variable comment-indent-fixed, maybe we should just say that if comment-indent-function returns a list of a single integer, it should be taken as the indentation position and not second-guessed. Or it could return a cons cell (MIN . MAX) to say "anywhere between MIN and MAX". Stefan From cjm@cjmweb.net Wed Jun 11 11:59:15 2008 X-Spam-Checker-Version: SpamAssassin 3.2.3-bugs.debian.org_2005_01_02 (2007-08-08) on rzlab.ucr.edu X-Spam-Level: X-Spam-Status: No, score=-7.0 required=4.0 tests=AWL,BAYES_00,HAS_BUG_NUMBER, MURPHY_DRUGS_REL8,RCVD_IN_DNSWL_LOW autolearn=ham version=3.2.3-bugs.debian.org_2005_01_02 Received: (at submit) by emacsbugs.donarmstrong.com; 11 Jun 2008 18:59:15 +0000 Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m5BIxAGj025678 for ; Wed, 11 Jun 2008 11:59:11 -0700 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K6VXK-0001eQ-AB for bug-gnu-emacs@gnu.org; Wed, 11 Jun 2008 14:59:10 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K6VXJ-0001dH-4G for bug-gnu-emacs@gnu.org; Wed, 11 Jun 2008 14:59:09 -0400 Received: from [199.232.76.173] (port=40192 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K6VXI-0001cz-PL for bug-gnu-emacs@gnu.org; Wed, 11 Jun 2008 14:59:08 -0400 Received: from a-sasl-quonix.sasl.smtp.pobox.com ([208.72.237.25]:62351 helo=sasl.smtp.pobox.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1K6VXI-00037Z-QU for bug-gnu-emacs@gnu.org; Wed, 11 Jun 2008 14:59:08 -0400 Received: from localhost.localdomain (localhost [127.0.0.1]) by a-sasl-quonix.sasl.smtp.pobox.com (Postfix) with ESMTP id B72253172 for ; Wed, 11 Jun 2008 14:59:04 -0400 (EDT) Received: from orthanc.cjmweb.net (cpe-24-175-86-179.tx.res.rr.com [24.175.86.179]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-sasl-quonix.sasl.smtp.pobox.com (Postfix) with ESMTPSA id 7A3B03171 for ; Wed, 11 Jun 2008 14:59:02 -0400 (EDT) Received: (qmail 8228 invoked from network); 11 Jun 2008 18:59:01 -0000 Received: from localhost (HELO cjm.myvnc.com) (127.0.0.1) by localhost with SMTP; 11 Jun 2008 18:59:01 -0000 Received: from 75.39.61.37 (SquirrelMail authenticated user cjm) by cjm.myvnc.com with HTTP; Wed, 11 Jun 2008 13:59:01 -0500 (CDT) Message-ID: <21310.75.39.61.37.1213210741.squirrel@cjm.myvnc.com> In-Reply-To: References: <20080611171102.7261.qmail@byte.local> Date: Wed, 11 Jun 2008 13:59:01 -0500 (CDT) Subject: Re: bug#385: [PATCH] comment-indent doesn't respect comment-indent-function From: "Christopher J. Madsen" To: "Stefan Monnier" Cc: 385@debbugs.gnu.org, bug-gnu-emacs@gnu.org User-Agent: SquirrelMail/1.4.10a MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 X-Priority: 3 (Normal) Importance: Normal X-Pobox-Relay-ID: 7648AFEC-37E8-11DD-8FDA-B8BFEAD4C077-09214675!a-sasl-quonix.pobox.com Content-Transfer-Encoding: quoted-printable X-detected-kernel: by monty-python.gnu.org: Solaris 10 (beta) On Wed, June 11, 2008 1:04 pm, Stefan Monnier wrote: >> It appears that comment-indent changed in 22.1. It gained some code >> For example, I had a custom indent function that placed comments >> immediately after a closing brace. However, in Emacs 22, I'd see this= : > >> while (1) { >> while (2) { > >> } # end 2 <-- this comment placed correctly >> } # end 1 <-- this comment was aligned with the previous one > >> instead of this: > >> while (1) { >> while (2) { > >> } # end 2 >> } # end 1 <-- here's where comment-indent-function placed it > > I'm not sure I understand. Are you saying that you don't want comments > to be aligned in that case? Yes. I want the comment one space after the closing brace. Period. In Emacs 22, there's no way for the comment-indent-function to say "Put it here and don't second guess me." > If you need more control over the placement, rather than a variable > comment-indent-fixed, maybe we should just say that if > comment-indent-function returns a list of a single integer, it should b= e > taken as the indentation position and not second-guessed. Or it could > return a cons cell (MIN . MAX) to say "anywhere between MIN and MAX". I thought about something like that. The problem is that current version= s of Emacs would have no idea what to do with a return value that's not an integer. I use a variety of Emacs versions on a number of machines. The indent function would have to check emacs-version and change the return value accordingly. That's always a mess. The advantage of my approach is that you can use the same indent function on any version of Emacs. Older versions just won't pay any attention to comment-indent-fixed. Otherwise, I'd go with returning a list. --=20 Chris Madsen cjm cjmweb.net -------------------- http://www.cjmweb.net -------------------- From monnier@IRO.UMontreal.CA Fri Jun 13 09:48:19 2008 X-Spam-Checker-Version: SpamAssassin 3.2.3-bugs.debian.org_2005_01_02 (2007-08-08) on rzlab.ucr.edu X-Spam-Level: X-Spam-Status: No, score=-6.7 required=4.0 tests=AWL,BAYES_00,HAS_BUG_NUMBER, MURPHY_DRUGS_REL8,VALID_BTS_CONTROL autolearn=ham version=3.2.3-bugs.debian.org_2005_01_02 Received: (at 385) by emacsbugs.donarmstrong.com; 13 Jun 2008 16:48:19 +0000 Received: from chene.dit.umontreal.ca (chene.dit.umontreal.ca [132.204.246.20]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m5DGmD64023624 for <385@emacsbugs.donarmstrong.com>; Fri, 13 Jun 2008 09:48:14 -0700 Received: from ceviche.home (vpn-132-204-232-131.acd.umontreal.ca [132.204.232.131]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id m5DGmBlW026536 for <385@emacsbugs.donarmstrong.com>; Fri, 13 Jun 2008 12:48:11 -0400 Received: by ceviche.home (Postfix, from userid 20848) id 6F462B4087; Fri, 13 Jun 2008 12:47:41 -0400 (EDT) From: Stefan Monnier To: 385@debbugs.gnu.org Subject: Re: bug#385: [PATCH] comment-indent doesn't respect Message-ID: References: <20080611171102.7261.qmail@byte.local> <21310.75.39.61.37.1213210741.squirrel@cjm.myvnc.com> Date: Fri, 13 Jun 2008 12:47:41 -0400 In-Reply-To: <21310.75.39.61.37.1213210741.squirrel@cjm.myvnc.com> (Christopher J. Madsen's message of "Wed, 11 Jun 2008 13:59:01 -0500 (CDT)") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 2 Rules triggered HAS_X_HELO=0, RV3038=0 severity 385 minor thanks > I thought about something like that. The problem is that current versions > of Emacs would have no idea what to do with a return value that's not an > integer. I use a variety of Emacs versions on a number of machines. The > indent function would have to check emacs-version and change the return > value accordingly. That's always a mess. I understand, but a variable like you suggests makes it impossible to have the special indentation you want together with the auto-alignment for other comment cases. I don't want a half solution, just to make the transition easier. You're trading off a minor short term gain again a long term loss. Stefan From rgm@gnu.org Mon Jun 30 17:57:34 2008 X-Spam-Checker-Version: SpamAssassin 3.2.3-bugs.debian.org_2005_01_02 (2007-08-08) on rzlab.ucr.edu X-Spam-Level: X-Spam-Status: No, score=-5.8 required=4.0 tests=AWL,BAYES_00,MISSING_SUBJECT, NOSUBJECT,RCVD_IN_DNSWL_MED autolearn=ham version=3.2.3-bugs.debian.org_2005_01_02 Received: (at control) by emacsbugs.donarmstrong.com; 1 Jul 2008 00:57:34 +0000 Received: from fencepost.gnu.org (fencepost.gnu.org [140.186.70.10]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m610vTvE032072 for ; Mon, 30 Jun 2008 17:57:30 -0700 Received: from rgm by fencepost.gnu.org with local (Exim 4.67) (envelope-from ) id 1KDUBF-0008DR-Sr; Mon, 30 Jun 2008 20:57:13 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <18537.33001.831109.48725@fencepost.gnu.org> Date: Mon, 30 Jun 2008 20:57:13 -0400 From: Glenn Morris To: control X-Attribution: GM X-Mailer: VM (www.wonderworks.com/vm), GNU Emacs (www.gnu.org/software/emacs) X-Hue: black X-Ran: v;?(b4pp]t{=,w_+9HM*^78%x_(pE^g\/WUl}d-,bzi|U4E=t1U`#j.5bY|[3o_,#";.'L close 239 tags 253 moreinfo severity 267 wishlist tags 284 unreproducible owner 341 Alan Mackenzie owner 343 Alan Mackenzie merge 364 365 tags 366 moreinfo severity 385 minor close 387 tags 390 unreproducible moreinfo tags 393 unreproducible moreinfo close 398 close 405 tags 443 moreinfo From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 28 23:59:30 2016 Received: (at 385) by debbugs.gnu.org; 29 Feb 2016 04:59:30 +0000 Received: from localhost ([127.0.0.1]:51348 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aaFve-0001fg-HS for submit@debbugs.gnu.org; Sun, 28 Feb 2016 23:59:30 -0500 Received: from hermes.netfonds.no ([80.91.224.195]:36306) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aaFvd-0001fY-4k for 385@debbugs.gnu.org; Sun, 28 Feb 2016 23:59:29 -0500 Received: from cpe-60-225-211-161.nsw.bigpond.net.au ([60.225.211.161] helo=mouse) by hermes.netfonds.no with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1aaFvF-0002KU-6c; Mon, 29 Feb 2016 05:59:05 +0100 From: Lars Ingebrigtsen To: "Christopher J. Madsen" Subject: Re: bug#385: [PATCH] comment-indent doesn't respect comment-indent-function References: <20080611171102.7261.qmail@byte.local> Date: Mon, 29 Feb 2016 15:59:01 +1100 In-Reply-To: <20080611171102.7261.qmail@byte.local> (Christopher J. Madsen's message of "11 Jun 2008 17:11:02 -0000") Message-ID: <87ziukw1re.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-MailScanner-ID: 1aaFvF-0002KU-6c X-Netfonds-MailScanner: Found to be clean X-Netfonds-MailScanner-From: larsi@gnus.org MailScanner-NULL-Check: 1457326746.65769@/2WYFFrRcExiy+4akQmHMQ X-Spam-Status: No X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 385 Cc: 385@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) "Christopher J. Madsen" writes: > Please describe exactly what actions triggered the bug > and the precise symptoms of the bug: > > It appears that comment-indent changed in 22.1. It gained some code > to attempt to align the comment with those on surrounding lines. > Unfortunately, this made it impossible to do certain things with > comment-indent-function. > > For example, I had a custom indent function that placed comments > immediately after a closing brace. However, in Emacs 22, I'd see this: > > while (1) { > while (2) { > > } # end 2 <-- this comment placed correctly > } # end 1 <-- this comment was aligned with the previous one > > instead of this: > > while (1) { > while (2) { > > } # end 2 > } # end 1 <-- here's where comment-indent-function placed it Is this still an issue in Emacs 25? -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 03 00:03:38 2016 Received: (at 385) by debbugs.gnu.org; 3 Mar 2016 05:03:38 +0000 Received: from localhost ([127.0.0.1]:58409 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1abLQH-00070u-PL for submit@debbugs.gnu.org; Thu, 03 Mar 2016 00:03:37 -0500 Received: from pb-smtp0.int.icgroup.com ([208.72.237.35]:59019 helo=sasl.smtp.pobox.com) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1abLQF-00070m-F1 for 385@debbugs.gnu.org; Thu, 03 Mar 2016 00:03:36 -0500 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-smtp0.pobox.com (Postfix) with ESMTP id C6CAA4A542 for <385@debbugs.gnu.org>; Thu, 3 Mar 2016 00:03:34 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=subject:to :references:cc:from:message-id:date:mime-version:in-reply-to :content-type:content-transfer-encoding; s=sasl; bh=7hAqrO1lVVmh rFgSfCJQbyDK6uY=; b=RpratNBIes8FBR5pEjq7dGH4v9TAbjqOfFCSmY/4+QSZ 3NgKrE9Zv46iWdDS7znPFmC9yAaQ/2Rxur4QM0Fyj5GJj6YG4AAH3vm8N8mML3rr KYdlbyJpmPpI15aZM/40mGSaD+rw2p58vHqTpbjJdVyeUB5wd36PYZ4QY3VuSK8= Received: from pb-smtp0.int.icgroup.com (unknown [127.0.0.1]) by pb-smtp0.pobox.com (Postfix) with ESMTP id BD6DD4A540 for <385@debbugs.gnu.org>; Thu, 3 Mar 2016 00:03:34 -0500 (EST) Received: from orthanc.cjmweb.net (unknown [70.121.55.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp0.pobox.com (Postfix) with ESMTPSA id 2EDB74A53D for <385@debbugs.gnu.org>; Thu, 3 Mar 2016 00:03:34 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=cjmweb.net; h=subject:to :references:cc:from:message-id:date:mime-version:in-reply-to :content-type:content-transfer-encoding; s=y16; bh=FKibKe68oUGJI lYgxkpT5X4zSPPbOfV4jcKH2em3gnM=; b=ZzVpHrGTWZUR8GJj/2rsDeZ+XR2QJ +TQ9MzSEIXSdmUpLnaCx2ffaR7az5hWmCUnf5Msl4yMXSnNgM/d+d86O2+G3H2AP QkHWfoToW2wFIkae1Dvy8Lbrb7zEh3H1aFx+c7FCVeDPLQ4bWJ58Kg/yd++X1zHk HCgYplsJXK2w/Q= Received: (qmail 29899 invoked from network); 3 Mar 2016 05:03:33 -0000 Received: from seven.lan.cjmweb.net (HELO ?192.168.0.12?) (192.168.0.12) by quad.lan.cjmweb.net with SMTP; 3 Mar 2016 05:03:33 -0000 Subject: Re: bug#385: [PATCH] comment-indent doesn't respect comment-indent-function To: Lars Ingebrigtsen References: <20080611171102.7261.qmail@byte.local> <87ziukw1re.fsf@gnus.org> From: "Christopher J. Madsen" X-Enigmail-Draft-Status: N1110 Message-ID: <56D7C5A9.7040007@cjmweb.net> Date: Wed, 2 Mar 2016 23:03:37 -0600 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <87ziukw1re.fsf@gnus.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Pobox-Relay-ID: 47EA3604-E0FD-11E5-9068-79226BB36C07-09214675!pb-smtp0.pobox.com X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 385 Cc: 385@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On 2/28/2016 10:59 PM, Lars Ingebrigtsen wrote: > Is this still an issue in Emacs 25? Yes. I built emacs-25.1.50.1 from 04289d1cd and nothing seems to have changed. The fundamental problem is that there's no way for a comment-indent-function to say "Put the comment here, and I really mean it." In some situations, comment-indent will always second-guess the comment-indent-function. In particular, it insists on aligning the comment with a comment on the line above even when that's not what I want. To reproduce this, load this Perl code: #! /usr/bin/perl if (1) { if (2) { if (3) { 4; } # end 3 } # end 2 } # end 1 And set comment-indent-function to this function: (defun cjm-perl-comment-indent () (if (and (bolp) (not (eolp))) 0 ;Existing comment at bol stays there. (save-excursion ;; endcol is the minimum column number the comment can start at ;; and still leave one space after text already on the line (skip-chars-backward " \t") (let ((endcol (1+ (current-column)))) (if (= 1 endcol) ;Don't leave just one space (setq endcol 0)) ;at beginning of line (beginning-of-line) (cond ;; CASE 1: A comment following a solitary closing brace should ;; have only one space. ((looking-at "[ \t]*}[ \t]*\\($\\|#\\)") endcol) ;; CASE 2: Align with comment on previous line ;; unless that's more than 9 chars before comment-column, ;; and leave at least one space (unless starting at bol). ((and (= 0 (forward-line -1)) (looking-at ".*[ \t]\\(#\\)") (progn (goto-char (match-beginning 1)) (> 10 (- comment-column (current-column))))) (max (current-column) endcol)) ;; CASE 3: indent at comment column except leave at least one ;; space (unless at bol) (t (max endcol comment-column)) ))))) Put point on the "end 2" line, hit M-; and the comment will be moved to align with the "end 3 " comment instead of staying where it was. Repeat on the "end 1" line and you'll have } # end 3 } # end 2 } # end 1 instead of the original code. (You don't actually need a comment-indent-function this complex to reproduce the issue, but this is the actual function I use.) Sorry for the delay in getting back to you. -- Chris Madsen cjm@cjmweb.net -------------------- http://www.cjmweb.net -------------------- From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 14 00:31:37 2017 Received: (at 385) by debbugs.gnu.org; 14 Jun 2017 04:31:37 +0000 Received: from localhost ([127.0.0.1]:46536 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKzxx-00087M-2j for submit@debbugs.gnu.org; Wed, 14 Jun 2017 00:31:37 -0400 Received: from mail-it0-f43.google.com ([209.85.214.43]:38781) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKzxv-000873-5Z; Wed, 14 Jun 2017 00:31:35 -0400 Received: by mail-it0-f43.google.com with SMTP id l6so40953502iti.1; Tue, 13 Jun 2017 21:31:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=Q99BLSFz68Huot7NQ3KMfLGnBPBgsJo1qwbSFZQfQAw=; b=QC2fT9YUZ675rCP8O59lhfb32aKHq7vkU1abqp0s3nowKNjUQQQ4cLd5xz8QpcJgZ8 9azetNPwGtVMTDFQYru1lzDUitJeZx70Wgq5uQ6N4Uavl7lOB0XT19kjaRG9kFYNMd25 IKllHS3wlQzXpJ4Zyt8xOw9NxHieXN0nDYHLIujUWY3rcuAV6MuiSLp6OX2mX+V94+9z 7e42qrMfRKSPq8yzEB2TvUdMYx2ZoNEukZVw/Eh1qN7cXIsKqu7VjDe3smVJ8+ppGGaI KPOQjkGnLo6dPYKTKiK++8dGLa0fqNFL0WTxpOLEo62xg5JPqeOwE2JQmz1xUBctNft2 OqlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=Q99BLSFz68Huot7NQ3KMfLGnBPBgsJo1qwbSFZQfQAw=; b=qB82slgDXrbZHHOTkwzJz8iJzJzdtzD2PXdR5SQYWdM2/OCIIMCNMNhqiFwOINzxWM TVp3jJM7tJW++KmpZ46ACvrquwO2Cu5cYmuTt525okiXxiqznmoUqikVZkxoYXWreFqa 0uU3lyAKTorFverlMMBzmVX8jVgGH7NO13WPIMaebBoXIxCT0M71Trh3Skgb1npEr6a9 SGoNHmz2Xt71nRKtU7UmiifE/3VRdtMWYpWUSy9MtDkn718UnAlR5PlLmSMQ87IiStMa vKfwdWw9vW0CPho28XCwfNpve11ydy7Z6eNslF3BCBKhJtgESOpBMvB4z226rhOtYqch Ntbg== X-Gm-Message-State: AKS2vOyZ7Uf09kpI7m2czdtOtX5UAx9dHjV4na+mDVjsAR8JDFth3uJp 2uw4WRbY4buFaHvB X-Received: by 10.36.11.68 with SMTP id 65mr4247282itd.80.1497414689357; Tue, 13 Jun 2017 21:31:29 -0700 (PDT) Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id o14sm82120itb.8.2017.06.13.21.31.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Jun 2017 21:31:27 -0700 (PDT) From: npostavs@users.sourceforge.net To: Stefan Monnier Subject: Re: bug#385: [PATCH] comment-indent doesn't respect comment-indent-function References: <20080611171102.7261.qmail@byte.local> Date: Wed, 14 Jun 2017 00:33:06 -0400 In-Reply-To: (Stefan Monnier's message of "Wed, 11 Jun 2008 14:04:57 -0400") Message-ID: <87efuntchp.fsf@users.sourceforge.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 385 Cc: 385@debbugs.gnu.org, "Christopher J. Madsen" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) --=-=-= Content-Type: text/plain tags 19740 + patch block 19740 by 385 quit Stefan Monnier writes: > If you need more control over the placement, rather than a variable > comment-indent-fixed, maybe we should just say that if > comment-indent-function returns a list of a single integer, it should be > taken as the indentation position and not second-guessed. Or it could > return a cons cell (MIN . MAX) to say "anywhere between MIN and MAX". Here's a patch. This seems to be a prerequisite to fix #19740. Regarding incompatibility of new comment-indent-functions for old Emacs, some simple advice on comment-choose-indent should easily do the trick. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=v1-0001-Allow-comment-indent-functions-to-specify-exact-i.patch Content-Description: patch >From cc9db0dbb5590ee909386078128e55c5ee24f319 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Wed, 14 Jun 2017 00:08:15 -0400 Subject: [PATCH v1] Allow comment-indent-functions to specify exact indentation (Bug#385) * lisp/newcomment.el (comment-choose-indent): Interpret a cons of two integers as indicating a range of acceptable indentation. (comment-indent): Don't apply `comment-inline-offset', `comment-choose-indent' already does that. (comment-indent-function): * doc/emacs/programs.texi (Options for Comments): Document new acceptable return values. * etc/NEWS: Announce it. --- doc/emacs/programs.texi | 9 ++++++--- etc/NEWS | 4 ++++ lisp/newcomment.el | 35 ++++++++++++++++++----------------- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi index 222d1c2a4d..27ac0eb640 100644 --- a/doc/emacs/programs.texi +++ b/doc/emacs/programs.texi @@ -1146,9 +1146,12 @@ Options for Comments various major modes. The function is called with no arguments, but with point at the beginning of the comment, or at the end of a line if a new comment is to be inserted. It should return the column in which the -comment ought to start. For example, in Lisp mode, the indent hook -function bases its decision on how many semicolons begin an existing -comment, and on the code in the preceding lines. +comment ought to start. For example, the default hook function bases +its decision on how many comment characters begin an existing comment. + +Emacs also tries to align comments on adjacent lines. To override +this, the function may return a cons of two (possibly equal) integers +to indicate an acceptable range of indentation. @node Documentation @section Documentation Lookup diff --git a/etc/NEWS b/etc/NEWS index 7e955ad26d..2467e81fe3 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -377,6 +377,10 @@ display of raw bytes from octal to hex. ** You can now provide explicit field numbers in format specifiers. For example, '(format "%2$s %1$s" "X" "Y")' produces "Y X". ++++ +** 'comment-indent-function' values may now return a cons to specify a +range of indentation. + * Editing Changes in Emacs 26.1 diff --git a/lisp/newcomment.el b/lisp/newcomment.el index 118549f421..8772b52376 100644 --- a/lisp/newcomment.el +++ b/lisp/newcomment.el @@ -142,9 +142,10 @@ (put 'comment-end 'safe-local-variable 'stringp) ;;;###autoload (defvar comment-indent-function 'comment-indent-default "Function to compute desired indentation for a comment. -This function is called with no args with point at the beginning of -the comment's starting delimiter and should return either the desired -column indentation or nil. +This function is called with no args with point at the beginning +of the comment's starting delimiter and should return either the +desired column indentation, a range of acceptable +indentation (MIN . MAX), or nil. If nil is returned, indentation is delegated to `indent-according-to-mode'.") ;;;###autoload @@ -649,13 +650,20 @@ (defun comment-choose-indent (&optional indent) - prefer INDENT (or `comment-column' if nil). Point is expected to be at the start of the comment." (unless indent (setq indent comment-column)) - ;; Avoid moving comments past the fill-column. - (let ((max (+ (current-column) - (- (or comment-fill-column fill-column) - (save-excursion (end-of-line) (current-column))))) - (other nil) - (min (save-excursion (skip-chars-backward " \t") - (if (bolp) 0 (+ comment-inline-offset (current-column)))))) + (let ((other nil) + min max) + (pcase indent + (`(,lo . ,hi) (setq min lo) (setq max hi) + (setq indent comment-column)) + (_ ;; Avoid moving comments past the fill-column. + (setq max (+ (current-column) + (- (or comment-fill-column fill-column) + (save-excursion (end-of-line) (current-column))))) + (setq min (save-excursion + (skip-chars-backward " \t") + ;; Leave at least `comment-inline-offset' space after + ;; other nonwhite text on the line. + (if (bolp) 0 (+ comment-inline-offset (current-column))))))) ;; Fix up the range. (if (< max min) (setq max min)) ;; Don't move past the fill column. @@ -750,13 +758,6 @@ (defun comment-indent (&optional continue) ;; If the comment is at the right of code, adjust the indentation. (unless (save-excursion (skip-chars-backward " \t") (bolp)) (setq indent (comment-choose-indent indent))) - ;; Update INDENT to leave at least one space - ;; after other nonwhite text on the line. - (save-excursion - (skip-chars-backward " \t") - (unless (bolp) - (setq indent (max indent - (+ (current-column) comment-inline-offset))))) ;; If that's different from comment's current position, change it. (unless (= (current-column) indent) (delete-region (point) (progn (skip-chars-backward " \t") (point))) -- 2.11.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 14 19:52:39 2017 Received: (at control) by debbugs.gnu.org; 14 Jun 2017 23:52:39 +0000 Received: from localhost ([127.0.0.1]:48108 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dLI5X-0000cb-9w for submit@debbugs.gnu.org; Wed, 14 Jun 2017 19:52:39 -0400 Received: from mail-it0-f47.google.com ([209.85.214.47]:38487) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dLI5V-0000cM-PX; Wed, 14 Jun 2017 19:52:38 -0400 Received: by mail-it0-f47.google.com with SMTP id l6so1757512iti.1; Wed, 14 Jun 2017 16:52:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=VPwFJjukWvjbbXcvOU+UsBVYzVHv+wUtxLXQdNkteO4=; b=A/nIifi+5+AeIeOVuWhloLymmdk4aQSPQ7wQU/+UhQxFQKH40vMXvyPTEVh+bi0PUu wW1FerAXcBreZeLRWCDq7/+mhHwBd5mTT0MT8vUx+W/OgEUBbNCBEXdBE/dXD3y3FKG/ KrEs0zENsaM+tTkmiP/8Ne0QKg/FYvYhDV8EBns0n6eDHN2NwTEtbrRzvUOPGVQ4AOfF YsvFq/j3ZFgG8ymAYmSIS7lBU0bV3np+JYyay2sowUBHMX067//aw5KrMvLz3h+kyshj 5v2BRIzirVbQm4kYxaXKV+vF/E5G35YtMh1bm83bMWfeaw4MrWc1wvQW9Vhgw9Uf964j n9Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=VPwFJjukWvjbbXcvOU+UsBVYzVHv+wUtxLXQdNkteO4=; b=nY7MH0czEWWkilrkbspZMR9qIiB/ILcOKaNt8HMwLrvxj5Bv06QodPANNd4E2kYmMv D/TsNmSrV6ocijDIgvM6m6DB9pnlCp+guvi+89lA3feq9hYQ68HYuZJ7b4PLbWINxSCH FwyAUVPrlcYKfMYyzDqIBd2kUlnkXl0duyDTxhWowuoAoK0FsbGpNyLXFaE50DfWEaua VKW1YXhJ+ftznlwi6vrq7I0f1sAfFs+Konz5jlq/8nAV7yVL91ykN11ARN+TCh9IMKPa DG3e+O4CnJKPQgvHroxCgAjz8Z0b0/mGfg7ytfmWhPAzZcjvF9lyCzeOwZz11xfw8f0E v7/Q== X-Gm-Message-State: AKS2vOyiyO22rFTYRF0d/mJdrJr9NHi7t78Z0zgYPXT0fVwOSUy9hSE9 SxLDcusjnxfYDqtr X-Received: by 10.36.57.67 with SMTP id l64mr2668520ita.56.1497484351751; Wed, 14 Jun 2017 16:52:31 -0700 (PDT) Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id m15sm716181iti.19.2017.06.14.16.52.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Jun 2017 16:52:31 -0700 (PDT) From: npostavs@users.sourceforge.net To: Drew Adams Subject: Re: bug#19740: 25.0.50; Bad comment indentation by `C-M-q' in `emacs-lisp-mode' References: <1580667c-4ee3-48b8-bbb7-cf6f41c36078@default> Date: Wed, 14 Jun 2017 19:54:08 -0400 In-Reply-To: <1580667c-4ee3-48b8-bbb7-cf6f41c36078@default> (Drew Adams's message of "Sat, 31 Jan 2015 20:19:34 -0800 (PST)") Message-ID: <878tkut9b3.fsf@users.sourceforge.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: control Cc: 19740@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --=-=-= Content-Type: text/plain # I accidentally tagged this bug instead of #385 before tags 385 + patch quit Drew Adams writes: > This is a regression introduced after Emacs 20 (perhaps after 21). > > Emacs should not indent the first `;;' comment line here by a space. > That does no good and interferes with alignment of a multi-line > comments and multiple separate comments that are on the same level. > > (let* ( ;; If FOOBAR then blah the blahdy blah and other blahs if blah, > ;; blah, or blah. Unless, that is, blah, blah, or blah. > (the-tatas (bar-bar-toto-babar foo1 foo2 foo3)) > ...) > > In Emacs 20, this is the result - no extra space inserted. The two > comment lines, which are logically at the same level, and in this case > are part of a single multi-line comment, are aligned vertically. > > (let* (;; If FOOBAR then blah the blahdy blah and other blahs if blah, > ;; blah, or blah. Unless, that is, blah, blah, or blah. > (the-tatas (bar-bar-toto-babar foo1 foo2 foo3)) > ...) This was introduced in [1: bdbe3a8995]. I think in most contexts, it makes sense to put the space, but it definitely looks wrong in a lisp let. Here's patch to override the alignment for comments following an open in paren in lisp modes. It requires the patch I posted for #385. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=v1-0001-Don-t-put-whitespace-between-open-paren-and-comme.patch Content-Description: patch >From f314ec8ee3b99bb6adc5ee789ef07b8b834b5c57 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Wed, 14 Jun 2017 00:13:06 -0400 Subject: [PATCH v1] Don't put whitespace between open paren and comment in Lisp modes (Bug#19740) * lisp/emacs-lisp/lisp-mode.el (lisp-comment-indent): If current line's code ends in open paren, set comment indentation exactly to column following it. (lisp-mode-variables): Set `comment-indent-function' to `lisp-comment-indent'. --- lisp/emacs-lisp/lisp-mode.el | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 59db00d5f9..985b7513a3 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -602,6 +602,7 @@ (defun lisp-mode-variables (&optional lisp-syntax keywords-case-insensitive ;;(set (make-local-variable 'adaptive-fill-mode) nil) (setq-local indent-line-function 'lisp-indent-line) (setq-local indent-region-function 'lisp-indent-region) + (setq-local comment-indent-function #'lisp-comment-indent) (setq-local outline-regexp ";;;\\(;* [^ \t\n]\\|###autoload\\)\\|(") (setq-local outline-level 'lisp-outline-level) (setq-local add-log-current-defun-function #'lisp-current-defun-name) @@ -735,9 +736,15 @@ (defalias 'common-lisp-mode 'lisp-mode) (autoload 'lisp-eval-defun "inf-lisp" nil t) -;; May still be used by some external Lisp-mode variant. -(define-obsolete-function-alias 'lisp-comment-indent - 'comment-indent-default "22.1") +(defun lisp-comment-indent () + "Like `comment-indent-default', but don't put space after open paren." + (let ((pt (point))) + (skip-syntax-backward " ") + (if (eq (preceding-char) ?\() + (cons (current-column) (current-column)) + (goto-char pt) + (comment-indent-default)))) + (define-obsolete-function-alias 'lisp-mode-auto-fill 'do-auto-fill "23.1") (defcustom lisp-indent-offset nil -- 2.11.1 --=-=-= Content-Type: text/plain [1: bdbe3a8995]: 2000-09-29 19:11:42 +0000 (comment-indent-function): Use 0 for ;;; and %%%. (comment-indent): Make sure there's a space between code and comment[...] http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=bdbe3a8995c5f1dae126acd4be4872f6af687cd1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 05 22:57:05 2017 Received: (at 385) by debbugs.gnu.org; 6 Jul 2017 02:57:05 +0000 Received: from localhost ([127.0.0.1]:53995 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dSwyW-0000Vt-TE for submit@debbugs.gnu.org; Wed, 05 Jul 2017 22:57:05 -0400 Received: from mail-it0-f65.google.com ([209.85.214.65]:36011) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dSwyU-0000VH-Du; Wed, 05 Jul 2017 22:57:02 -0400 Received: by mail-it0-f65.google.com with SMTP id k3so16238629ita.3; Wed, 05 Jul 2017 19:57:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=sBDBIAqzERGnbk1nE7i+nCrkchH2aOPSoHxjRKakhpY=; b=OIyKfcoIjloIXYIbBgLpGgS7BxEF4yDDDeahrnvdoGks2ojeR14WX+PIkxvCthMZ/v xOfURXbwp4nzhXIZ1IXluxxW1km+yAfSbnh6ExGA+2gJhCOY41zF7qP44c6RXfPicozv z2NUJ2MrHJIgJ23MccXUmkQHPSxonGD7fE4z00thEuKXSLll+cFpQXZSFlISEQ/OypBl jOGAsSSMJYtkTguukJkkCxModOElZ4iA6rjWSKm0TM5qzlUmJNiFlYBipJYeNaFxe2fK dCTMAXmai6bMD9eDcyB7VIs7NBXo8uBGZHYR4haRuw3DLMsZsuCFvpIsr/YOqwTw6HFR 5wAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=sBDBIAqzERGnbk1nE7i+nCrkchH2aOPSoHxjRKakhpY=; b=YsraatNPA2b5intg3usGmoX+zxPSMiGLwwgwfkZwSIxbHXlRjdnSEpg93EEs0EjmLy 3zth3xklLuCOAYR9IPvjI5mAK3CcmdIuCCySG38AO2nr/9anky+Pm8UjFhBr9b1aF9kI oUulHrKrUnSrR67xXighTWHsJyohWpdRowNj625YA04pO4v3H2QfHacM3AYaJeG6xg21 9K1c705XXQRQzDN5mSOOj2u+Y34W3vAsm30IzNXG0UKqdSVkhBUefjLRb5APVsTcNRGs KOERitzUloSGf7maCAvvPfKwj7KJMDEkZEsHZONSWtkYnPcGuYZpAkVaFpo9yd+V0Dqn jGWQ== X-Gm-Message-State: AKS2vOxN37EtzKrHBddFl3iViUlNDuGHURk4+8vnwBdKmDk4QrYGdHG3 HFdO9enYjCis2dIk X-Received: by 10.107.198.1 with SMTP id w1mr52539582iof.101.1499309816343; Wed, 05 Jul 2017 19:56:56 -0700 (PDT) Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id b17sm13524350itd.0.2017.07.05.19.56.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Jul 2017 19:56:55 -0700 (PDT) From: npostavs@users.sourceforge.net To: Stefan Monnier Subject: Re: bug#385: [PATCH] comment-indent doesn't respect comment-indent-function References: <20080611171102.7261.qmail@byte.local> <87efuntchp.fsf@users.sourceforge.net> Date: Wed, 05 Jul 2017 22:58:31 -0400 In-Reply-To: <87efuntchp.fsf@users.sourceforge.net> (npostavs@users.sourceforge.net's message of "Wed, 14 Jun 2017 00:33:06 -0400") Message-ID: <87o9sygtk8.fsf@users.sourceforge.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: 385 Cc: "Christopher J. Madsen" , 385@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.7 (/) tags 385 fixed close 385 26.1 quit npostavs@users.sourceforge.net writes: > Stefan Monnier writes: > >> If you need more control over the placement, rather than a variable >> comment-indent-fixed, maybe we should just say that if >> comment-indent-function returns a list of a single integer, it should be >> taken as the indentation position and not second-guessed. Or it could >> return a cons cell (MIN . MAX) to say "anywhere between MIN and MAX". > > Here's a patch. Pushed to master. [1: e832febfb4]: 2017-07-05 22:52:35 -0400 Allow comment-indent-functions to specify exact indentation (Bug#385) http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=e832febfb4089418e0152c805e24dee977a7590d From unknown Sat Jun 21 10:26:15 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 03 Aug 2017 11:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator