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: Tue, 02 May 2017 12:57:26 -0600 Message-ID: <87mvavw0h5.fsf@pokyo> References: <87o9vdj0s5.fsf@tromey.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1493751522 7254 195.159.176.226 (2 May 2017 18:58:42 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 2 May 2017 18:58:42 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue May 02 20:58:36 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 1d5d0N-0001km-9e for ged-emacs-devel@m.gmane.org; Tue, 02 May 2017 20:58:35 +0200 Original-Received: from localhost ([::1]:60622 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5d0T-0000xe-16 for ged-emacs-devel@m.gmane.org; Tue, 02 May 2017 14:58:41 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40708) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d5d0M-0000xX-4h for emacs-devel@gnu.org; Tue, 02 May 2017 14:58:35 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d5d0J-0005Uk-2M for emacs-devel@gnu.org; Tue, 02 May 2017 14:58:34 -0400 Original-Received: from gproxy8-pub.mail.unifiedlayer.com ([67.222.33.93]:36978 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 1d5d0I-0005F5-Lz for emacs-devel@gnu.org; Tue, 02 May 2017 14:58:31 -0400 Original-Received: from cmgw2 (unknown [10.0.90.83]) by gproxy8.mail.unifiedlayer.com (Postfix) with ESMTP id 982591AB12E for ; Tue, 2 May 2017 12:57:33 -0600 (MDT) Original-Received: from box522.bluehost.com ([74.220.219.122]) by cmgw2 with id FWxT1v01D2f2jeq01WxWBY; Tue, 02 May 2017 12:57:33 -0600 X-Authority-Analysis: v=2.2 cv=Ibz3YSia c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=tJ8p9aeEuA8A:10 a=-1FhLIK6oEkzoA5xKysA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: 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=Su9zD+3OEHL6Lm9uA7frRBNx4Noic2XfR9BvHWilM5k=; b=vIP611Sz55k18dXBP6sGc2Vk13 AjH0NKCTV3O+hsFJJ0bcowDZpQwtt/JSzJoNKEfeHXnK9EHXANjBxh1AJG8Ydsmnx38HCPMxklZyJ GYWSv6FstzH4ZKtw2RfyMPENN; Original-Received: from 75-166-63-71.hlrn.qwest.net ([75.166.63.71]:52082 helo=pokyo) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1d5czH-0005at-MO; Tue, 02 May 2017 12:57:27 -0600 X-Attribution: Tom In-Reply-To: (Stefan Monnier's message of "Sun, 30 Apr 2017 13:52:44 -0400") 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: 75.166.63.71 X-Exim-ID: 1d5czH-0005at-MO X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-63-71.hlrn.qwest.net (pokyo) [75.166.63.71]:52082 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:214524 Archived-At: >>>>> "Stefan" == Stefan Monnier writes: >>> This won't fix the SMIE issue though. That would require a similar fix >>> in smie-auto-fill. >> We should try and find a solution which doesn't require changing every >> normal-auto-fill-function. Stefan> I think the patch below "does the trick" but it's rather ugly. I think the idea of changing auto-fill-mode to handle this case is better than what I was doing. However, I also agree that the advice is ugly... Stefan> + (setq auto-fill-function normal-auto-fill-function) Stefan> + (add-function :around normal-auto-fill-function Stefan> + (lambda (orig-fun &rest args) Stefan> + (if (and comment-start Stefan> + comment-auto-fill-only-comments Stefan> + (not (nth 4 (syntax-ppss)))) Stefan> + ;; Comments exist and we only want to Stefan> + ;; auto-fill them but we're not in one! Stefan> + nil Stefan> + (apply orig-fun args)))))))) Could this just setq auto-fill-function to a function that wraps (the captured value of) normal-auto-fill-function? That would avoid using advice. Tom