From debbugs-submit-bounces@debbugs.gnu.org Sat Jan 31 23:19:53 2015 Received: (at submit) by debbugs.gnu.org; 1 Feb 2015 04:19:53 +0000 Received: from localhost ([127.0.0.1]:59287 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YHm0m-0004bl-Rt for submit@debbugs.gnu.org; Sat, 31 Jan 2015 23:19:53 -0500 Received: from eggs.gnu.org ([208.118.235.92]:43966) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YHm0j-0004bX-F5 for submit@debbugs.gnu.org; Sat, 31 Jan 2015 23:19:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YHm0d-0006z6-CV for submit@debbugs.gnu.org; Sat, 31 Jan 2015 23:19:44 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:49700) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YHm0d-0006z2-9k for submit@debbugs.gnu.org; Sat, 31 Jan 2015 23:19:43 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45688) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YHm0c-0006sE-9b for bug-gnu-emacs@gnu.org; Sat, 31 Jan 2015 23:19:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YHm0X-0006xf-6V for bug-gnu-emacs@gnu.org; Sat, 31 Jan 2015 23:19:42 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:40828) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YHm0X-0006xa-0H for bug-gnu-emacs@gnu.org; Sat, 31 Jan 2015 23:19:37 -0500 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 t114JZIb002089 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 1 Feb 2015 04:19:36 GMT 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 t114JYxH018906 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Sun, 1 Feb 2015 04:19:35 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id t114JY1G010690 for ; Sun, 1 Feb 2015 04:19:34 GMT MIME-Version: 1.0 Message-ID: <1580667c-4ee3-48b8-bbb7-cf6f41c36078@default> Date: Sat, 31 Jan 2015 20:19:34 -0800 (PST) From: Drew Adams To: bug-gnu-emacs@gnu.org Subject: 25.0.50; Bad comment indentation by `C-M-q' in `emacs-lisp-mode' X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.8.2 (807160) [OL 12.0.6691.5000 (x86)] Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable 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-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 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: -4.0 (----) 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)) ...) In GNU Emacs 25.0.50.1 (i686-pc-mingw32) of 2014-10-20 on LEG570 Bzr revision: 118168 rgm@gnu.org-20141020195941-icp42t8ttcnud09g Windowing system distributor `Microsoft Corp.', version 6.1.7601 Configured using: `configure --enable-checking=3Dyes,glyphs CPPFLAGS=3D-DGLYPH_DEBUG=3D1' From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 30 13:07:46 2016 Received: (at control) by debbugs.gnu.org; 30 Apr 2016 17:07:46 +0000 Received: from localhost ([127.0.0.1]:58181 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1awYMs-0001GW-0V for submit@debbugs.gnu.org; Sat, 30 Apr 2016 13:07:46 -0400 Received: from hermes.netfonds.no ([80.91.224.195]:58711) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1awYMq-0001GP-QU for control@debbugs.gnu.org; Sat, 30 Apr 2016 13:07:45 -0400 Received: from cm-84.215.1.64.getinternet.no ([84.215.1.64] helo=mouse) by hermes.netfonds.no with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1awYMo-0004gg-Kw for control@debbugs.gnu.org; Sat, 30 Apr 2016 19:07:44 +0200 Date: Sat, 30 Apr 2016 19:07:42 +0200 Message-Id: <877fffgh41.fsf@gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #19740 X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control 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 (/) forcemerge 19740 6141 From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 14 00:31:37 2017 Received: (at control) by debbugs.gnu.org; 14 Jun 2017 04:31:37 +0000 Received: from localhost ([127.0.0.1]:46534 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKzxw-00087K-ON 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: control 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:41 2017 Received: (at 19740) by debbugs.gnu.org; 14 Jun 2017 23:52:42 +0000 Received: from localhost ([127.0.0.1]:48110 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dLI5Z-0000ck-KV for submit@debbugs.gnu.org; Wed, 14 Jun 2017 19:52:41 -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: 19740 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:58:35 2017 Received: (at 19740) by debbugs.gnu.org; 6 Jul 2017 02:58:35 +0000 Received: from localhost ([127.0.0.1]:54004 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dSwzz-0000YS-Ex for submit@debbugs.gnu.org; Wed, 05 Jul 2017 22:58:35 -0400 Received: from mail-it0-f51.google.com ([209.85.214.51]:38708) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dSwzx-0000YB-PR; Wed, 05 Jul 2017 22:58:34 -0400 Received: by mail-it0-f51.google.com with SMTP id k192so104546029ith.1; Wed, 05 Jul 2017 19:58:33 -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=aY+As/l+JK2oxKMMvb/JIRJtFmT9cYwNskndwAag8z0=; b=Y0pGcPEyBvM6/4mu4LF2eUftBstuF5n3/JvCETNPvBwk7rCQFNJY10Xv7GbjRmXQoa G1M1UuwW3PDSlR76yh5uI/D6sZThomfkdHg+UWps9o+baLDMxqOTgqYjM/Nin9I6fRgE X0QonXOMrpoSQAawzAuTockWWUfgnh36Jvymy+wBJ4AVgA3hXWTx8sQXsvQUsVvaQRul y8vz3VOAHYWIkas/RkGJXc2Lc5a40GVR+yD3WoHrAx1Xo4tH2WVDh9h12+9lQkxXE4iI AtnHHOvFYGVj6fbfSelHoR5uwbufMRdzk5Husa8NkwzauKMZ+KYrEoWhDS6B5tbevypO 2YSQ== 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=aY+As/l+JK2oxKMMvb/JIRJtFmT9cYwNskndwAag8z0=; b=iYyAZz8kFpvEjcg7MDw/XWkdLCGCBu/2gbnj/gMiPEQREpqI1c2QewDngX+GKNX3RI MUcSSanlekfWwCEkmExUHlvRB7IL6EcPhw4naVmm72MFUvkPsxPSRACWlxa/p2pRrEpW kOAG2GPuDMPfUn9ESE0G8nxkVPyxEKyPNXTYTSorleR3BO+2NnsmfdmB9QudzNbz9sS9 mcshB6f0t8D3BlP+k33NxAD0jm7fXGBc4UVgdUzSqR9j9xpBONEeeWJDQblN2UQ4/klY lngR45yrqcMVD/fif5+9Mr3Psvl5GbwLk34rK8ZjeZ3zkiyMd7X4MZlQ/UfgW+FwWrg+ xgfg== X-Gm-Message-State: AKS2vOzcFkL0EeYKkrJwH9KVHqBCns+iufGg2TqEpVwbA4S2mYSI9UhF 2hw58IlgVSPPiKkb X-Received: by 10.107.201.66 with SMTP id z63mr46758883iof.220.1499309908188; Wed, 05 Jul 2017 19:58:28 -0700 (PDT) Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id s135sm13963399ita.2.2017.07.05.19.58.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Jul 2017 19:58:27 -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> <878tkut9b3.fsf@users.sourceforge.net> Date: Wed, 05 Jul 2017 23:00:03 -0400 In-Reply-To: <878tkut9b3.fsf@users.sourceforge.net> (npostavs@users.sourceforge.net's message of "Wed, 14 Jun 2017 19:54:08 -0400") Message-ID: <87lgo2gtho.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: 19740 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.7 (/) tags 19740 fixed close 19740 26.1 quit npostavs@users.sourceforge.net 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. Pushed: [2: 7a0170de20] [2: 7a0170de20]: 2017-07-05 22:52:36 -0400 Don't put whitespace between open paren and comment in Lisp modes (Bug#19740) http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=7a0170de20fe1225d3eeac099d1e61a0c0410bf3 From unknown Sat Aug 16 20:00:41 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:04 +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