From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Christopher J. Madsen" Newsgroups: gmane.emacs.bugs Subject: bug#385: [PATCH] comment-indent doesn't respect comment-indent-function Date: Wed, 2 Mar 2016 23:03:37 -0600 Message-ID: <56D7C5A9.7040007@cjmweb.net> References: <20080611171102.7261.qmail@byte.local> <87ziukw1re.fsf@gnus.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1456981464 15990 80.91.229.3 (3 Mar 2016 05:04:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 3 Mar 2016 05:04:24 +0000 (UTC) Cc: 385@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Mar 03 06:04:13 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1abLQr-0006B1-Em for geb-bug-gnu-emacs@m.gmane.org; Thu, 03 Mar 2016 06:04:13 +0100 Original-Received: from localhost ([::1]:60557 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1abLQn-0001Ue-LK for geb-bug-gnu-emacs@m.gmane.org; Thu, 03 Mar 2016 00:04:09 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48504) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1abLQk-0001TH-5C for bug-gnu-emacs@gnu.org; Thu, 03 Mar 2016 00:04:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1abLQg-0005k7-Tn for bug-gnu-emacs@gnu.org; Thu, 03 Mar 2016 00:04:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:33049) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1abLQg-0005k2-Kl for bug-gnu-emacs@gnu.org; Thu, 03 Mar 2016 00:04:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1abLQg-00071d-8f for bug-gnu-emacs@gnu.org; Thu, 03 Mar 2016 00:04:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: "Christopher J. Madsen" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 03 Mar 2016 05:04:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 385 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 385-submit@debbugs.gnu.org id=B385.145698141826968 (code B ref 385); Thu, 03 Mar 2016 05:04:02 +0000 Original-Received: (at 385) by debbugs.gnu.org; 3 Mar 2016 05:03:38 +0000 Original-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 Original-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 Original-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= Original-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) Original-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= Original-Received: (qmail 29899 invoked from network); 3 Mar 2016 05:03:33 -0000 Original-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 X-Enigmail-Draft-Status: N1110 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 In-Reply-To: <87ziukw1re.fsf@gnus.org> X-Pobox-Relay-ID: 47EA3604-E0FD-11E5-9068-79226BB36C07-09214675!pb-smtp0.pobox.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:114320 Archived-At: 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 --------------------