From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tom Tromey Newsgroups: gmane.emacs.devel Subject: Re: Smie-auto-fill =?utf-8?Q?doesn=E2=80=99t?= respect comment-auto-fill-only-comments Date: Sun, 30 Apr 2017 10:52:26 -0600 Message-ID: <87o9vdj0s5.fsf@tromey.com> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1493571193 31024 195.159.176.226 (30 Apr 2017 16:53:13 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 30 Apr 2017 16:53:13 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) Cc: Emacs Developers To: Nikolai Weibull Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Apr 30 18:53:09 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d4s5s-0007yV-Uo for ged-emacs-devel@m.gmane.org; Sun, 30 Apr 2017 18:53:09 +0200 Original-Received: from localhost ([::1]:45300 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d4s5y-00016M-S2 for ged-emacs-devel@m.gmane.org; Sun, 30 Apr 2017 12:53:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:32929) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d4s5s-00016G-M6 for emacs-devel@gnu.org; Sun, 30 Apr 2017 12:53:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d4s5p-0005Xj-HD for emacs-devel@gnu.org; Sun, 30 Apr 2017 12:53:08 -0400 Original-Received: from gproxy8-pub.mail.unifiedlayer.com ([67.222.33.93]:56619 helo=gproxy8.mail.unifiedlayer.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d4s5p-0005Wv-3r for emacs-devel@gnu.org; Sun, 30 Apr 2017 12:53:05 -0400 Original-Received: from cmgw3 (unknown [10.0.90.84]) by gproxy8.mail.unifiedlayer.com (Postfix) with ESMTP id CA9341AB130 for ; Sun, 30 Apr 2017 10:52:32 -0600 (MDT) Original-Received: from box522.bluehost.com ([74.220.219.122]) by cmgw3 with id EgsT1v00K2f2jeq01gsWan; Sun, 30 Apr 2017 10:52:32 -0600 X-Authority-Analysis: v=2.2 cv=VKStp5HX c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=IkcTkHD0fZMA:10 a=AzvcPWV-tVgA:10 a=2m_4gFGpwK84zwCbz_MA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID: In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=+8bas6f1nQGrukSkJxukIH99QliDzohqi+PCUzxXgqQ=; b=SmAsxmncj1oOD2NAn2nEfffDWW sr/EB+EZVD5K/iU7Ao9dr+zDlFeRuoIPEjPuLAWrKCTLpjteBJVCRc5YnoiYdsW0ZqKdBU7d5CQjr dSi+aGeCYj7WZ+jsPM1i53Nx7; Original-Received: from c-67-176-62-53.hsd1.co.comcast.net ([67.176.62.53]:60310 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1d4s5D-000436-DO; Sun, 30 Apr 2017 10:52:27 -0600 X-Attribution: Tom In-Reply-To: (Nikolai Weibull's message of "Thu, 6 Apr 2017 14:04:45 +0200") X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box522.bluehost.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 67.176.62.53 X-Exim-ID: 1d4s5D-000436-DO X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: c-67-176-62-53.hsd1.co.comcast.net (bapiya) [67.176.62.53]:60310 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 67.222.33.93 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:214444 Archived-At: >>>>> "Nikolai" =3D=3D Nikolai Weibull writes: Nikolai> Smie-auto-fill doesn=E2=80=99t respect comment-auto-fill-only-comm= ents. I=E2=80=99m Nikolai> not quite sure whether it actually should, but the issue I=E2=80= =99m having is Nikolai> that auto-fill is being applied in sh-mode, even though I have Nikolai> comment-auto-fill-only-comments. I recently noticed this for other programming modes, like js-mode. I wasn't sure if this is some recent(-ish) change or if I just never happened to notice it before somehow. Anyway, I'm trying out the appended, which I'd like to push in. This won't fix the SMIE issue though. That would require a similar fix in smie-auto-fill. Or maybe this should just be done directly in do-auto-fill itself? Tom diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el index 8f66f1c..b5bb637 100644 --- a/lisp/progmodes/prog-mode.el +++ b/lisp/progmodes/prog-mode.el @@ -129,6 +129,11 @@ prog-widen (narrow-to-region (car chunk) (or (cdr chunk) (point-max))) (widen)))) =20 +(defun prog-mode-do-auto-fill () + "Like `do-auto-fill' but respect `comment-auto-fill-only-comments'." + (when (or (not comment-auto-fill-only-comments) + (nth 4 (syntax-ppss))) + (do-auto-fill))) =20 (defvar-local prettify-symbols-alist nil "Alist of symbol prettifications. @@ -293,6 +298,7 @@ prog-mode "Major mode for editing programming language source code." (setq-local require-final-newline mode-require-final-newline) (setq-local parse-sexp-ignore-comments t) + (setq-local normal-auto-fill-function #'prog-mode-do-auto-fill) ;; Any programming language is always written left to right. (setq bidi-paragraph-direction 'left-to-right)) =20