all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#27775: footnotes mode hanging indent [CODE INCLUDED]
@ 2017-07-20 21:17 Boruch Baum
  2019-07-21 14:42 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 6+ messages in thread
From: Boruch Baum @ 2017-07-20 21:17 UTC (permalink / raw)
  To: 27775

1] I find it preferable to have footnote text always left-justified to
   the beginning of the first character of text, while emacs
   auto-fills by default to column 1 and would require unwieldly
   toggling set-fill-prefix whenever moving between text body and
   footnotes.

   Here's what I've done for myself, so far, and if you like it in
   principle, you can have it. I'm available to tweak it some per your
   suggestions and my ability (eg. modify the footnote functions
   themselves instead advising after them).

2] Function `Footnote-add-footnote' in emacs25 defines an optional
   `arg', but it is never used.

3] The current default value for variable `footnote-body-tag-spacing'
   is 2, which is visually appealing, but doesn't persist upon
   `fill-paragraph'. I've tried replacing the space character with a
   non-breaking space (integer value 160), which you might want to
   consider, but it visually looks like an underscore which is
   un-appealing.


#+BEGIN_SRC emacs-lisp
(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))
#+END_SRC

--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-07-25 17:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-20 21:17 bug#27775: footnotes mode hanging indent [CODE INCLUDED] Boruch Baum
2019-07-21 14:42 ` Lars Ingebrigtsen
2019-07-23  1:04   ` Noam Postavsky
2019-07-23 11:03     ` Lars Ingebrigtsen
2019-07-25 12:16       ` Noam Postavsky
2019-07-25 17:39         ` Lars Ingebrigtsen

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.