[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 7acae22f42f: Fix auto-filling in Texinfo mode
From: |
Eli Zaretskii |
Subject: |
emacs-29 7acae22f42f: Fix auto-filling in Texinfo mode |
Date: |
Sat, 13 May 2023 04:29:41 -0400 (EDT) |
branch: emacs-29
commit 7acae22f42f1b2df2042d5d77a0839f0ca9c02e7
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>
Fix auto-filling in Texinfo mode
This fixes auto-filling in Texinfo buffers. It was broken by the
fix to bug#49558, which made M-q fill over-long @noindent lines by
refraining from customizing 'paragraph-separate' in Texinfo mode.
The underlying problem here is that 'auto-fill-mode' doesn't call
mode-specific filling functions, but does its job by itself, and
depends on 'forward-paragraph' to find the beginning of the
paragraph as appropriate for calculation of 'fill-prefix', and a
different value of 'paragraph-separate' broke that. As a side
effect, the change below also changes paragraph-movement commands
in Texinfo back to how they behaved prior to that bugfix, but I
don't see why the paragraph-movement behavior introduced by that
fix made more sense. Try to move through a series of
@-directives, like a paragraph preceded by several @cindex
entries, and you will see the inconsistencies. In any case, the
adverse effects of that fix on auto-filling is unacceptable.
* lisp/textmodes/texinfo.el (fill-paragraph-separate): New
variable.
(texinfo-mode): Set 'fill-paragraph-separate' to the default value
of 'paragraph-separate'. Customize 'paragraph-separate' to the
Texinfo-specific value, as it was before commit dde591571abf.
(texinfo--fill-paragraph): Bind 'paragraph-separate' to the value
of 'fill-paragraph-separate', to keep 'M-q' happy.
---
lisp/textmodes/texinfo.el | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/lisp/textmodes/texinfo.el b/lisp/textmodes/texinfo.el
index 7416c631c9f..bedf9ec92a5 100644
--- a/lisp/textmodes/texinfo.el
+++ b/lisp/textmodes/texinfo.el
@@ -409,6 +409,8 @@ REPORT-FN is the callback function."
;;; Texinfo mode
+(defvar fill-paragraph-separate nil)
+
;;;###autoload
(define-derived-mode texinfo-mode text-mode "Texinfo"
"Major mode for editing Texinfo files.
@@ -482,6 +484,10 @@ value of `texinfo-mode-hook'."
"\\)\\>"))
(setq-local require-final-newline mode-require-final-newline)
(setq-local indent-tabs-mode nil)
+ ;; This is used in 'texinfo--fill-paragraph'.
+ (setq-local fill-paragraph-separate (default-value 'paragraph-separate))
+ (setq-local paragraph-separate
+ (concat "@[a-zA-Z]*[ \n]\\|" paragraph-separate))
(setq-local paragraph-start (concat "@[a-zA-Z]*[ \n]\\|"
paragraph-start))
(setq-local fill-paragraph-function 'texinfo--fill-paragraph)
@@ -536,7 +542,13 @@ value of `texinfo-mode-hook'."
(defun texinfo--fill-paragraph (justify)
"Function to fill a paragraph in `texinfo-mode'."
- (let ((command-re "\\(@[a-zA-Z]+\\)[ \t\n]"))
+ (let ((command-re "\\(@[a-zA-Z]+\\)[ \t\n]")
+ ;; Kludge alert: we override paragraph-separate here because
+ ;; that is needed for filling @noindent and similar lines.
+ ;; The default Texinfo-specific paragraph-separate value,
+ ;; OTOH, is needed for auto-fill-mode, which doesn't call
+ ;; mode-specific functions.
+ (paragraph-separate fill-paragraph-separate))
(catch 'no-fill
(save-restriction
;; First check whether we're on a command line that can be
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- emacs-29 7acae22f42f: Fix auto-filling in Texinfo mode,
Eli Zaretskii <=