diff options
| author | Martin Rudalics | 2008-10-06 06:29:05 +0000 |
|---|---|---|
| committer | Martin Rudalics | 2008-10-06 06:29:05 +0000 |
| commit | 6a8b4632645ea3d5f065be5849982f98148dc340 (patch) | |
| tree | 94d929106ac3d0b479cc3161378f510820e441c7 | |
| parent | cd1d1525597e3fb9476daaf79a0a5fa405f0a8ae (diff) | |
| download | emacs-6a8b4632645ea3d5f065be5849982f98148dc340.tar.gz emacs-6a8b4632645ea3d5f065be5849982f98148dc340.zip | |
Remove * in defcustom docstrings and tell
for most options that customizing them doesn't affect buffers
already displaying footnotes.
(Footnote-refresh-footnotes, Footnote-renumber-footnotes): Fix
handling of text properties and identical start/end tags. Do
not use format when renumbering.
(Footnote-set-style): Make it work.
(Footnote-insert-numbered-footnote): Simplify.
(Footnote-narrow-to-footnotes, Footnote-insert-footnote)
(Footnote-goto-footnote): Fix handling of empty section tag.
(Footnote-delete-footnote): Fix handling of identical start/end
tags, empty section tag, and spaced footnotes. Do not use
kill-region.
(footnote-mode): Make most options buffer-local to avoid that
customizing messes up handling of footnotes in buffers that
already display them.
| -rw-r--r-- | lisp/ChangeLog | 19 | ||||
| -rw-r--r-- | lisp/mail/footnote.el | 268 |
2 files changed, 180 insertions, 107 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 8e3496d2323..c404c3ca43b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,22 @@ | |||
| 1 | 2008-10-06 Martin Rudalics <rudalics@gmx.at> | ||
| 2 | |||
| 3 | * mail/footnote.el: Remove * in defcustom docstrings and tell | ||
| 4 | for most options that customizing them doesn't affect buffers | ||
| 5 | already displaying footnotes. | ||
| 6 | (Footnote-refresh-footnotes, Footnote-renumber-footnotes): Fix | ||
| 7 | handling of text properties and identical start/end tags. Do | ||
| 8 | not use format when renumbering. | ||
| 9 | (Footnote-set-style): Make it work. | ||
| 10 | (Footnote-insert-numbered-footnote): Simplify. | ||
| 11 | (Footnote-narrow-to-footnotes, Footnote-insert-footnote) | ||
| 12 | (Footnote-goto-footnote): Fix handling of empty section tag. | ||
| 13 | (Footnote-delete-footnote): Fix handling of identical start/end | ||
| 14 | tags, empty section tag, and spaced footnotes. Do not use | ||
| 15 | kill-region. | ||
| 16 | (footnote-mode): Make most options buffer-local to avoid that | ||
| 17 | customizing messes up handling of footnotes in buffers that | ||
| 18 | already display them. | ||
| 19 | |||
| 1 | 2008-10-06 Dan Nicolaescu <dann@ics.uci.edu> | 20 | 2008-10-06 Dan Nicolaescu <dann@ics.uci.edu> |
| 2 | 21 | ||
| 3 | * faces.el (x-create-frame-with-faces): Undo previous change. | 22 | * faces.el (x-create-frame-with-faces): Undo previous change. |
diff --git a/lisp/mail/footnote.el b/lisp/mail/footnote.el index cd51caa11ba..6741e0a5442 100644 --- a/lisp/mail/footnote.el +++ b/lisp/mail/footnote.el | |||
| @@ -46,66 +46,78 @@ | |||
| 46 | :group 'message) | 46 | :group 'message) |
| 47 | 47 | ||
| 48 | (defcustom footnote-mode-line-string " FN" | 48 | (defcustom footnote-mode-line-string " FN" |
| 49 | "*String to display in modes section of the mode-line." | 49 | "String to display in modes section of the mode-line." |
| 50 | :group 'footnote) | 50 | :group 'footnote) |
| 51 | 51 | ||
| 52 | (defcustom footnote-mode-hook nil | 52 | (defcustom footnote-mode-hook nil |
| 53 | "*Hook functions run when footnote-mode is activated." | 53 | "Hook functions run when footnote-mode is activated." |
| 54 | :type 'hook | 54 | :type 'hook |
| 55 | :group 'footnote) | 55 | :group 'footnote) |
| 56 | 56 | ||
| 57 | (defcustom footnote-narrow-to-footnotes-when-editing nil | 57 | (defcustom footnote-narrow-to-footnotes-when-editing nil |
| 58 | "*If set, narrow to footnote text body while editing a footnote." | 58 | "If non-nil, narrow to footnote text body while editing a footnote." |
| 59 | :type 'boolean | 59 | :type 'boolean |
| 60 | :group 'footnote) | 60 | :group 'footnote) |
| 61 | 61 | ||
| 62 | (defcustom footnote-prompt-before-deletion t | 62 | (defcustom footnote-prompt-before-deletion t |
| 63 | "*If set, prompt before deleting a footnote. | 63 | "If non-nil, prompt before deleting a footnote. |
| 64 | There is currently no way to undo deletions." | 64 | There is currently no way to undo deletions." |
| 65 | :type 'boolean | 65 | :type 'boolean |
| 66 | :group 'footnote) | 66 | :group 'footnote) |
| 67 | 67 | ||
| 68 | (defcustom footnote-spaced-footnotes t | 68 | (defcustom footnote-spaced-footnotes t |
| 69 | "If set true it will put a blank line between each footnote. | 69 | "If non-nil, insert an empty line between footnotes. |
| 70 | If nil, no blank line will be inserted." | 70 | Customizing this variable has no effect on buffers already |
| 71 | displaying footnotes." | ||
| 71 | :type 'boolean | 72 | :type 'boolean |
| 72 | :group 'footnote) | 73 | :group 'footnote) |
| 73 | 74 | ||
| 74 | (defcustom footnote-use-message-mode t | 75 | (defcustom footnote-use-message-mode t ; Nowhere used. |
| 75 | "*If non-nil assume Footnoting will be done in message-mode." | 76 | "If non-nil, assume Footnoting will be done in `message-mode'." |
| 76 | :type 'boolean | 77 | :type 'boolean |
| 77 | :group 'footnote) | 78 | :group 'footnote) |
| 78 | 79 | ||
| 79 | (defcustom footnote-body-tag-spacing 2 | 80 | (defcustom footnote-body-tag-spacing 2 |
| 80 | "*Number of blanks separating a footnote body tag and its text." | 81 | "Number of spaces separating a footnote body tag and its text. |
| 82 | Customizing this variable has no effect on buffers already | ||
| 83 | displaying footnotes." | ||
| 81 | :type 'integer | 84 | :type 'integer |
| 82 | :group 'footnote) | 85 | :group 'footnote) |
| 83 | 86 | ||
| 84 | (defvar footnote-prefix [(control ?c) ?!] | 87 | (defvar footnote-prefix [(control ?c) ?!] |
| 85 | "*When not using message mode, the prefix to bind in `mode-specific-map'") | 88 | "*When not using `message-mode', the prefix to bind in `mode-specific-map'") |
| 86 | 89 | ||
| 87 | ;;; Interface variables that probably shouldn't be changed | 90 | ;;; Interface variables that probably shouldn't be changed |
| 88 | 91 | ||
| 89 | (defcustom footnote-section-tag "Footnotes: " | 92 | (defcustom footnote-section-tag "Footnotes: " |
| 90 | "*Tag inserted at beginning of footnote section." | 93 | "Tag inserted at beginning of footnote section. |
| 91 | :version "22.1" | 94 | If you set this to the empty string, no tag is inserted and the |
| 95 | value of `footnote-section-tag-regexp' is ignored. Customizing | ||
| 96 | this variable has no effect on buffers already displaying | ||
| 97 | footnotes." | ||
| 92 | :type 'string | 98 | :type 'string |
| 93 | :group 'footnote) | 99 | :group 'footnote) |
| 94 | 100 | ||
| 95 | (defcustom footnote-section-tag-regexp "Footnotes\\(\\[.\\]\\)?: " | 101 | (defcustom footnote-section-tag-regexp "Footnotes\\(\\[.\\]\\)?: " |
| 96 | "*Regexp which indicates the start of a footnote section. | 102 | "Regexp which indicates the start of a footnote section. |
| 97 | See also `footnote-section-tag'." | 103 | This variable is disregarded when `footnote-section-tag' is the |
| 104 | empty string. Customizing this variable has no effect on buffers | ||
| 105 | already displaying footnotes." | ||
| 98 | :type 'regexp | 106 | :type 'regexp |
| 99 | :group 'footnote) | 107 | :group 'footnote) |
| 100 | 108 | ||
| 101 | ;; The following three should be consumed by footnote styles. | 109 | ;; The following three should be consumed by footnote styles. |
| 102 | (defcustom footnote-start-tag "[" | 110 | (defcustom footnote-start-tag "[" |
| 103 | "*String used to denote start of numbered footnote." | 111 | "String used to denote start of numbered footnote. |
| 112 | Should not be set to the empty string. Customizing this variable | ||
| 113 | has no effect on buffers already displaying footnotes." | ||
| 104 | :type 'string | 114 | :type 'string |
| 105 | :group 'footnote) | 115 | :group 'footnote) |
| 106 | 116 | ||
| 107 | (defcustom footnote-end-tag "]" | 117 | (defcustom footnote-end-tag "]" |
| 108 | "*String used to denote end of numbered footnote." | 118 | "String used to denote end of numbered footnote. |
| 119 | Should not be set to the empty string. Customizing this variable | ||
| 120 | has no effect on buffers already displaying footnotes." | ||
| 109 | :type 'string | 121 | :type 'string |
| 110 | :group 'footnote) | 122 | :group 'footnote) |
| 111 | 123 | ||
| @@ -293,7 +305,7 @@ See footnote-han.el, footnote-greek.el and footnote-hebrew.el for more | |||
| 293 | exciting styles.") | 305 | exciting styles.") |
| 294 | 306 | ||
| 295 | (defcustom footnote-style 'numeric | 307 | (defcustom footnote-style 'numeric |
| 296 | "*Default style used for footnoting. | 308 | "Default style used for footnoting. |
| 297 | numeric == 1, 2, 3, ... | 309 | numeric == 1, 2, 3, ... |
| 298 | english-lower == a, b, c, ... | 310 | english-lower == a, b, c, ... |
| 299 | english-upper == A, B, C, ... | 311 | english-upper == A, B, C, ... |
| @@ -303,8 +315,8 @@ latin == ¹ ² ³ º ª § ¶ | |||
| 303 | See also variables `footnote-start-tag' and `footnote-end-tag'. | 315 | See also variables `footnote-start-tag' and `footnote-end-tag'. |
| 304 | 316 | ||
| 305 | Customizing this variable has no effect on buffers already | 317 | Customizing this variable has no effect on buffers already |
| 306 | displaying footnotes. You can change the style of existing | 318 | displaying footnotes. To change the style of footnotes in such a |
| 307 | buffers using the command `Footnote-set-style'." | 319 | buffer use the command `Footnote-set-style'." |
| 308 | :type (cons 'choice (mapcar (lambda (x) (list 'const (car x))) | 320 | :type (cons 'choice (mapcar (lambda (x) (list 'const (car x))) |
| 309 | footnote-style-alist)) | 321 | footnote-style-alist)) |
| 310 | :group 'footnote) | 322 | :group 'footnote) |
| @@ -341,16 +353,21 @@ styles." | |||
| 341 | (setq locn (cdr alist)) | 353 | (setq locn (cdr alist)) |
| 342 | (while locn | 354 | (while locn |
| 343 | (goto-char (car locn)) | 355 | (goto-char (car locn)) |
| 344 | (search-backward footnote-start-tag nil t) | 356 | ;; Try to handle the case where `footnote-start-tag' and |
| 345 | (when (looking-at (concat | 357 | ;; `footnote-end-tag' are the same string. |
| 346 | (regexp-quote footnote-start-tag) | 358 | (when (looking-back (concat |
| 347 | "\\(" index-regexp "+\\)" | 359 | (regexp-quote footnote-start-tag) |
| 348 | (regexp-quote footnote-end-tag))) | 360 | "\\(" index-regexp "+\\)" |
| 349 | (replace-match (concat | 361 | (regexp-quote footnote-end-tag)) |
| 350 | footnote-start-tag | 362 | (line-beginning-position)) |
| 351 | (Footnote-index-to-string (1+ i)) | 363 | (replace-match |
| 352 | footnote-end-tag) | 364 | (propertize |
| 353 | nil "\\1")) | 365 | (concat |
| 366 | footnote-start-tag | ||
| 367 | (Footnote-index-to-string (1+ i)) | ||
| 368 | footnote-end-tag) | ||
| 369 | 'footnote-number (1+ i) footnote-mouse-highlight t) | ||
| 370 | nil "\\1")) | ||
| 354 | (setq locn (cdr locn))) | 371 | (setq locn (cdr locn))) |
| 355 | (setq i (1+ i)))) | 372 | (setq i (1+ i)))) |
| 356 | 373 | ||
| @@ -362,11 +379,14 @@ styles." | |||
| 362 | (regexp-quote footnote-start-tag) | 379 | (regexp-quote footnote-start-tag) |
| 363 | "\\(" index-regexp "+\\)" | 380 | "\\(" index-regexp "+\\)" |
| 364 | (regexp-quote footnote-end-tag))) | 381 | (regexp-quote footnote-end-tag))) |
| 365 | (replace-match (concat | 382 | (replace-match |
| 366 | footnote-start-tag | 383 | (propertize |
| 367 | (Footnote-index-to-string (1+ i)) | 384 | (concat |
| 368 | footnote-end-tag) | 385 | footnote-start-tag |
| 369 | nil "\\1")) | 386 | (Footnote-index-to-string (1+ i)) |
| 387 | footnote-end-tag) | ||
| 388 | 'footnote-number (1+ i)) | ||
| 389 | nil "\\1")) | ||
| 370 | (setq i (1+ i)))))) | 390 | (setq i (1+ i)))))) |
| 371 | 391 | ||
| 372 | (defun Footnote-assoc-index (key alist) | 392 | (defun Footnote-assoc-index (key alist) |
| @@ -397,23 +417,21 @@ styles." | |||
| 397 | (list (intern (completing-read | 417 | (list (intern (completing-read |
| 398 | "Footnote Style: " | 418 | "Footnote Style: " |
| 399 | obarray #'Footnote-style-p 'require-match)))) | 419 | obarray #'Footnote-style-p 'require-match)))) |
| 400 | (setq footnote-style style)) | 420 | (let ((old (Footnote-assoc-index footnote-style footnote-style-alist))) |
| 421 | (setq footnote-style style) | ||
| 422 | (Footnote-refresh-footnotes (nth 2 (nth old footnote-style-alist))))) | ||
| 401 | 423 | ||
| 402 | ;; Internal functions | 424 | ;; Internal functions |
| 403 | (defun Footnote-insert-numbered-footnote (arg &optional mousable) | 425 | (defun Footnote-insert-numbered-footnote (arg &optional mousable) |
| 404 | "Insert numbered footnote at (point)." | 426 | "Insert numbered footnote at (point)." |
| 405 | (let* ((start (point)) | 427 | (let ((string (concat footnote-start-tag |
| 406 | (end (progn | 428 | (Footnote-index-to-string arg) |
| 407 | (insert-before-markers (concat footnote-start-tag | 429 | footnote-end-tag))) |
| 408 | (Footnote-index-to-string arg) | 430 | (insert-before-markers |
| 409 | footnote-end-tag)) | 431 | (if mousable |
| 410 | (point)))) | 432 | (propertize |
| 411 | 433 | string 'footnote-number arg footnote-mouse-highlight t) | |
| 412 | (add-text-properties start end | 434 | (propertize string 'footnote-number arg))))) |
| 413 | (list 'footnote-number arg)) | ||
| 414 | (when mousable | ||
| 415 | (add-text-properties start end | ||
| 416 | (list footnote-mouse-highlight t))))) | ||
| 417 | 435 | ||
| 418 | (defun Footnote-renumber (from to pointer-alist text-alist) | 436 | (defun Footnote-renumber (from to pointer-alist text-alist) |
| 419 | "Renumber a single footnote." | 437 | "Renumber a single footnote." |
| @@ -422,29 +440,27 @@ styles." | |||
| 422 | (setcar text-alist to) | 440 | (setcar text-alist to) |
| 423 | (while posn-list | 441 | (while posn-list |
| 424 | (goto-char (car posn-list)) | 442 | (goto-char (car posn-list)) |
| 425 | (search-backward footnote-start-tag nil t) | 443 | (when (looking-back (concat (regexp-quote footnote-start-tag) |
| 426 | (when (looking-at (format "%s%s%s" | 444 | (Footnote-current-regexp) |
| 427 | (regexp-quote footnote-start-tag) | 445 | (regexp-quote footnote-end-tag)) |
| 428 | (Footnote-current-regexp) | 446 | (line-beginning-position)) |
| 429 | (regexp-quote footnote-end-tag))) | 447 | (replace-match |
| 430 | (add-text-properties (match-beginning 0) (match-end 0) | 448 | (propertize |
| 431 | (list 'footnote-number to)) | 449 | (concat footnote-start-tag |
| 432 | (replace-match (format "%s%s%s" | 450 | (Footnote-index-to-string to) |
| 433 | footnote-start-tag | 451 | footnote-end-tag) |
| 434 | (Footnote-index-to-string to) | 452 | 'footnote-number to footnote-mouse-highlight t))) |
| 435 | footnote-end-tag))) | ||
| 436 | (setq posn-list (cdr posn-list))) | 453 | (setq posn-list (cdr posn-list))) |
| 437 | (goto-char (cdr text-alist)) | 454 | (goto-char (cdr text-alist)) |
| 438 | (when (looking-at (format "%s%s%s" | 455 | (when (looking-at (concat (regexp-quote footnote-start-tag) |
| 439 | (regexp-quote footnote-start-tag) | ||
| 440 | (Footnote-current-regexp) | 456 | (Footnote-current-regexp) |
| 441 | (regexp-quote footnote-end-tag))) | 457 | (regexp-quote footnote-end-tag))) |
| 442 | (add-text-properties (match-beginning 0) (match-end 0) | 458 | (replace-match |
| 443 | (list 'footnote-number to)) | 459 | (propertize |
| 444 | (replace-match (format "%s%s%s" | 460 | (concat footnote-start-tag |
| 445 | footnote-start-tag | 461 | (Footnote-index-to-string to) |
| 446 | (Footnote-index-to-string to) | 462 | footnote-end-tag) |
| 447 | footnote-end-tag) nil t)))) | 463 | 'footnote-number to))))) |
| 448 | 464 | ||
| 449 | ;; Not needed? | 465 | ;; Not needed? |
| 450 | (defun Footnote-narrow-to-footnotes () | 466 | (defun Footnote-narrow-to-footnotes () |
| @@ -453,8 +469,13 @@ styles." | |||
| 453 | (goto-char (point-max)) | 469 | (goto-char (point-max)) |
| 454 | (when (re-search-backward footnote-signature-separator nil t) | 470 | (when (re-search-backward footnote-signature-separator nil t) |
| 455 | (let ((end (point))) | 471 | (let ((end (point))) |
| 456 | (when (re-search-backward (concat "^" footnote-section-tag-regexp) nil t) | 472 | (cond |
| 457 | (narrow-to-region (point) end))))) | 473 | ((and (not (string-equal footnote-section-tag "")) |
| 474 | (re-search-backward | ||
| 475 | (concat "^" footnote-section-tag-regexp) nil t)) | ||
| 476 | (narrow-to-region (point) end)) | ||
| 477 | (footnote-text-marker-alist | ||
| 478 | (narrow-to-region (cdar footnote-text-marker-alist) end)))))) | ||
| 458 | 479 | ||
| 459 | (defun Footnote-goto-char-point-max () | 480 | (defun Footnote-goto-char-point-max () |
| 460 | "Move to end of buffer or prior to start of .signature." | 481 | "Move to end of buffer or prior to start of .signature." |
| @@ -463,7 +484,7 @@ styles." | |||
| 463 | (point))) | 484 | (point))) |
| 464 | 485 | ||
| 465 | (defun Footnote-insert-text-marker (arg locn) | 486 | (defun Footnote-insert-text-marker (arg locn) |
| 466 | "Insert a marker pointing to footnote arg, at buffer location locn." | 487 | "Insert a marker pointing to footnote ARG, at buffer location LOCN." |
| 467 | (let ((marker (make-marker))) | 488 | (let ((marker (make-marker))) |
| 468 | (unless (assq arg footnote-text-marker-alist) | 489 | (unless (assq arg footnote-text-marker-alist) |
| 469 | (set-marker marker locn) | 490 | (set-marker marker locn) |
| @@ -473,7 +494,7 @@ styles." | |||
| 473 | (Footnote-sort footnote-text-marker-alist))))) | 494 | (Footnote-sort footnote-text-marker-alist))))) |
| 474 | 495 | ||
| 475 | (defun Footnote-insert-pointer-marker (arg locn) | 496 | (defun Footnote-insert-pointer-marker (arg locn) |
| 476 | "Insert a marker pointing to footnote arg, at buffer location locn." | 497 | "Insert a marker pointing to footnote ARG, at buffer location LOCN." |
| 477 | (let ((marker (make-marker)) | 498 | (let ((marker (make-marker)) |
| 478 | alist) | 499 | alist) |
| 479 | (set-marker marker locn) | 500 | (set-marker marker locn) |
| @@ -486,12 +507,16 @@ styles." | |||
| 486 | (Footnote-sort footnote-pointer-marker-alist))))) | 507 | (Footnote-sort footnote-pointer-marker-alist))))) |
| 487 | 508 | ||
| 488 | (defun Footnote-insert-footnote (arg) | 509 | (defun Footnote-insert-footnote (arg) |
| 489 | "Insert a footnote numbered arg, at (point)." | 510 | "Insert a footnote numbered ARG, at (point)." |
| 490 | (push-mark) | 511 | (push-mark) |
| 491 | (Footnote-insert-pointer-marker arg (point)) | 512 | (Footnote-insert-pointer-marker arg (point)) |
| 492 | (Footnote-insert-numbered-footnote arg t) | 513 | (Footnote-insert-numbered-footnote arg t) |
| 493 | (Footnote-goto-char-point-max) | 514 | (Footnote-goto-char-point-max) |
| 494 | (if (re-search-backward (concat "^" footnote-section-tag-regexp) nil t) | 515 | (if (cond |
| 516 | ((not (string-equal footnote-section-tag "")) | ||
| 517 | (re-search-backward (concat "^" footnote-section-tag-regexp) nil t)) | ||
| 518 | (footnote-text-marker-alist | ||
| 519 | (goto-char (cdar footnote-text-marker-alist)))) | ||
| 495 | (save-restriction | 520 | (save-restriction |
| 496 | (when footnote-narrow-to-footnotes-when-editing | 521 | (when footnote-narrow-to-footnotes-when-editing |
| 497 | (Footnote-narrow-to-footnotes)) | 522 | (Footnote-narrow-to-footnotes)) |
| @@ -509,12 +534,18 @@ styles." | |||
| 509 | nil t) | 534 | nil t) |
| 510 | (unless (beginning-of-line) t)) | 535 | (unless (beginning-of-line) t)) |
| 511 | (Footnote-goto-char-point-max) | 536 | (Footnote-goto-char-point-max) |
| 512 | (re-search-backward (concat "^" footnote-section-tag-regexp) nil t)))) | 537 | (cond |
| 538 | ((not (string-equal footnote-section-tag "")) | ||
| 539 | (re-search-backward | ||
| 540 | (concat "^" footnote-section-tag-regexp) nil t)) | ||
| 541 | (footnote-text-marker-alist | ||
| 542 | (goto-char (cdar footnote-text-marker-alist))))))) | ||
| 513 | (unless (looking-at "^$") | 543 | (unless (looking-at "^$") |
| 514 | (insert "\n")) | 544 | (insert "\n")) |
| 515 | (when (eobp) | 545 | (when (eobp) |
| 516 | (insert "\n")) | 546 | (insert "\n")) |
| 517 | (insert footnote-section-tag "\n")) | 547 | (unless (string-equal footnote-section-tag "") |
| 548 | (insert footnote-section-tag "\n"))) | ||
| 518 | (let ((old-point (point))) | 549 | (let ((old-point (point))) |
| 519 | (Footnote-insert-numbered-footnote arg nil) | 550 | (Footnote-insert-numbered-footnote arg nil) |
| 520 | (Footnote-insert-text-marker arg old-point))) | 551 | (Footnote-insert-text-marker arg old-point))) |
| @@ -608,7 +639,7 @@ by using `Footnote-back-to-message'." | |||
| 608 | 639 | ||
| 609 | (defun Footnote-delete-footnote (&optional arg) | 640 | (defun Footnote-delete-footnote (&optional arg) |
| 610 | "Delete a numbered footnote. | 641 | "Delete a numbered footnote. |
| 611 | With no parameter, delete the footnote under (point). With arg specified, | 642 | With no parameter, delete the footnote under (point). With ARG specified, |
| 612 | delete the footnote with that number." | 643 | delete the footnote with that number." |
| 613 | (interactive "*P") | 644 | (interactive "*P") |
| 614 | (unless arg | 645 | (unless arg |
| @@ -625,13 +656,22 @@ delete the footnote with that number." | |||
| 625 | (while (car locn) | 656 | (while (car locn) |
| 626 | (save-excursion | 657 | (save-excursion |
| 627 | (goto-char (car locn)) | 658 | (goto-char (car locn)) |
| 628 | (let* ((end (point)) | 659 | (when (looking-back (concat (regexp-quote footnote-start-tag) |
| 629 | (start (search-backward footnote-start-tag nil t))) | 660 | (Footnote-current-regexp) |
| 630 | (kill-region start end))) | 661 | (regexp-quote footnote-end-tag)) |
| 662 | (line-beginning-position)) | ||
| 663 | (delete-region (match-beginning 0) (match-end 0)))) | ||
| 631 | (setq locn (cdr locn))) | 664 | (setq locn (cdr locn))) |
| 632 | (save-excursion | 665 | (save-excursion |
| 633 | (goto-char (cdr alist-txt)) | 666 | (goto-char (cdr alist-txt)) |
| 634 | (kill-region (point) (search-forward "\n\n" nil t))) | 667 | (delete-region |
| 668 | (point) | ||
| 669 | (if footnote-spaced-footnotes | ||
| 670 | (search-forward "\n\n" nil t) | ||
| 671 | (save-restriction | ||
| 672 | (end-of-line) | ||
| 673 | (next-single-char-property-change | ||
| 674 | (point) 'footnote-number nil (Footnote-goto-char-point-max)))))) | ||
| 635 | (setq footnote-pointer-marker-alist | 675 | (setq footnote-pointer-marker-alist |
| 636 | (delq alist-ptr footnote-pointer-marker-alist)) | 676 | (delq alist-ptr footnote-pointer-marker-alist)) |
| 637 | (setq footnote-text-marker-alist | 677 | (setq footnote-text-marker-alist |
| @@ -640,16 +680,20 @@ delete the footnote with that number." | |||
| 640 | (when (and (null footnote-text-marker-alist) | 680 | (when (and (null footnote-text-marker-alist) |
| 641 | (null footnote-pointer-marker-alist)) | 681 | (null footnote-pointer-marker-alist)) |
| 642 | (save-excursion | 682 | (save-excursion |
| 643 | (let* ((end (Footnote-goto-char-point-max)) | 683 | (if (not (string-equal footnote-section-tag "")) |
| 644 | (start (1- (re-search-backward | 684 | (let* ((end (Footnote-goto-char-point-max)) |
| 645 | (concat "^" footnote-section-tag-regexp) | 685 | (start (1- (re-search-backward |
| 646 | nil t)))) | 686 | (concat "^" footnote-section-tag-regexp) |
| 647 | (forward-line -1) | 687 | nil t)))) |
| 648 | (when (looking-at "\n") | 688 | (forward-line -1) |
| 649 | (kill-line)) | 689 | (when (looking-at "\n") |
| 650 | (kill-region start (if (< end (point-max)) | 690 | (kill-line)) |
| 651 | end | 691 | (delete-region start (if (< end (point-max)) |
| 652 | (point-max))))))))) | 692 | end |
| 693 | (point-max)))) | ||
| 694 | (Footnote-goto-char-point-max) | ||
| 695 | (when (looking-back "\n\n") | ||
| 696 | (kill-line -1)))))))) | ||
| 653 | 697 | ||
| 654 | (defun Footnote-renumber-footnotes (&optional arg) | 698 | (defun Footnote-renumber-footnotes (&optional arg) |
| 655 | "Renumber footnotes, starting from 1." | 699 | "Renumber footnotes, starting from 1." |
| @@ -667,22 +711,25 @@ delete the footnote with that number." | |||
| 667 | 711 | ||
| 668 | (defun Footnote-goto-footnote (&optional arg) | 712 | (defun Footnote-goto-footnote (&optional arg) |
| 669 | "Jump to the text of a footnote. | 713 | "Jump to the text of a footnote. |
| 670 | With no parameter, jump to the text of the footnote under (point). With arg | 714 | With no parameter, jump to the text of the footnote under (point). With ARG |
| 671 | specified, jump to the text of that footnote." | 715 | specified, jump to the text of that footnote." |
| 672 | (interactive "P") | 716 | (interactive "P") |
| 673 | (let (footnote) | 717 | (unless arg |
| 674 | (if arg | 718 | (setq arg (Footnote-under-cursor))) |
| 675 | (setq footnote (assq arg footnote-text-marker-alist)) | 719 | (let ((footnote (assq arg footnote-text-marker-alist))) |
| 676 | (when (setq arg (Footnote-under-cursor)) | 720 | (cond |
| 677 | (setq footnote (assq arg footnote-text-marker-alist)))) | 721 | (footnote |
| 678 | (if footnote | 722 | (goto-char (cdr footnote))) |
| 679 | (goto-char (cdr footnote)) | 723 | ((eq arg 0) |
| 680 | (if (eq arg 0) | 724 | (goto-char (point-max)) |
| 681 | (progn | 725 | (cond |
| 682 | (goto-char (point-max)) | 726 | ((not (string-equal footnote-section-tag "")) |
| 683 | (re-search-backward (concat "^" footnote-section-tag-regexp)) | 727 | (re-search-backward (concat "^" footnote-section-tag-regexp)) |
| 684 | (forward-line 1)) | 728 | (forward-line 1)) |
| 685 | (error "I don't see a footnote here"))))) | 729 | (footnote-text-marker-alist |
| 730 | (goto-char (cdar footnote-text-marker-alist))))) | ||
| 731 | (t | ||
| 732 | (error "I don't see a footnote here"))))) | ||
| 686 | 733 | ||
| 687 | (defun Footnote-back-to-message (&optional arg) | 734 | (defun Footnote-back-to-message (&optional arg) |
| 688 | "Move cursor back to footnote referent. | 735 | "Move cursor back to footnote referent. |
| @@ -723,12 +770,13 @@ being set it is automatically widened." | |||
| 723 | key binding | 770 | key binding |
| 724 | --- ------- | 771 | --- ------- |
| 725 | 772 | ||
| 726 | \\[Footnote-renumber-footnotes] Footnote-renumber-footnotes | 773 | \\[Footnote-add-footnote] Footnote-add-footnote |
| 727 | \\[Footnote-goto-footnote] Footnote-goto-footnote | 774 | \\[Footnote-back-to-message] Footnote-back-to-message |
| 728 | \\[Footnote-delete-footnote] Footnote-delete-footnote | 775 | \\[Footnote-delete-footnote] Footnote-delete-footnote |
| 776 | \\[Footnote-goto-footnote] Footnote-goto-footnote | ||
| 777 | \\[Footnote-renumber-footnotes] Footnote-renumber-footnotes | ||
| 729 | \\[Footnote-cycle-style] Footnote-cycle-style | 778 | \\[Footnote-cycle-style] Footnote-cycle-style |
| 730 | \\[Footnote-back-to-message] Footnote-back-to-message | 779 | \\[Footnote-set-style] Footnote-set-style |
| 731 | \\[Footnote-add-footnote] Footnote-add-footnote | ||
| 732 | " | 780 | " |
| 733 | (interactive "*P") | 781 | (interactive "*P") |
| 734 | ;; (filladapt-mode t) | 782 | ;; (filladapt-mode t) |
| @@ -738,6 +786,12 @@ key binding | |||
| 738 | (when footnote-mode | 786 | (when footnote-mode |
| 739 | ;; (Footnote-setup-keybindings) | 787 | ;; (Footnote-setup-keybindings) |
| 740 | (make-local-variable 'footnote-style) | 788 | (make-local-variable 'footnote-style) |
| 789 | (make-local-variable 'footnote-body-tag-spacing) | ||
| 790 | (make-local-variable 'footnote-spaced-footnotes) | ||
| 791 | (make-local-variable 'footnote-section-tag) | ||
| 792 | (make-local-variable 'footnote-section-tag-regexp) | ||
| 793 | (make-local-variable 'footnote-start-tag) | ||
| 794 | (make-local-variable 'footnote-end-tag) | ||
| 741 | (if (fboundp 'force-mode-line-update) | 795 | (if (fboundp 'force-mode-line-update) |
| 742 | (force-mode-line-update) | 796 | (force-mode-line-update) |
| 743 | (set-buffer-modified-p (buffer-modified-p))) | 797 | (set-buffer-modified-p (buffer-modified-p))) |