;━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ; Footnote behavior customization ; + left-align footnote text to first character of first paragraph, ; not to left margin. ; + Instructions: ; + toggle the feature using 'mode-map-prexic q' (usually 'C-c ! q') ; + whenever you run `auto-fill' (M-q), it will act ; + if you set visual-line-mode, it acts automatically (require 'footnote) (setq Footnote-align-to-fn-text t body-auto-fill-prefix nil) (defun Footnote-calc-fn-alignment-column() (+ footnote-body-tag-spacing (length (concat footnote-start-tag footnote-end-tag (Footnote-index-to-string (caar (last footnote-text-marker-alist))))))) (defun Footnote-align-to-fn() (when Footnote-align-to-fn-text (setq body-auto-fill-prefix fill-prefix fill-prefix (make-string (Footnote-calc-fn-alignment-column) 32)))) (defun Footnote-align-to-body() (when (not Footnote-align-to-fn-text) (setq fill-prefix body-auto-fill-prefix))) (defun Footnote-toggle-alignment() (interactive) (setq Footnote-align-to-fn-text (not Footnote-align-to-fn-text)) (when footnote-text-marker-alist (if (>= (point) (cdr (first footnote-text-marker-alist))) (if Footnote-align-to-fn-text (Footnote-align-to-fn) (Footnote-align-to-body)))) (if Footnote-align-to-fn-text (message "Footnotes will left-align to footnote text") (message "Footnotes will left-align to body text"))) (define-key footnote-mode-map (kbd "q") 'Footnote-toggle-alignment) (defadvice Footnote-add-footnote (after update-auto-fill-prefix activate) (interactive) (Footnote-align-to-fn)) (defadvice Footnote-back-to-message (after restore-auto-fill-prefix activate) (interactive) (setq fill-prefix body-auto-fill-prefix)) (defadvice Footnote-add-footnote (around abort-when-in-fn-area activate) (interactive) (if (or (not footnote-text-marker-alist) (< (point) (cdr (first footnote-text-marker-alist)))) ad-do-it (message "Add footnotes only while in text body"))) ;━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━