GNU bug report logs - #27775
footnotes mode hanging indent [CODE INCLUDED]

Previous Next

Package: emacs;

Reported by: Boruch Baum <boruch_baum <at> gmx.com>

Date: Thu, 20 Jul 2017 21:18:01 UTC

Severity: minor

Tags: fixed

Fixed in version 27.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 27775 in the body.
You can then email your comments to 27775 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#27775; Package emacs. (Thu, 20 Jul 2017 21:18:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Boruch Baum <boruch_baum <at> gmx.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 20 Jul 2017 21:18:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Boruch Baum <boruch_baum <at> gmx.com>
To: Emacs Bug Reporting <bug-gnu-emacs <at> gnu.org>
Subject: footnotes mode hanging indent [CODE INCLUDED]
Date: Thu, 20 Jul 2017 17:17:26 -0400
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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27775; Package emacs. (Sun, 21 Jul 2019 14:43:01 GMT) Full text and rfc822 format available.

Message #8 received at 27775 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Boruch Baum <boruch_baum <at> gmx.com>
Cc: 27775 <at> debbugs.gnu.org
Subject: Re: bug#27775: footnotes mode hanging indent [CODE INCLUDED]
Date: Sun, 21 Jul 2019 16:42:11 +0200
Boruch Baum <boruch_baum <at> gmx.com> writes:

> 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.

This seems to have changed since this bug was filed -- when
auto-filling, things seem to work as expected in the footnotes.
However, `M-q' didn't work in any sensible fashion:

Footnotes:
[1] Foo bar

and then hit `M-q' would result in

Footnotes: [1] Foo bar

so I've added a new fill-paragraph function to the Emacs trunk.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 21 Jul 2019 14:44:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 27.1, send any further explanations to 27775 <at> debbugs.gnu.org and Boruch Baum <boruch_baum <at> gmx.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 21 Jul 2019 14:44:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27775; Package emacs. (Tue, 23 Jul 2019 01:05:01 GMT) Full text and rfc822 format available.

Message #15 received at 27775 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 27775 <at> debbugs.gnu.org, Boruch Baum <boruch_baum <at> gmx.com>
Subject: Re: bug#27775: footnotes mode hanging indent [CODE INCLUDED]
Date: Mon, 22 Jul 2019 21:04:42 -0400
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> so I've added a new fill-paragraph function to the Emacs trunk.

Hmm, you did

    (define-minor-mode footnote-mode
      ...
        (setq-local fill-paragraph-function #'footnote--fill-paragraph)

But since footnote-mode is a minor mode, isn't it a mistake to just take
over fill-paragraph-function like that?  What if the major mode has
installed some fill-paragraph-function?





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27775; Package emacs. (Tue, 23 Jul 2019 11:04:02 GMT) Full text and rfc822 format available.

Message #18 received at 27775 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Noam Postavsky <npostavs <at> gmail.com>
Cc: 27775 <at> debbugs.gnu.org, Boruch Baum <boruch_baum <at> gmx.com>
Subject: Re: bug#27775: footnotes mode hanging indent [CODE INCLUDED]
Date: Tue, 23 Jul 2019 13:03:35 +0200
Noam Postavsky <npostavs <at> gmail.com> writes:

> Lars Ingebrigtsen <larsi <at> gnus.org> writes:
>
>> so I've added a new fill-paragraph function to the Emacs trunk.
>
> Hmm, you did
>
>     (define-minor-mode footnote-mode
>       ...
>         (setq-local fill-paragraph-function #'footnote--fill-paragraph)
>
> But since footnote-mode is a minor mode, isn't it a mistake to just take
> over fill-paragraph-function like that?  What if the major mode has
> installed some fill-paragraph-function?

Oh, yeah, that's true.  How are minor modes supposed to do the paragraph
filling?  Hm...  For adaptive fill footnote does:

  (unless adaptive-fill-function
    ;; nil and `ignore' have the same semantics for adaptive-fill-function,
    ;; but only `ignore' behaves correctly with add/remove-function.
    (setq adaptive-fill-function #'ignore))
  (remove-function (local 'adaptive-fill-function)
                   #'footnote--adaptive-fill-function)

[...]

    (add-function :around (local 'adaptive-fill-function)
                  #'footnote--adaptive-fill-function)

and I guess it could do the same for fill-paragraph-function?   (It
seems like a mouthful, though -- perhaps there should be a helper
function to do all this?)

Hm!  Or will using fill-forward-paragraph-function do the right thing
both for adaptive filling and paragraph filling?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27775; Package emacs. (Thu, 25 Jul 2019 12:18:01 GMT) Full text and rfc822 format available.

Message #21 received at 27775 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 27775 <at> debbugs.gnu.org, Boruch Baum <boruch_baum <at> gmx.com>
Subject: Re: bug#27775: footnotes mode hanging indent [CODE INCLUDED]
Date: Thu, 25 Jul 2019 08:16:53 -0400
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Hm!  Or will using fill-forward-paragraph-function do the right thing
> both for adaptive filling and paragraph filling?

I think the footnote--adaptive-fill-function would still be needed,
because fill-forward-paragraph-function can't choose the fill prefix.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27775; Package emacs. (Thu, 25 Jul 2019 17:40:02 GMT) Full text and rfc822 format available.

Message #24 received at 27775 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Noam Postavsky <npostavs <at> gmail.com>
Cc: 27775 <at> debbugs.gnu.org, Boruch Baum <boruch_baum <at> gmx.com>
Subject: Re: bug#27775: footnotes mode hanging indent [CODE INCLUDED]
Date: Thu, 25 Jul 2019 19:39:36 +0200
Noam Postavsky <npostavs <at> gmail.com> writes:

> Lars Ingebrigtsen <larsi <at> gnus.org> writes:
>
>> Hm!  Or will using fill-forward-paragraph-function do the right thing
>> both for adaptive filling and paragraph filling?
>
> I think the footnote--adaptive-fill-function would still be needed,
> because fill-forward-paragraph-function can't choose the fill prefix.

Right.

I've looked through the code to see if I could find any other minor
modes that does stuff with these variables, and I couldn't find them.
So I've just refactored out the dance footnote-mode does with
adaptive-fill-function into its own macro and done the same with
fill-paragraph-function.

If this is deemed generally useful, then we can move it somewhere more
central.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 23 Aug 2019 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 5 years and 323 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.