emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 9b463fa: Respect comment-auto-fill-only-comments


From: Tom Tromey
Subject: [Emacs-diffs] master 9b463fa: Respect comment-auto-fill-only-comments
Date: Sat, 5 Aug 2017 20:37:40 -0400 (EDT)

branch: master
commit 9b463fa8648b7baed95a44f4317cb7402fd8bf1c
Author: Tom Tromey <address@hidden>
Commit: Tom Tromey <address@hidden>

    Respect comment-auto-fill-only-comments
    
    Respect comment-auto-fill-only-comments when auto-filling and a
    comment syntax is defined.
    
    * lisp/newcomment.el (comment-indent-new-line): Do not check
    comment-auto-fill-only-comments.
    * lisp/simple.el (internal-auto-fill): New defun.
    * src/cmds.c (internal_self_insert): Call Qinternal_auto_fill, not
    auto_fill_function.
    (syms_of_cmds): Define Qinternal_auto_fill.
---
 lisp/newcomment.el |  5 ++---
 lisp/simple.el     |  7 +++++++
 src/cmds.c         | 11 +++++++----
 3 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/lisp/newcomment.el b/lisp/newcomment.el
index 8772b523..e3ee4df 100644
--- a/lisp/newcomment.el
+++ b/lisp/newcomment.el
@@ -1382,10 +1382,9 @@ unless optional argument SOFT is non-nil."
   (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 e3d86ab..027ce39 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -7219,6 +7219,13 @@ unless optional argument SOFT is non-nil."
        ;; 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");



reply via email to

[Prev in Thread] Current Thread [Next in Thread]