From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [Footnote-mode]: alignment option [CODE included] Date: Fri, 08 Dec 2017 11:50:43 -0500 Message-ID: References: <20171207061801.6ym3aeukjl3arlmg@E15-2016.optimum.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1512751900 3758 195.159.176.226 (8 Dec 2017 16:51:40 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 8 Dec 2017 16:51:40 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Dec 08 17:51:32 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eNLs2-0000hG-7L for ged-emacs-devel@m.gmane.org; Fri, 08 Dec 2017 17:51:30 +0100 Original-Received: from localhost ([::1]:38128 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eNLs9-0000uB-JG for ged-emacs-devel@m.gmane.org; Fri, 08 Dec 2017 11:51:37 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54877) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eNLrX-0000u4-Rz for emacs-devel@gnu.org; Fri, 08 Dec 2017 11:51:00 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eNLrU-0003Ir-PD for emacs-devel@gnu.org; Fri, 08 Dec 2017 11:50:59 -0500 Original-Received: from [195.159.176.226] (port=35734 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eNLrU-0003HC-Iz for emacs-devel@gnu.org; Fri, 08 Dec 2017 11:50:56 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1eNLrG-0007ib-RC for emacs-devel@gnu.org; Fri, 08 Dec 2017 17:50:42 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 68 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:l3HbYXhPdBsfq/v0yLIrdDrws4Y= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:220793 Archived-At: > 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