unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: emacs-devel@gnu.org
Subject: Re: [Footnote-mode]: alignment option [CODE included]
Date: Fri, 08 Dec 2017 11:50:43 -0500	[thread overview]
Message-ID: <jwv374luqnn.fsf-monnier+gmane.emacs.devel@gnu.org> (raw)
In-Reply-To: 20171207061801.6ym3aeukjl3arlmg@E15-2016.optimum.net

> The attached code allows one to left-justify footnote text from the
> first column of text, instead of from the left margin.  I find this
> aesthetically preferable, especially when I have long footnotes.

Could you give some example of the difference?

> Of course, if one has visual-line-mode enabled, the
> auto-fill acts automatically.

Hmm... how does visual-line-mode pay attention to
Footnote-align-to-fn-text (and know if it's inside a footnote)?

> The current code is set up as defadvice-s (that's how long I've ended up
> sitting on it), but if emacs wants it integrated into the mode, there's
> no need for that.

Of course.  Some comments about the code:

> (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))))

IIUC body-auto-fill-prefix is just a var into which we temporarily save
the normal fill-prefix.  So this should be named with a "[Ff]ootnote-"
prefix (arguably with a "--" somewhere to make it clear it's an
internal variable), and it should be made buffer-local (so there's no
cross-buffer pollution).

The more serious problem is that `fill-prefix' is set with no guarantee
it will be reset to its proper value later.  E.g. if the user returns to
the body "manually" rather than via Footnote-back-to-message.

> (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")))

I suggest you make this into a minor mode:

    (define-minor-mode Footnote-align-to-text
      "When enabled, align footnote to the text rather than to the margin."
      :lighter nil
      (when footnote-text-marker-alist
        (if (>= (point) (cdr (first footnote-text-marker-alist)))
            (if Footnote-align-to-text
                (Footnote-align-to-fn)
              (Footnote-align-to-body)))))

> (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")))

I don't see how this relates to this new alignment feature.


        Stefan




  reply	other threads:[~2017-12-08 16:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-07  6:18 [Footnote-mode]: alignment option [CODE included] Boruch Baum
2017-12-08 16:50 ` Stefan Monnier [this message]
     [not found]   ` <jwvbmiylnmn.fsf-monnier+gmane.emacs.devel@gnu.org>
2017-12-18  0:13     ` Boruch Baum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwv374luqnn.fsf-monnier+gmane.emacs.devel@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).