diff options
| author | Tom Tromey | 2017-08-05 18:30:52 -0600 |
|---|---|---|
| committer | Tom Tromey | 2017-08-05 18:31:39 -0600 |
| commit | 9b463fa8648b7baed95a44f4317cb7402fd8bf1c (patch) | |
| tree | c7134b781617519f14256c5126a766673a01c7dd | |
| parent | 0bd08c00751a9deee66d304d3f18aa45ef1276db (diff) | |
| download | emacs-9b463fa8648b7baed95a44f4317cb7402fd8bf1c.tar.gz emacs-9b463fa8648b7baed95a44f4317cb7402fd8bf1c.zip | |
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.
| -rw-r--r-- | lisp/newcomment.el | 5 | ||||
| -rw-r--r-- | lisp/simple.el | 7 | ||||
| -rw-r--r-- | src/cmds.c | 11 |
3 files changed, 16 insertions, 7 deletions
diff --git a/lisp/newcomment.el b/lisp/newcomment.el index 8772b52376d..e3ee4dfab11 100644 --- a/lisp/newcomment.el +++ b/lisp/newcomment.el | |||
| @@ -1382,10 +1382,9 @@ unless optional argument SOFT is non-nil." | |||
| 1382 | (interactive) | 1382 | (interactive) |
| 1383 | (comment-normalize-vars t) | 1383 | (comment-normalize-vars t) |
| 1384 | (let (compos comin) | 1384 | (let (compos comin) |
| 1385 | ;; If we are not inside a comment and we only auto-fill comments, | 1385 | ;; If we are not inside a comment don't do anything (unless no |
| 1386 | ;; don't do anything (unless no comment syntax is defined). | 1386 | ;; comment syntax is defined). |
| 1387 | (unless (and comment-start | 1387 | (unless (and comment-start |
| 1388 | comment-auto-fill-only-comments | ||
| 1389 | (not (called-interactively-p 'interactive)) | 1388 | (not (called-interactively-p 'interactive)) |
| 1390 | (not (save-excursion | 1389 | (not (save-excursion |
| 1391 | (prog1 (setq compos (comment-beginning)) | 1390 | (prog1 (setq compos (comment-beginning)) |
diff --git a/lisp/simple.el b/lisp/simple.el index e3d86abe87a..027ce3959a9 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -7219,6 +7219,13 @@ unless optional argument SOFT is non-nil." | |||
| 7219 | ;; If we're not inside a comment, just try to indent. | 7219 | ;; If we're not inside a comment, just try to indent. |
| 7220 | (t (indent-according-to-mode)))))) | 7220 | (t (indent-according-to-mode)))))) |
| 7221 | 7221 | ||
| 7222 | (defun internal-auto-fill () | ||
| 7223 | "The function called by `self-insert-command' to perform auto-filling." | ||
| 7224 | (when (or (not comment-start) | ||
| 7225 | (not comment-auto-fill-only-comments) | ||
| 7226 | (nth 4 (syntax-ppss))) | ||
| 7227 | (do-auto-fill))) | ||
| 7228 | |||
| 7222 | (defvar normal-auto-fill-function 'do-auto-fill | 7229 | (defvar normal-auto-fill-function 'do-auto-fill |
| 7223 | "The function to use for `auto-fill-function' if Auto Fill mode is turned on. | 7230 | "The function to use for `auto-fill-function' if Auto Fill mode is turned on. |
| 7224 | Some major modes set this.") | 7231 | Some major modes set this.") |
diff --git a/src/cmds.c b/src/cmds.c index 51652d542a8..6f2db8696e9 100644 --- a/src/cmds.c +++ b/src/cmds.c | |||
| @@ -268,9 +268,10 @@ Whichever character you type to run this command is inserted. | |||
| 268 | The numeric prefix argument N says how many times to repeat the insertion. | 268 | The numeric prefix argument N says how many times to repeat the insertion. |
| 269 | Before insertion, `expand-abbrev' is executed if the inserted character does | 269 | Before insertion, `expand-abbrev' is executed if the inserted character does |
| 270 | not have word syntax and the previous character in the buffer does. | 270 | not have word syntax and the previous character in the buffer does. |
| 271 | After insertion, the value of `auto-fill-function' is called if the | 271 | After insertion, `internal-auto-fill' is called if |
| 272 | `auto-fill-chars' table has a non-nil value for the inserted character. | 272 | `auto-fill-function' is non-nil and if the `auto-fill-chars' table has |
| 273 | At the end, it runs `post-self-insert-hook'. */) | 273 | a non-nil value for the inserted character. At the end, it runs |
| 274 | `post-self-insert-hook'. */) | ||
| 274 | (Lisp_Object n) | 275 | (Lisp_Object n) |
| 275 | { | 276 | { |
| 276 | CHECK_NUMBER (n); | 277 | CHECK_NUMBER (n); |
| @@ -475,7 +476,7 @@ internal_self_insert (int c, EMACS_INT n) | |||
| 475 | that. Must have the newline in place already so filling and | 476 | that. Must have the newline in place already so filling and |
| 476 | justification, if any, know where the end is going to be. */ | 477 | justification, if any, know where the end is going to be. */ |
| 477 | SET_PT_BOTH (PT - 1, PT_BYTE - 1); | 478 | SET_PT_BOTH (PT - 1, PT_BYTE - 1); |
| 478 | auto_fill_result = call0 (BVAR (current_buffer, auto_fill_function)); | 479 | auto_fill_result = call0 (Qinternal_auto_fill); |
| 479 | /* Test PT < ZV in case the auto-fill-function is strange. */ | 480 | /* Test PT < ZV in case the auto-fill-function is strange. */ |
| 480 | if (c == '\n' && PT < ZV) | 481 | if (c == '\n' && PT < ZV) |
| 481 | SET_PT_BOTH (PT + 1, PT_BYTE + 1); | 482 | SET_PT_BOTH (PT + 1, PT_BYTE + 1); |
| @@ -494,6 +495,8 @@ internal_self_insert (int c, EMACS_INT n) | |||
| 494 | void | 495 | void |
| 495 | syms_of_cmds (void) | 496 | syms_of_cmds (void) |
| 496 | { | 497 | { |
| 498 | DEFSYM (Qinternal_auto_fill, "internal-auto-fill"); | ||
| 499 | |||
| 497 | DEFSYM (Qundo_auto_amalgamate, "undo-auto-amalgamate"); | 500 | DEFSYM (Qundo_auto_amalgamate, "undo-auto-amalgamate"); |
| 498 | DEFSYM (Qundo_auto__this_command_amalgamating, | 501 | DEFSYM (Qundo_auto__this_command_amalgamating, |
| 499 | "undo-auto--this-command-amalgamating"); | 502 | "undo-auto--this-command-amalgamating"); |