emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 23.0.50; Footnote-add-footnote and more condensed style


From: martin rudalics
Subject: Re: 23.0.50; Footnote-add-footnote and more condensed style
Date: Sat, 02 Feb 2008 20:57:33 +0100
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

> "Really needed", not in that sense. But it is a lot nicer to have
> beautifully condensed footnotes without at least two linefeeds between.

OK, try the attached patch (against the trunk) and customize
`footnote-section-tag' to nil.

Observe that I can't guarantee for anything here.  The footnote code is
hopelessly broken if not used with the default values.  Just for fun:
Before applying the patch set `footnote-spaced-footnotes' to nil, add a
footnote, and try to delete it with `footnote-delete-footnote'.
*** mail/footnote.el    Thu Jan 10 19:25:58 2008
--- mail/footnote.el    Sat Feb  2 20:43:08 2008
***************
*** 48,68 ****
    :group 'message)
  
  (defcustom footnote-mode-line-string " FN"
!   "*String to display in modes section of the mode-line."
    :group 'footnote)
  
  (defcustom footnote-mode-hook nil
!   "*Hook functions run when footnote-mode is activated."
    :type 'hook
    :group 'footnote)
  
  (defcustom footnote-narrow-to-footnotes-when-editing nil
!   "*If set, narrow to footnote text body while editing a footnote."
    :type 'boolean
    :group 'footnote)
  
  (defcustom footnote-prompt-before-deletion t
!   "*If set, prompt before deleting a footnote.
  There is currently no way to undo deletions."
    :type 'boolean
    :group 'footnote)
--- 48,68 ----
    :group 'message)
  
  (defcustom footnote-mode-line-string " FN"
!   "String to display in modes section of the mode-line."
    :group 'footnote)
  
  (defcustom footnote-mode-hook nil
!   "Hook functions run when footnote-mode is activated."
    :type 'hook
    :group 'footnote)
  
  (defcustom footnote-narrow-to-footnotes-when-editing nil
!   "If set, narrow to footnote text body while editing a footnote."
    :type 'boolean
    :group 'footnote)
  
  (defcustom footnote-prompt-before-deletion t
!   "If set, prompt before deleting a footnote.
  There is currently no way to undo deletions."
    :type 'boolean
    :group 'footnote)
***************
*** 74,85 ****
    :group 'footnote)
  
  (defcustom footnote-use-message-mode t
!   "*If non-nil assume Footnoting will be done in message-mode."
    :type 'boolean
    :group 'footnote)
  
  (defcustom footnote-body-tag-spacing 2
!   "*Number of blanks separating a footnote body tag and its text."
    :type 'integer
    :group 'footnote)
  
--- 74,85 ----
    :group 'footnote)
  
  (defcustom footnote-use-message-mode t
!   "If non-nil assume Footnoting will be done in message-mode."
    :type 'boolean
    :group 'footnote)
  
  (defcustom footnote-body-tag-spacing 2
!   "Number of blanks separating a footnote body tag and its text."
    :type 'integer
    :group 'footnote)
  
***************
*** 89,120 ****
  ;;; Interface variables that probably shouldn't be changed
  
  (defcustom footnote-section-tag "Footnotes: "
!   "*Tag inserted at beginning of footnote section."
!   :version "22.1"
!   :type 'string
    :group 'footnote)
  
  (defcustom footnote-section-tag-regexp "Footnotes\\(\\[.\\]\\)?: "
!   "*Regexp which indicates the start of a footnote section.
! See also `footnote-section-tag'."
    :type 'regexp
    :group 'footnote)
  
  ;; The following three should be consumed by footnote styles.
  (defcustom footnote-start-tag "["
!   "*String used to denote start of numbered footnote."
    :type 'string
    :group 'footnote)
  
  (defcustom footnote-end-tag "]"
!   "*String used to denote end of numbered footnote."
    :type 'string
    :group 'footnote)
  
  (defvar footnote-signature-separator (if (boundp 'message-signature-separator)
                                         message-signature-separator
                                       "^-- $")
!   "*String used to recognize .signatures.")
  
  ;;; Private variables
  
--- 89,122 ----
  ;;; Interface variables that probably shouldn't be changed
  
  (defcustom footnote-section-tag "Footnotes: "
!   "Tag inserted at beginning of footnote section.
! If you set this to nil no section tag is inserted and the value
! of `footnote-section-tag-regexp' is disregarded."
!   :version "23.1"
!   :type '(choice (const :tag "None" nil) string)
    :group 'footnote)
  
  (defcustom footnote-section-tag-regexp "Footnotes\\(\\[.\\]\\)?: "
!   "Regexp which indicates the start of a footnote section.
! This variable is disregarded when `footnote-section-tag' is nil."
    :type 'regexp
    :group 'footnote)
  
  ;; The following three should be consumed by footnote styles.
  (defcustom footnote-start-tag "["
!   "String used to denote start of numbered footnote."
    :type 'string
    :group 'footnote)
  
  (defcustom footnote-end-tag "]"
!   "String used to denote end of numbered footnote."
    :type 'string
    :group 'footnote)
  
  (defvar footnote-signature-separator (if (boundp 'message-signature-separator)
                                         message-signature-separator
                                       "^-- $")
!   "String used to recognize .signatures.")
  
  ;;; Private variables
  
***************
*** 295,301 ****
  exciting styles.")
  
  (defcustom footnote-style 'numeric
!   "*Default style used for footnoting.
  numeric == 1, 2, 3, ...
  english-lower == a, b, c, ...
  english-upper == A, B, C, ...
--- 297,303 ----
  exciting styles.")
  
  (defcustom footnote-style 'numeric
!   "Default style used for footnoting.
  numeric == 1, 2, 3, ...
  english-lower == a, b, c, ...
  english-upper == A, B, C, ...
***************
*** 455,462 ****
    (goto-char (point-max))
    (when (re-search-backward footnote-signature-separator nil t)
      (let ((end (point)))
!       (when (re-search-backward (concat "^" footnote-section-tag-regexp) nil 
t)
!       (narrow-to-region (point) end)))))
  
  (defun Footnote-goto-char-point-max ()
    "Move to end of buffer or prior to start of .signature."
--- 457,467 ----
    (goto-char (point-max))
    (when (re-search-backward footnote-signature-separator nil t)
      (let ((end (point)))
!       (cond
!        ((not footnote-section-tag)
!       (narrow-to-region (cdar footnote-text-marker-alist) end))
!        ((re-search-backward (concat "^" footnote-section-tag-regexp) nil t)
!       (narrow-to-region (point) end))))))
  
  (defun Footnote-goto-char-point-max ()
    "Move to end of buffer or prior to start of .signature."
***************
*** 465,471 ****
        (point)))
  
  (defun Footnote-insert-text-marker (arg locn)
!   "Insert a marker pointing to footnote arg, at buffer location locn."
    (let ((marker (make-marker)))
      (unless (assq arg footnote-text-marker-alist)
        (set-marker marker locn)
--- 470,476 ----
        (point)))
  
  (defun Footnote-insert-text-marker (arg locn)
!   "Insert a marker pointing to footnote ARG, at buffer location LOCN."
    (let ((marker (make-marker)))
      (unless (assq arg footnote-text-marker-alist)
        (set-marker marker locn)
***************
*** 475,481 ****
            (Footnote-sort footnote-text-marker-alist)))))
  
  (defun Footnote-insert-pointer-marker (arg locn)
!   "Insert a marker pointing to footnote arg, at buffer location locn."
    (let ((marker (make-marker))
        alist)
      (set-marker marker locn)
--- 480,486 ----
            (Footnote-sort footnote-text-marker-alist)))))
  
  (defun Footnote-insert-pointer-marker (arg locn)
!   "Insert a marker pointing to footnote ARG, at buffer location LOCN."
    (let ((marker (make-marker))
        alist)
      (set-marker marker locn)
***************
*** 488,499 ****
            (Footnote-sort footnote-pointer-marker-alist)))))
  
  (defun Footnote-insert-footnote (arg)
!   "Insert a footnote numbered arg, at (point)."
    (push-mark)
    (Footnote-insert-pointer-marker arg (point))
    (Footnote-insert-numbered-footnote arg t)
    (Footnote-goto-char-point-max)
!   (if (re-search-backward (concat "^" footnote-section-tag-regexp) nil t)
        (save-restriction
        (when footnote-narrow-to-footnotes-when-editing
          (Footnote-narrow-to-footnotes))
--- 493,507 ----
            (Footnote-sort footnote-pointer-marker-alist)))))
  
  (defun Footnote-insert-footnote (arg)
!   "Insert a footnote numbered ARG, at (point)."
    (push-mark)
    (Footnote-insert-pointer-marker arg (point))
    (Footnote-insert-numbered-footnote arg t)
    (Footnote-goto-char-point-max)
!   (if (cond (footnote-section-tag
!                (re-search-backward (concat "^" footnote-section-tag-regexp) 
nil t))
!               (footnote-text-marker-alist
!                (goto-char (cdar footnote-text-marker-alist))))
        (save-restriction
        (when footnote-narrow-to-footnotes-when-editing
          (Footnote-narrow-to-footnotes))
***************
*** 511,522 ****
                       nil t)
                  (unless (beginning-of-line) t))
                (Footnote-goto-char-point-max)
!               (re-search-backward (concat "^" footnote-section-tag-regexp) 
nil t))))
      (unless (looking-at "^$")
        (insert "\n"))
      (when (eobp)
        (insert "\n"))
!     (insert footnote-section-tag "\n"))
    (let ((old-point (point)))
      (Footnote-insert-numbered-footnote arg nil)
      (Footnote-insert-text-marker arg old-point)))
--- 519,536 ----
                       nil t)
                  (unless (beginning-of-line) t))
                (Footnote-goto-char-point-max)
!               (cond
!                (footnote-section-tag
!                (re-search-backward
!                 (concat "^" footnote-section-tag-regexp) nil t))
!                (footnote-text-marker-alist
!                 (goto-char (cdar footnote-text-marker-alist)))))))
      (unless (looking-at "^$")
        (insert "\n"))
      (when (eobp)
        (insert "\n"))
!     (when footnote-section-tag
!       (insert footnote-section-tag "\n")))
    (let ((old-point (point)))
      (Footnote-insert-numbered-footnote arg nil)
      (Footnote-insert-text-marker arg old-point)))
***************
*** 579,585 ****
        (setq i (1+ i)))
        rc)))
  
! (defun Footnote-add-footnote (&optional arg)
    "Add a numbered footnote.
  The number the footnote receives is dependent upon the relative location
  of any other previously existing footnotes.
--- 593,599 ----
        (setq i (1+ i)))
        rc)))
  
! (defun Footnote-add-footnote (&optional arg) ; what is ARG needed for ???
    "Add a numbered footnote.
  The number the footnote receives is dependent upon the relative location
  of any other previously existing footnotes.
***************
*** 610,616 ****
  
  (defun Footnote-delete-footnote (&optional arg)
    "Delete a numbered footnote.
! With no parameter, delete the footnote under (point).  With arg specified,
  delete the footnote with that number."
    (interactive "*P")
    (unless arg
--- 624,630 ----
  
  (defun Footnote-delete-footnote (&optional arg)
    "Delete a numbered footnote.
! With no parameter, delete the footnote under (point).  With ARG specified,
  delete the footnote with that number."
    (interactive "*P")
    (unless arg
***************
*** 629,639 ****
          (goto-char (car locn))
          (let* ((end (point))
                 (start (search-backward footnote-start-tag nil t)))
!           (kill-region start end)))
        (setq locn (cdr locn)))
        (save-excursion
        (goto-char (cdr alist-txt))
!       (kill-region (point) (search-forward "\n\n" nil t)))
        (setq footnote-pointer-marker-alist
            (delq alist-ptr footnote-pointer-marker-alist))
        (setq footnote-text-marker-alist
--- 643,661 ----
          (goto-char (car locn))
          (let* ((end (point))
                 (start (search-backward footnote-start-tag nil t)))
!           (delete-region start end)))
        (setq locn (cdr locn)))
        (save-excursion
        (goto-char (cdr alist-txt))
!       (delete-region
!        (point)
!        (if footnote-spaced-footnotes
!            ;; This might fail miserably when there's no such string.
!            (search-forward "\n\n" nil t)
!          (save-restriction
!            (end-of-line)
!            (next-single-char-property-change
!             (point) 'footnote-number nil (Footnote-goto-char-point-max))))))
        (setq footnote-pointer-marker-alist
            (delq alist-ptr footnote-pointer-marker-alist))
        (setq footnote-text-marker-alist
***************
*** 642,657 ****
        (when (and (null footnote-text-marker-alist)
                 (null footnote-pointer-marker-alist))
        (save-excursion
!         (let* ((end (Footnote-goto-char-point-max))
!                (start (1- (re-search-backward
!                            (concat "^" footnote-section-tag-regexp)
!                            nil t))))
!           (forward-line -1)
!           (when (looking-at "\n")
!             (kill-line))
!           (kill-region start (if (< end (point-max))
!                                  end
!                                (point-max)))))))))
  
  (defun Footnote-renumber-footnotes (&optional arg)
    "Renumber footnotes, starting from 1."
--- 664,683 ----
        (when (and (null footnote-text-marker-alist)
                 (null footnote-pointer-marker-alist))
        (save-excursion
!         (if footnote-section-tag
!             (let* ((end (Footnote-goto-char-point-max))
!                    (start (1- (re-search-backward
!                                (concat "^" footnote-section-tag-regexp)
!                                nil t))))
!               (forward-line -1)
!               (when (looking-at "\n")
!                 (kill-line))
!               (delete-region start (if (< end (point-max))
!                                        end ; ???
!                                      (point-max))))
!           (Footnote-goto-char-point-max)
!           (when (looking-back "\n\n")
!             (kill-line -1))))))))
  
  (defun Footnote-renumber-footnotes (&optional arg)
    "Renumber footnotes, starting from 1."
***************
*** 682,689 ****
        (if (eq arg 0)
          (progn
            (goto-char (point-max))
!           (re-search-backward (concat "^" footnote-section-tag-regexp))
!           (forward-line 1))
        (error "I don't see a footnote here")))))
  
  (defun Footnote-back-to-message (&optional arg)
--- 708,718 ----
        (if (eq arg 0)
          (progn
            (goto-char (point-max))
!           (cond (footnote-section-tag
!                  (re-search-backward (concat "^" footnote-section-tag-regexp))
!                  (forward-line 1))
!                 (footnote-text-marker-alist
!                  (goto-char (cdar footnote-text-marker-alist)))))
        (error "I don't see a footnote here")))))
  
  (defun Footnote-back-to-message (&optional arg)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]