]> git.eshelyaron.com Git - emacs.git/commitdiff
Fill footnotes better on `M-q'
authorLars Ingebrigtsen <larsi@gnus.org>
Sun, 21 Jul 2019 14:43:07 +0000 (16:43 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Sun, 21 Jul 2019 14:43:11 +0000 (16:43 +0200)
* lisp/mail/footnote.el (footnote--fill-paragraph): New function
(bug#27775).
(footnote-mode): Use it.

lisp/mail/footnote.el

index bbc42e11f74f6bdc70075cce231c8385f409bac4..42ab35b66522d61f047afc2707ce859b57c7b5c7 100644 (file)
@@ -695,6 +695,15 @@ footnote area, returns `point-max'."
    ;; If not within a footnote's text, fallback to the default.
    (funcall orig-fun)))
 
+(defun footnote--fill-paragraph (justify)
+  (when (footnote--text-under-cursor)
+    (let ((fill-paragraph-function nil)
+          (fill-prefix (if footnote-align-to-fn-text
+                           (footnote--fill-prefix-string)
+                         ""))
+          (paragraph-start "\\["))
+      (fill-paragraph justify))))
+
 ;;; User functions
 
 (defun footnote--make-hole ()
@@ -875,6 +884,7 @@ play around with the following keys:
     (make-local-variable 'adaptive-fill-function)
     (add-function :around (local 'adaptive-fill-function)
                   #'footnote--adaptive-fill-function)
+    (setq-local fill-paragraph-function #'footnote--fill-paragraph)
 
     ;; Filladapt was an XEmacs package which is now in GNU ELPA.
     (when (boundp 'filladapt-token-table)