mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-04-30 02:02:38 -07:00
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.
This commit is contained in:
parent
0bd08c0075
commit
9b463fa864
3 changed files with 16 additions and 7 deletions
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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.")
|
||||
|
|
|
|||
11
src/cmds.c
11
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");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue