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: Mon, 22 May 2017 00:24:20 -0600 Message-ID: <87d1b1e7e3.fsf@bapiya> References: <87o9vdj0s5.fsf@tromey.com> <87mvavw0h5.fsf@pokyo> <87r2zidut2.fsf@bapiya> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1495434284 3952 195.159.176.226 (22 May 2017 06:24:44 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 22 May 2017 06:24:44 +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 Mon May 22 08:24:40 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 1dCglh-0000sr-Hk for ged-emacs-devel@m.gmane.org; Mon, 22 May 2017 08:24:37 +0200 Original-Received: from localhost ([::1]:40715 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dCglm-00057z-VJ for ged-emacs-devel@m.gmane.org; Mon, 22 May 2017 02:24:42 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34469) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dCgle-00057j-SD for emacs-devel@gnu.org; Mon, 22 May 2017 02:24:35 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dCglb-0003vr-MD for emacs-devel@gnu.org; Mon, 22 May 2017 02:24:34 -0400 Original-Received: from gproxy1-pub.mail.unifiedlayer.com ([69.89.25.95]:44957 helo=outbound-ss-1812.hostmonster.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dCglb-0003v8-93 for emacs-devel@gnu.org; Mon, 22 May 2017 02:24:31 -0400 Original-Received: from CMOut01 (cmgw2 [10.0.90.82]) by gproxy1.mail.unifiedlayer.com (Postfix) with ESMTP id 24B57175DC3 for ; Mon, 22 May 2017 00:24:27 -0600 (MDT) Original-Received: from box522.bluehost.com ([74.220.219.122]) by CMOut01 with id PJQM1v00C2f2jeq01JQQyq; Mon, 22 May 2017 00:24:27 -0600 X-Authority-Analysis: v=2.2 cv=K+5SJ2eI c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=tJ8p9aeEuA8A:10 a=NktFDEUEzs4_IF-oTuwA: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=r+8/WWbGUmRn6tgW6484E7P7AH6uzUyXB5iCm/eh95w=; b=F3s3z8JF2E1pltPltkV7IkNd4x U58+o8g1xRTOrKLlCPUkJAtwyXnebZ3+oDBVOt2NTGt74nM+R9BR+bM2YN706qgpdrIZx9oX5ISzC uyEGYwCK9HP1eeQBee/L25Zwv; Original-Received: from 174-29-43-217.hlrn.qwest.net ([174.29.43.217]:59764 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1dCglR-0003Ug-9D; Mon, 22 May 2017 00:24:21 -0600 In-Reply-To: (Stefan Monnier's message of "Sun, 21 May 2017 17:03:57 -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: 174.29.43.217 X-Exim-ID: 1dCglR-0003Ug-9D X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 174-29-43-217.hlrn.qwest.net (bapiya) [174.29.43.217]:59764 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: 69.89.25.95 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:215083 Archived-At: Stefan> Please check also comment-start, since you don't want to check Stefan> (syntax-ppss) if there's no comment-start defined. Well, technically, Stefan> it shouldn't make any difference, but it's the way it's been defined so Stefan> far, so it makes sense to preserve it. Stefan> The patch looks good, but please also remove the Stefan> comment-auto-fill-only-comments handling from newcomment.el Like the appended? I wasn't sure if I did the newcomment.el part correctly. Also, any comment on the prog-mode suggestion? thanks, Tom diff --git a/lisp/newcomment.el b/lisp/newcomment.el index 4b261c3..44dd7e1 100644 --- a/lisp/newcomment.el +++ b/lisp/newcomment.el @@ -1381,10 +1381,9 @@ comment-indent-new-line (interactive) (comment-normalize-vars t) (let (compos comin) - ;; If we are not inside a comment and we only auto-fill comments, - ;; don't do anything (unless no comment syntax is defined). + ;; If we are not inside a comment don't do anything (unless no + ;; comment syntax is defined). (unless (and comment-start - comment-auto-fill-only-comments (not (called-interactively-p 'interactive)) (not (save-excursion (prog1 (setq compos (comment-beginning)) diff --git a/lisp/simple.el b/lisp/simple.el index ea3a495..33a4082 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -7191,6 +7191,13 @@ default-indent-new-line ;; If we're not inside a comment, just try to indent. (t (indent-according-to-mode)))))) +(defun internal-auto-fill () + "The function called by `self-insert-command' to perform auto-filling." + (when (or (not comment-start) + (not comment-auto-fill-only-comments) + (nth 4 (syntax-ppss))) + (do-auto-fill))) + (defvar normal-auto-fill-function 'do-auto-fill "The function to use for `auto-fill-function' if Auto Fill mode is turned on. Some major modes set this.") diff --git a/src/cmds.c b/src/cmds.c index 51652d5..6f2db86 100644 --- a/src/cmds.c +++ b/src/cmds.c @@ -268,9 +268,10 @@ Whichever character you type to run this command is inserted. The numeric prefix argument N says how many times to repeat the insertion. Before insertion, `expand-abbrev' is executed if the inserted character does not have word syntax and the previous character in the buffer does. -After insertion, the value of `auto-fill-function' is called if the -`auto-fill-chars' table has a non-nil value for the inserted character. -At the end, it runs `post-self-insert-hook'. */) +After insertion, `internal-auto-fill' is called if +`auto-fill-function' is non-nil and if the `auto-fill-chars' table has +a non-nil value for the inserted character. At the end, it runs +`post-self-insert-hook'. */) (Lisp_Object n) { CHECK_NUMBER (n); @@ -475,7 +476,7 @@ internal_self_insert (int c, EMACS_INT n) that. Must have the newline in place already so filling and justification, if any, know where the end is going to be. */ SET_PT_BOTH (PT - 1, PT_BYTE - 1); - auto_fill_result = call0 (BVAR (current_buffer, auto_fill_function)); + auto_fill_result = call0 (Qinternal_auto_fill); /* Test PT < ZV in case the auto-fill-function is strange. */ if (c == '\n' && PT < ZV) SET_PT_BOTH (PT + 1, PT_BYTE + 1); @@ -494,6 +495,8 @@ internal_self_insert (int c, EMACS_INT n) void syms_of_cmds (void) { + DEFSYM (Qinternal_auto_fill, "internal-auto-fill"); + DEFSYM (Qundo_auto_amalgamate, "undo-auto-amalgamate"); DEFSYM (Qundo_auto__this_command_amalgamating, "undo-auto--this-command-amalgamating");