diff options
| author | Boruch Baum | 2017-12-25 23:27:26 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2017-12-25 23:27:26 -0500 |
| commit | b7123e2a451961970c1a71c734f3ce607665ae6c (patch) | |
| tree | 204c7cb5c7acfee605955ddf0b8c7672a5b90b6e | |
| parent | cd1d9e79f74f137511d49eb9b0ae7ba750ba6c3c (diff) | |
| download | emacs-b7123e2a451961970c1a71c734f3ce607665ae6c.tar.gz emacs-b7123e2a451961970c1a71c734f3ce607665ae6c.zip | |
* lisp/mail/footnote.el: Replace "Footnote-" prefix with "footnote--"
(footnote-section-tag): Remove trailing space.
| -rw-r--r-- | lisp/mail/footnote.el | 259 |
1 files changed, 128 insertions, 131 deletions
diff --git a/lisp/mail/footnote.el b/lisp/mail/footnote.el index adfe03d3061..795b89649ed 100644 --- a/lisp/mail/footnote.el +++ b/lisp/mail/footnote.el | |||
| @@ -2,8 +2,8 @@ | |||
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1997, 2000-2017 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1997, 2000-2017 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: Steven L Baur <steve@xemacs.org> | 5 | ;; Author: Steven L Baur <steve@xemacs.org> (1997-) |
| 6 | ;; Boruch Baum <boruch_baum@gmx.com> | 6 | ;; Boruch Baum <boruch_baum@gmx.com> (2017-) |
| 7 | ;; Keywords: mail, news | 7 | ;; Keywords: mail, news |
| 8 | ;; Version: 0.19 | 8 | ;; Version: 0.19 |
| 9 | 9 | ||
| @@ -120,12 +120,13 @@ After that, changing the prefix key requires manipulating keymaps." | |||
| 120 | 120 | ||
| 121 | ;;; Interface variables that probably shouldn't be changed | 121 | ;;; Interface variables that probably shouldn't be changed |
| 122 | 122 | ||
| 123 | (defcustom footnote-section-tag "Footnotes: " | 123 | (defcustom footnote-section-tag "Footnotes:" |
| 124 | "Tag inserted at beginning of footnote section. | 124 | "Tag inserted at beginning of footnote section. |
| 125 | If you set this to the empty string, no tag is inserted and the | 125 | If you set this to the empty string, no tag is inserted and the |
| 126 | value of `footnote-section-tag-regexp' is ignored. Customizing | 126 | value of `footnote-section-tag-regexp' is ignored. Customizing |
| 127 | this variable has no effect on buffers already displaying | 127 | this variable has no effect on buffers already displaying |
| 128 | footnotes." | 128 | footnotes." |
| 129 | :version "27.1" | ||
| 129 | :type 'string | 130 | :type 'string |
| 130 | :group 'footnote) | 131 | :group 'footnote) |
| 131 | 132 | ||
| @@ -165,10 +166,10 @@ has no effect on buffers already displaying footnotes." | |||
| 165 | :group 'footnote) | 166 | :group 'footnote) |
| 166 | 167 | ||
| 167 | (defcustom footnote-align-to-fn-text t | 168 | (defcustom footnote-align-to-fn-text t |
| 168 | "If non-nil, align footnote text lines. | 169 | "How to left-align footnote text. |
| 169 | If nil, footnote text lines are to be aligned flush left with left side | 170 | If nil, footnote text is to be aligned flush left with left side |
| 170 | of the footnote number. If non-nil footnote text lines are to be aligned | 171 | of the footnote number. If non-nil, footnote text is to be aligned |
| 171 | with the first character of footnote text." | 172 | left with the first character of footnote text." |
| 172 | :type 'boolean) | 173 | :type 'boolean) |
| 173 | 174 | ||
| 174 | ;;; Private variables | 175 | ;;; Private variables |
| @@ -195,7 +196,7 @@ with the first character of footnote text." | |||
| 195 | (defconst footnote-numeric-regexp "[0-9]+" | 196 | (defconst footnote-numeric-regexp "[0-9]+" |
| 196 | "Regexp for digits.") | 197 | "Regexp for digits.") |
| 197 | 198 | ||
| 198 | (defun Footnote-numeric (n) | 199 | (defun footnote--numeric (n) |
| 199 | "Numeric footnote style. | 200 | "Numeric footnote style. |
| 200 | Use Arabic numerals for footnoting." | 201 | Use Arabic numerals for footnoting." |
| 201 | (int-to-string n)) | 202 | (int-to-string n)) |
| @@ -207,7 +208,7 @@ Use Arabic numerals for footnoting." | |||
| 207 | (defconst footnote-english-upper-regexp "[A-Z]+" | 208 | (defconst footnote-english-upper-regexp "[A-Z]+" |
| 208 | "Regexp for upper case English alphabet.") | 209 | "Regexp for upper case English alphabet.") |
| 209 | 210 | ||
| 210 | (defun Footnote-english-upper (n) | 211 | (defun footnote--english-upper (n) |
| 211 | "Upper case English footnoting. | 212 | "Upper case English footnoting. |
| 212 | Wrapping around the alphabet implies successive repetitions of letters." | 213 | Wrapping around the alphabet implies successive repetitions of letters." |
| 213 | (let* ((ltr (mod (1- n) (length footnote-english-upper))) | 214 | (let* ((ltr (mod (1- n) (length footnote-english-upper))) |
| @@ -226,7 +227,7 @@ Wrapping around the alphabet implies successive repetitions of letters." | |||
| 226 | (defconst footnote-english-lower-regexp "[a-z]+" | 227 | (defconst footnote-english-lower-regexp "[a-z]+" |
| 227 | "Regexp of lower case English alphabet.") | 228 | "Regexp of lower case English alphabet.") |
| 228 | 229 | ||
| 229 | (defun Footnote-english-lower (n) | 230 | (defun footnote--english-lower (n) |
| 230 | "Lower case English footnoting. | 231 | "Lower case English footnoting. |
| 231 | Wrapping around the alphabet implies successive repetitions of letters." | 232 | Wrapping around the alphabet implies successive repetitions of letters." |
| 232 | (let* ((ltr (mod (1- n) (length footnote-english-lower))) | 233 | (let* ((ltr (mod (1- n) (length footnote-english-lower))) |
| @@ -247,9 +248,9 @@ Wrapping around the alphabet implies successive repetitions of letters." | |||
| 247 | (defconst footnote-roman-lower-regexp "[ivxlcdm]+" | 248 | (defconst footnote-roman-lower-regexp "[ivxlcdm]+" |
| 248 | "Regexp of roman numerals.") | 249 | "Regexp of roman numerals.") |
| 249 | 250 | ||
| 250 | (defun Footnote-roman-lower (n) | 251 | (defun footnote--roman-lower (n) |
| 251 | "Generic Roman number footnoting." | 252 | "Generic Roman number footnoting." |
| 252 | (Footnote-roman-common n footnote-roman-lower-list)) | 253 | (footnote--roman-common n footnote-roman-lower-list)) |
| 253 | 254 | ||
| 254 | ;;; ROMAN UPPER | 255 | ;;; ROMAN UPPER |
| 255 | (defconst footnote-roman-upper-list | 256 | (defconst footnote-roman-upper-list |
| @@ -260,11 +261,11 @@ Wrapping around the alphabet implies successive repetitions of letters." | |||
| 260 | (defconst footnote-roman-upper-regexp "[IVXLCDM]+" | 261 | (defconst footnote-roman-upper-regexp "[IVXLCDM]+" |
| 261 | "Regexp of roman numerals. Not complete") | 262 | "Regexp of roman numerals. Not complete") |
| 262 | 263 | ||
| 263 | (defun Footnote-roman-upper (n) | 264 | (defun footnote--roman-upper (n) |
| 264 | "Generic Roman number footnoting." | 265 | "Generic Roman number footnoting." |
| 265 | (Footnote-roman-common n footnote-roman-upper-list)) | 266 | (footnote--roman-common n footnote-roman-upper-list)) |
| 266 | 267 | ||
| 267 | (defun Footnote-roman-common (n footnote-roman-list) | 268 | (defun footnote--roman-common (n footnote-roman-list) |
| 268 | "Lower case Roman footnoting." | 269 | "Lower case Roman footnoting." |
| 269 | (let* ((our-list footnote-roman-list) | 270 | (let* ((our-list footnote-roman-list) |
| 270 | (rom-lngth (length our-list)) | 271 | (rom-lngth (length our-list)) |
| @@ -299,22 +300,22 @@ Wrapping around the alphabet implies successive repetitions of letters." | |||
| 299 | ;; (message "pairs are: rom-low: %S, rom-high: %S, rom-div: %S" | 300 | ;; (message "pairs are: rom-low: %S, rom-high: %S, rom-div: %S" |
| 300 | ;; rom-low-pair rom-high-pair rom-div-pair) | 301 | ;; rom-low-pair rom-high-pair rom-div-pair) |
| 301 | (cond | 302 | (cond |
| 302 | ((< n 0) (error "Footnote-roman-common called with n < 0")) | 303 | ((< n 0) (error "footnote--roman-common called with n < 0")) |
| 303 | ((= n 0) "") | 304 | ((= n 0) "") |
| 304 | ((= n (car rom-low-pair)) (cdr rom-low-pair)) | 305 | ((= n (car rom-low-pair)) (cdr rom-low-pair)) |
| 305 | ((= n (car rom-high-pair)) (cdr rom-high-pair)) | 306 | ((= n (car rom-high-pair)) (cdr rom-high-pair)) |
| 306 | ((= (car rom-low-pair) (car rom-high-pair)) | 307 | ((= (car rom-low-pair) (car rom-high-pair)) |
| 307 | (concat (cdr rom-low-pair) | 308 | (concat (cdr rom-low-pair) |
| 308 | (Footnote-roman-common | 309 | (footnote--roman-common |
| 309 | (- n (car rom-low-pair)) | 310 | (- n (car rom-low-pair)) |
| 310 | footnote-roman-list))) | 311 | footnote-roman-list))) |
| 311 | ((>= rom-div 0) (concat (cdr rom-div-pair) (cdr rom-high-pair) | 312 | ((>= rom-div 0) (concat (cdr rom-div-pair) (cdr rom-high-pair) |
| 312 | (Footnote-roman-common | 313 | (footnote--roman-common |
| 313 | (- n (- (car rom-high-pair) | 314 | (- n (- (car rom-high-pair) |
| 314 | (car rom-div-pair))) | 315 | (car rom-div-pair))) |
| 315 | footnote-roman-list))) | 316 | footnote-roman-list))) |
| 316 | (t (concat (cdr rom-low-pair) | 317 | (t (concat (cdr rom-low-pair) |
| 317 | (Footnote-roman-common | 318 | (footnote--roman-common |
| 318 | (- n (car rom-low-pair)) | 319 | (- n (car rom-low-pair)) |
| 319 | footnote-roman-list))))))) | 320 | footnote-roman-list))))))) |
| 320 | 321 | ||
| @@ -327,7 +328,7 @@ Wrapping around the alphabet implies successive repetitions of letters." | |||
| 327 | (defconst footnote-latin-regexp (concat "[" footnote-latin-string "]") | 328 | (defconst footnote-latin-regexp (concat "[" footnote-latin-string "]") |
| 328 | "Regexp for Latin-1 footnoting characters.") | 329 | "Regexp for Latin-1 footnoting characters.") |
| 329 | 330 | ||
| 330 | (defun Footnote-latin (n) | 331 | (defun footnote--latin (n) |
| 331 | "Latin-1 footnote style. | 332 | "Latin-1 footnote style. |
| 332 | Use a range of Latin-1 non-ASCII characters for footnoting." | 333 | Use a range of Latin-1 non-ASCII characters for footnoting." |
| 333 | (string (aref footnote-latin-string | 334 | (string (aref footnote-latin-string |
| @@ -341,7 +342,7 @@ Use a range of Latin-1 non-ASCII characters for footnoting." | |||
| 341 | (defconst footnote-unicode-regexp (concat "[" footnote-unicode-string "]+") | 342 | (defconst footnote-unicode-regexp (concat "[" footnote-unicode-string "]+") |
| 342 | "Regexp for Unicode footnoting characters.") | 343 | "Regexp for Unicode footnoting characters.") |
| 343 | 344 | ||
| 344 | (defun Footnote-unicode (n) | 345 | (defun footnote--unicode (n) |
| 345 | "Unicode footnote style. | 346 | "Unicode footnote style. |
| 346 | Use Unicode characters for footnoting." | 347 | Use Unicode characters for footnoting." |
| 347 | (let (modulus result done) | 348 | (let (modulus result done) |
| @@ -363,7 +364,7 @@ Use Unicode characters for footnoting." | |||
| 363 | ("י" "כ" "ל" "מ" "נ" "ס" "ע" "פ" "צ") | 364 | ("י" "כ" "ל" "מ" "נ" "ס" "ע" "פ" "צ") |
| 364 | ("ק" "ר" "ש" "ת" "תק" "תר"" תש" "תת" "תתק"))) | 365 | ("ק" "ר" "ש" "ת" "תק" "תר"" תש" "תת" "תתק"))) |
| 365 | 366 | ||
| 366 | (defun Footnote-hebrew-numeric (n) | 367 | (defun footnote--hebrew-numeric (n) |
| 367 | "Supports 9999 footnotes, then rolls over." | 368 | "Supports 9999 footnotes, then rolls over." |
| 368 | (let* ((n (+ (mod n 10000) (/ n 10000))) | 369 | (let* ((n (+ (mod n 10000) (/ n 10000))) |
| 369 | (thousands (/ n 1000)) | 370 | (thousands (/ n 1000)) |
| @@ -389,22 +390,22 @@ Use Unicode characters for footnoting." | |||
| 389 | '( | 390 | '( |
| 390 | "א" "ב" "ג" "ד" "ה" "ו" "ז" "ח" "ט" "י" "כ" "ל" "מ" "נ" "ס" "ע" "פ" "צ" "ק" "ר" "ש" "ת")) | 391 | "א" "ב" "ג" "ד" "ה" "ו" "ז" "ח" "ט" "י" "כ" "ל" "מ" "נ" "ס" "ע" "פ" "צ" "ק" "ר" "ש" "ת")) |
| 391 | 392 | ||
| 392 | (defun Footnote-hebrew-symbolic (n) | 393 | (defun footnote--hebrew-symbolic (n) |
| 393 | "Only 22 elements, per the style of eg. 'פירוש שפתי חכמים על רש״י'. | 394 | "Only 22 elements, per the style of eg. 'פירוש שפתי חכמים על רש״י'. |
| 394 | Proceeds from `י' to `כ', from `צ' to `ק'. After `ת', rolls over to `א'." | 395 | Proceeds from `י' to `כ', from `צ' to `ק'. After `ת', rolls over to `א'." |
| 395 | (nth (mod (1- n) 22) footnote-hebrew-symbolic)) | 396 | (nth (mod (1- n) 22) footnote-hebrew-symbolic)) |
| 396 | 397 | ||
| 397 | ;;; list of all footnote styles | 398 | ;;; list of all footnote styles |
| 398 | (defvar footnote-style-alist | 399 | (defvar footnote-style-alist |
| 399 | `((numeric Footnote-numeric ,footnote-numeric-regexp) | 400 | `((numeric footnote--numeric ,footnote-numeric-regexp) |
| 400 | (english-lower Footnote-english-lower ,footnote-english-lower-regexp) | 401 | (english-lower footnote--english-lower ,footnote-english-lower-regexp) |
| 401 | (english-upper Footnote-english-upper ,footnote-english-upper-regexp) | 402 | (english-upper footnote--english-upper ,footnote-english-upper-regexp) |
| 402 | (roman-lower Footnote-roman-lower ,footnote-roman-lower-regexp) | 403 | (roman-lower footnote--roman-lower ,footnote-roman-lower-regexp) |
| 403 | (roman-upper Footnote-roman-upper ,footnote-roman-upper-regexp) | 404 | (roman-upper footnote--roman-upper ,footnote-roman-upper-regexp) |
| 404 | (latin Footnote-latin ,footnote-latin-regexp) | 405 | (latin footnote--latin ,footnote-latin-regexp) |
| 405 | (unicode Footnote-unicode ,footnote-unicode-regexp) | 406 | (unicode footnote--unicode ,footnote-unicode-regexp) |
| 406 | (hebrew-numeric Footnote-hebrew-numeric ,footnote-hebrew-numeric-regex) | 407 | (hebrew-numeric footnote--hebrew-numeric ,footnote-hebrew-numeric-regex) |
| 407 | (hebrew-symbolic Footnote-hebrew-symbolic ,footnote-hebrew-symbolic-regex)) | 408 | (hebrew-symbolic footnote--hebrew-symbolic ,footnote-hebrew-symbolic-regex)) |
| 408 | "Styles of footnote tags available. | 409 | "Styles of footnote tags available. |
| 409 | By default, Arabic numbers, English letters, Roman Numerals, | 410 | By default, Arabic numbers, English letters, Roman Numerals, |
| 410 | Latin and Unicode superscript characters, and Hebrew numerals | 411 | Latin and Unicode superscript characters, and Hebrew numerals |
| @@ -428,36 +429,36 @@ properly if the default font does not contain those characters. | |||
| 428 | 429 | ||
| 429 | Customizing this variable has no effect on buffers already | 430 | Customizing this variable has no effect on buffers already |
| 430 | displaying footnotes. To change the style of footnotes in such a | 431 | displaying footnotes. To change the style of footnotes in such a |
| 431 | buffer use the command `Footnote-set-style'." | 432 | buffer use the command `footnote-set-style'." |
| 432 | :type (cons 'choice (mapcar (lambda (x) (list 'const (car x))) | 433 | :type (cons 'choice (mapcar (lambda (x) (list 'const (car x))) |
| 433 | footnote-style-alist)) | 434 | footnote-style-alist)) |
| 434 | :group 'footnote) | 435 | :group 'footnote) |
| 435 | 436 | ||
| 436 | ;;; Style utilities & functions | 437 | ;;; Style utilities & functions |
| 437 | (defun Footnote-style-p (style) | 438 | (defun footnote--style-p (style) |
| 438 | "Return non-nil if style is a valid style known to `footnote-mode'." | 439 | "Return non-nil if style is a valid style known to `footnote-mode'." |
| 439 | (assq style footnote-style-alist)) | 440 | (assq style footnote-style-alist)) |
| 440 | 441 | ||
| 441 | (defun Footnote-index-to-string (index) | 442 | (defun footnote--index-to-string (index) |
| 442 | "Convert a binary index into a string to display as a footnote. | 443 | "Convert a binary index into a string to display as a footnote. |
| 443 | Conversion is done based upon the current selected style." | 444 | Conversion is done based upon the current selected style." |
| 444 | (let ((alist (if (Footnote-style-p footnote-style) | 445 | (let ((alist (if (footnote--style-p footnote-style) |
| 445 | (assq footnote-style footnote-style-alist) | 446 | (assq footnote-style footnote-style-alist) |
| 446 | (nth 0 footnote-style-alist)))) | 447 | (nth 0 footnote-style-alist)))) |
| 447 | (funcall (nth 1 alist) index))) | 448 | (funcall (nth 1 alist) index))) |
| 448 | 449 | ||
| 449 | (defun Footnote-current-regexp () | 450 | (defun footnote--current-regexp () |
| 450 | "Return the regexp of the index of the current style." | 451 | "Return the regexp of the index of the current style." |
| 451 | (concat (nth 2 (or (assq footnote-style footnote-style-alist) | 452 | (concat (nth 2 (or (assq footnote-style footnote-style-alist) |
| 452 | (nth 0 footnote-style-alist))) | 453 | (nth 0 footnote-style-alist))) |
| 453 | "*")) | 454 | "*")) |
| 454 | 455 | ||
| 455 | (defun Footnote-refresh-footnotes (&optional index-regexp) | 456 | (defun footnote--refresh-footnotes (&optional index-regexp) |
| 456 | "Redraw all footnotes. | 457 | "Redraw all footnotes. |
| 457 | You must call this or arrange to have this called after changing footnote | 458 | You must call this or arrange to have this called after changing footnote |
| 458 | styles." | 459 | styles." |
| 459 | (unless index-regexp | 460 | (unless index-regexp |
| 460 | (setq index-regexp (Footnote-current-regexp))) | 461 | (setq index-regexp (footnote--current-regexp))) |
| 461 | (save-excursion | 462 | (save-excursion |
| 462 | ;; Take care of the pointers first | 463 | ;; Take care of the pointers first |
| 463 | (let ((i 0) locn alist) | 464 | (let ((i 0) locn alist) |
| @@ -476,7 +477,7 @@ styles." | |||
| 476 | (propertize | 477 | (propertize |
| 477 | (concat | 478 | (concat |
| 478 | footnote-start-tag | 479 | footnote-start-tag |
| 479 | (Footnote-index-to-string (1+ i)) | 480 | (footnote--index-to-string (1+ i)) |
| 480 | footnote-end-tag) | 481 | footnote-end-tag) |
| 481 | 'footnote-number (1+ i) footnote-mouse-highlight t) | 482 | 'footnote-number (1+ i) footnote-mouse-highlight t) |
| 482 | nil "\\1")) | 483 | nil "\\1")) |
| @@ -495,13 +496,13 @@ styles." | |||
| 495 | (propertize | 496 | (propertize |
| 496 | (concat | 497 | (concat |
| 497 | footnote-start-tag | 498 | footnote-start-tag |
| 498 | (Footnote-index-to-string (1+ i)) | 499 | (footnote--index-to-string (1+ i)) |
| 499 | footnote-end-tag) | 500 | footnote-end-tag) |
| 500 | 'footnote-number (1+ i)) | 501 | 'footnote-number (1+ i)) |
| 501 | nil "\\1")) | 502 | nil "\\1")) |
| 502 | (setq i (1+ i)))))) | 503 | (setq i (1+ i)))))) |
| 503 | 504 | ||
| 504 | (defun Footnote-assoc-index (key alist) | 505 | (defun footnote--assoc-index (key alist) |
| 505 | "Give index of key in alist." | 506 | "Give index of key in alist." |
| 506 | (let ((i 0) (max (length alist)) rc) | 507 | (let ((i 0) (max (length alist)) rc) |
| 507 | (while (and (null rc) | 508 | (while (and (null rc) |
| @@ -511,33 +512,33 @@ styles." | |||
| 511 | (setq i (1+ i))) | 512 | (setq i (1+ i))) |
| 512 | rc)) | 513 | rc)) |
| 513 | 514 | ||
| 514 | (defun Footnote-cycle-style () | 515 | (defun footnote-cycle-style () |
| 515 | "Select next defined footnote style." | 516 | "Select next defined footnote style." |
| 516 | (interactive) | 517 | (interactive) |
| 517 | (let ((old (Footnote-assoc-index footnote-style footnote-style-alist)) | 518 | (let ((old (footnote--assoc-index footnote-style footnote-style-alist)) |
| 518 | (max (length footnote-style-alist)) | 519 | (max (length footnote-style-alist)) |
| 519 | idx) | 520 | idx) |
| 520 | (setq idx (1+ old)) | 521 | (setq idx (1+ old)) |
| 521 | (when (>= idx max) | 522 | (when (>= idx max) |
| 522 | (setq idx 0)) | 523 | (setq idx 0)) |
| 523 | (setq footnote-style (car (nth idx footnote-style-alist))) | 524 | (setq footnote-style (car (nth idx footnote-style-alist))) |
| 524 | (Footnote-refresh-footnotes (nth 2 (nth old footnote-style-alist))))) | 525 | (footnote--refresh-footnotes (nth 2 (nth old footnote-style-alist))))) |
| 525 | 526 | ||
| 526 | (defun Footnote-set-style (&optional style) | 527 | (defun footnote-set-style (&optional style) |
| 527 | "Select a specific style." | 528 | "Select a specific style." |
| 528 | (interactive | 529 | (interactive |
| 529 | (list (intern (completing-read | 530 | (list (intern (completing-read |
| 530 | "Footnote Style: " | 531 | "Footnote Style: " |
| 531 | obarray #'Footnote-style-p 'require-match)))) | 532 | obarray #'footnote--style-p 'require-match)))) |
| 532 | (let ((old (Footnote-assoc-index footnote-style footnote-style-alist))) | 533 | (let ((old (footnote--assoc-index footnote-style footnote-style-alist))) |
| 533 | (setq footnote-style style) | 534 | (setq footnote-style style) |
| 534 | (Footnote-refresh-footnotes (nth 2 (nth old footnote-style-alist))))) | 535 | (footnote--refresh-footnotes (nth 2 (nth old footnote-style-alist))))) |
| 535 | 536 | ||
| 536 | ;; Internal functions | 537 | ;; Internal functions |
| 537 | (defun Footnote-insert-numbered-footnote (arg &optional mousable) | 538 | (defun footnote--insert-numbered-footnote (arg &optional mousable) |
| 538 | "Insert numbered footnote at (point)." | 539 | "Insert numbered footnote at (point)." |
| 539 | (let ((string (concat footnote-start-tag | 540 | (let ((string (concat footnote-start-tag |
| 540 | (Footnote-index-to-string arg) | 541 | (footnote--index-to-string arg) |
| 541 | footnote-end-tag))) | 542 | footnote-end-tag))) |
| 542 | (insert-before-markers | 543 | (insert-before-markers |
| 543 | (if mousable | 544 | (if mousable |
| @@ -545,7 +546,7 @@ styles." | |||
| 545 | string 'footnote-number arg footnote-mouse-highlight t) | 546 | string 'footnote-number arg footnote-mouse-highlight t) |
| 546 | (propertize string 'footnote-number arg))))) | 547 | (propertize string 'footnote-number arg))))) |
| 547 | 548 | ||
| 548 | (defun Footnote-renumber (from to pointer-alist text-alist) | 549 | (defun footnote--renumber (from to pointer-alist text-alist) |
| 549 | "Renumber a single footnote." | 550 | "Renumber a single footnote." |
| 550 | (let* ((posn-list (cdr pointer-alist))) | 551 | (let* ((posn-list (cdr pointer-alist))) |
| 551 | (setcar pointer-alist to) | 552 | (setcar pointer-alist to) |
| @@ -553,44 +554,40 @@ styles." | |||
| 553 | (while posn-list | 554 | (while posn-list |
| 554 | (goto-char (car posn-list)) | 555 | (goto-char (car posn-list)) |
| 555 | (when (looking-back (concat (regexp-quote footnote-start-tag) | 556 | (when (looking-back (concat (regexp-quote footnote-start-tag) |
| 556 | (Footnote-current-regexp) | 557 | (footnote--current-regexp) |
| 557 | (regexp-quote footnote-end-tag)) | 558 | (regexp-quote footnote-end-tag)) |
| 558 | (line-beginning-position)) | 559 | (line-beginning-position)) |
| 559 | (replace-match | 560 | (replace-match |
| 560 | (propertize | 561 | (propertize |
| 561 | (concat footnote-start-tag | 562 | (concat footnote-start-tag |
| 562 | (Footnote-index-to-string to) | 563 | (footnote--index-to-string to) |
| 563 | footnote-end-tag) | 564 | footnote-end-tag) |
| 564 | 'footnote-number to footnote-mouse-highlight t))) | 565 | 'footnote-number to footnote-mouse-highlight t))) |
| 565 | (setq posn-list (cdr posn-list))) | 566 | (setq posn-list (cdr posn-list))) |
| 566 | (goto-char (cdr text-alist)) | 567 | (goto-char (cdr text-alist)) |
| 567 | (when (looking-at (concat (regexp-quote footnote-start-tag) | 568 | (when (looking-at (concat (regexp-quote footnote-start-tag) |
| 568 | (Footnote-current-regexp) | 569 | (footnote--current-regexp) |
| 569 | (regexp-quote footnote-end-tag))) | 570 | (regexp-quote footnote-end-tag))) |
| 570 | (replace-match | 571 | (replace-match |
| 571 | (propertize | 572 | (propertize |
| 572 | (concat footnote-start-tag | 573 | (concat footnote-start-tag |
| 573 | (Footnote-index-to-string to) | 574 | (footnote--index-to-string to) |
| 574 | footnote-end-tag) | 575 | footnote-end-tag) |
| 575 | 'footnote-number to))))) | 576 | 'footnote-number to))))) |
| 576 | 577 | ||
| 577 | ;; Not needed? <-- 2017-12 Boruch: Not my comment! BUT, when I | 578 | (defun footnote--narrow-to-footnotes () |
| 578 | ;; starting hacking the code, this function | ||
| 579 | ;; `Footnote-narrow-to-footnotes' was never narrowing, and the result | ||
| 580 | ;; wasn't breaking anything. | ||
| 581 | (defun Footnote-narrow-to-footnotes () | ||
| 582 | "Restrict text in buffer to show only text of footnotes." | 579 | "Restrict text in buffer to show only text of footnotes." |
| 583 | (interactive) ; testing | 580 | (interactive) ; testing |
| 584 | (narrow-to-region (Footnote--get-area-point-min) | 581 | (narrow-to-region (footnote--get-area-point-min) |
| 585 | (Footnote--get-area-point-max))) | 582 | (footnote--get-area-point-max))) |
| 586 | 583 | ||
| 587 | (defun Footnote-goto-char-point-max () | 584 | (defun footnote--goto-char-point-max () |
| 588 | "Move to end of buffer or prior to start of .signature." | 585 | "Move to end of buffer or prior to start of .signature." |
| 589 | (goto-char (point-max)) | 586 | (goto-char (point-max)) |
| 590 | (or (re-search-backward footnote-signature-separator nil t) | 587 | (or (re-search-backward footnote-signature-separator nil t) |
| 591 | (point))) | 588 | (point))) |
| 592 | 589 | ||
| 593 | (defun Footnote-insert-text-marker (arg locn) | 590 | (defun footnote--insert-text-marker (arg locn) |
| 594 | "Insert a marker pointing to footnote ARG, at buffer location LOCN." | 591 | "Insert a marker pointing to footnote ARG, at buffer location LOCN." |
| 595 | (let ((marker (make-marker))) | 592 | (let ((marker (make-marker))) |
| 596 | (unless (assq arg footnote-text-marker-alist) | 593 | (unless (assq arg footnote-text-marker-alist) |
| @@ -598,9 +595,9 @@ styles." | |||
| 598 | (setq footnote-text-marker-alist | 595 | (setq footnote-text-marker-alist |
| 599 | (cons (cons arg marker) footnote-text-marker-alist)) | 596 | (cons (cons arg marker) footnote-text-marker-alist)) |
| 600 | (setq footnote-text-marker-alist | 597 | (setq footnote-text-marker-alist |
| 601 | (Footnote-sort footnote-text-marker-alist))))) | 598 | (footnote--sort footnote-text-marker-alist))))) |
| 602 | 599 | ||
| 603 | (defun Footnote-insert-pointer-marker (arg locn) | 600 | (defun footnote--insert-pointer-marker (arg locn) |
| 604 | "Insert a marker pointing to footnote ARG, at buffer location LOCN." | 601 | "Insert a marker pointing to footnote ARG, at buffer location LOCN." |
| 605 | (let ((marker (make-marker)) | 602 | (let ((marker (make-marker)) |
| 606 | alist) | 603 | alist) |
| @@ -611,14 +608,14 @@ styles." | |||
| 611 | (setq footnote-pointer-marker-alist | 608 | (setq footnote-pointer-marker-alist |
| 612 | (cons (cons arg (list marker)) footnote-pointer-marker-alist)) | 609 | (cons (cons arg (list marker)) footnote-pointer-marker-alist)) |
| 613 | (setq footnote-pointer-marker-alist | 610 | (setq footnote-pointer-marker-alist |
| 614 | (Footnote-sort footnote-pointer-marker-alist))))) | 611 | (footnote--sort footnote-pointer-marker-alist))))) |
| 615 | 612 | ||
| 616 | (defun Footnote-insert-footnote (arg) | 613 | (defun footnote--insert-footnote (arg) |
| 617 | "Insert a footnote numbered ARG, at (point)." | 614 | "Insert a footnote numbered ARG, at (point)." |
| 618 | (push-mark) | 615 | (push-mark) |
| 619 | (Footnote-insert-pointer-marker arg (point)) | 616 | (footnote--insert-pointer-marker arg (point)) |
| 620 | (Footnote-insert-numbered-footnote arg t) | 617 | (footnote--insert-numbered-footnote arg t) |
| 621 | (Footnote-goto-char-point-max) | 618 | (footnote--goto-char-point-max) |
| 622 | (if (cond | 619 | (if (cond |
| 623 | ((not (string-equal footnote-section-tag "")) | 620 | ((not (string-equal footnote-section-tag "")) |
| 624 | (re-search-backward (concat "^" footnote-section-tag-regexp) nil t)) | 621 | (re-search-backward (concat "^" footnote-section-tag-regexp) nil t)) |
| @@ -626,8 +623,8 @@ styles." | |||
| 626 | (goto-char (cdar footnote-text-marker-alist)))) | 623 | (goto-char (cdar footnote-text-marker-alist)))) |
| 627 | (save-restriction | 624 | (save-restriction |
| 628 | (when footnote-narrow-to-footnotes-when-editing | 625 | (when footnote-narrow-to-footnotes-when-editing |
| 629 | (Footnote-narrow-to-footnotes)) | 626 | (footnote--narrow-to-footnotes)) |
| 630 | (Footnote-goto-footnote (1- arg)) ; evil, FIXME (less evil now) | 627 | (footnote-goto-footnote (1- arg)) ; evil, FIXME (less evil now) |
| 631 | ;; (message "Inserting footnote %d" arg) | 628 | ;; (message "Inserting footnote %d" arg) |
| 632 | (unless | 629 | (unless |
| 633 | (or (eq arg 1) | 630 | (or (eq arg 1) |
| @@ -636,11 +633,11 @@ styles." | |||
| 636 | "\n\n" | 633 | "\n\n" |
| 637 | (concat "\n" | 634 | (concat "\n" |
| 638 | (regexp-quote footnote-start-tag) | 635 | (regexp-quote footnote-start-tag) |
| 639 | (Footnote-current-regexp) | 636 | (footnote--current-regexp) |
| 640 | (regexp-quote footnote-end-tag))) | 637 | (regexp-quote footnote-end-tag))) |
| 641 | nil t) | 638 | nil t) |
| 642 | (unless (beginning-of-line) t)) | 639 | (unless (beginning-of-line) t)) |
| 643 | (Footnote-goto-char-point-max) | 640 | (footnote--goto-char-point-max) |
| 644 | (cond | 641 | (cond |
| 645 | ((not (string-equal footnote-section-tag "")) | 642 | ((not (string-equal footnote-section-tag "")) |
| 646 | (re-search-backward | 643 | (re-search-backward |
| @@ -654,21 +651,21 @@ styles." | |||
| 654 | (unless (string-equal footnote-section-tag "") | 651 | (unless (string-equal footnote-section-tag "") |
| 655 | (insert footnote-section-tag "\n"))) | 652 | (insert footnote-section-tag "\n"))) |
| 656 | (let ((old-point (point))) | 653 | (let ((old-point (point))) |
| 657 | (Footnote-insert-numbered-footnote arg nil) | 654 | (footnote--insert-numbered-footnote arg nil) |
| 658 | (Footnote-insert-text-marker arg old-point))) | 655 | (footnote--insert-text-marker arg old-point))) |
| 659 | 656 | ||
| 660 | (defun Footnote-sort (list) | 657 | (defun footnote--sort (list) |
| 661 | (sort list (lambda (e1 e2) | 658 | (sort list (lambda (e1 e2) |
| 662 | (< (car e1) (car e2))))) | 659 | (< (car e1) (car e2))))) |
| 663 | 660 | ||
| 664 | (defun Footnote-text-under-cursor () | 661 | (defun footnote--text-under-cursor () |
| 665 | "Return the number of the current footnote if in footnote text. | 662 | "Return the number of the current footnote if in footnote text. |
| 666 | Return nil if the cursor is not positioned over the text of | 663 | Return nil if the cursor is not positioned over the text of |
| 667 | a footnote." | 664 | a footnote." |
| 668 | (when (and footnote-text-marker-alist | 665 | (when (and footnote-text-marker-alist |
| 669 | (<= (Footnote--get-area-point-min) | 666 | (<= (footnote--get-area-point-min) |
| 670 | (point) | 667 | (point) |
| 671 | (Footnote--get-area-point-max))) | 668 | (footnote--get-area-point-max))) |
| 672 | (let ((i 1) alist-txt result) | 669 | (let ((i 1) alist-txt result) |
| 673 | (while (and (setq alist-txt (nth i footnote-text-marker-alist)) | 670 | (while (and (setq alist-txt (nth i footnote-text-marker-alist)) |
| 674 | (null result)) | 671 | (null result)) |
| @@ -679,40 +676,40 @@ a footnote." | |||
| 679 | (setq result (car (nth (1- i) footnote-text-marker-alist)))) | 676 | (setq result (car (nth (1- i) footnote-text-marker-alist)))) |
| 680 | result))) | 677 | result))) |
| 681 | 678 | ||
| 682 | (defun Footnote-under-cursor () | 679 | (defun footnote--under-cursor () |
| 683 | "Return the number of the footnote underneath the cursor. | 680 | "Return the number of the footnote underneath the cursor. |
| 684 | Return nil if the cursor is not over a footnote." | 681 | Return nil if the cursor is not over a footnote." |
| 685 | (or (get-text-property (point) 'footnote-number) | 682 | (or (get-text-property (point) 'footnote-number) |
| 686 | (Footnote-text-under-cursor))) | 683 | (footnote--text-under-cursor))) |
| 687 | 684 | ||
| 688 | (defun Footnote--calc-fn-alignment-column () | 685 | (defun footnote--calc-fn-alignment-column () |
| 689 | "Calculate the left alignment for footnote text." | 686 | "Calculate the left alignment for footnote text." |
| 690 | ;; FIXME: Maybe it would be better to go to the footnote's beginning and | 687 | ;; FIXME: Maybe it would be better to go to the footnote's beginning and |
| 691 | ;; see at which column it starts. | 688 | ;; see at which column it starts. |
| 692 | (+ footnote-body-tag-spacing | 689 | (+ footnote-body-tag-spacing |
| 693 | (string-width | 690 | (string-width |
| 694 | (concat footnote-start-tag footnote-end-tag | 691 | (concat footnote-start-tag footnote-end-tag |
| 695 | (Footnote-index-to-string | 692 | (footnote--index-to-string |
| 696 | (caar (last footnote-text-marker-alist))))))) | 693 | (caar (last footnote-text-marker-alist))))))) |
| 697 | 694 | ||
| 698 | (defun Footnote--fill-prefix-string () | 695 | (defun footnote--fill-prefix-string () |
| 699 | "Return the fill prefix to be used by footnote mode." | 696 | "Return the fill prefix to be used by footnote mode." |
| 700 | ;; TODO: Prefix to this value other prefix strings, such as those | 697 | ;; TODO: Prefix to this value other prefix strings, such as those |
| 701 | ;; designating a comment line, a message response, or a boxquote. | 698 | ;; designating a comment line, a message response, or a boxquote. |
| 702 | (make-string (Footnote--calc-fn-alignment-column) ?\s)) | 699 | (make-string (footnote--calc-fn-alignment-column) ?\s)) |
| 703 | 700 | ||
| 704 | (defun Footnote--point-in-body-p () | 701 | (defun footnote--point-in-body-p () |
| 705 | "Return non-nil if point is in the buffer text area, | 702 | "Return non-nil if point is in the buffer text area, |
| 706 | i.e. before the beginning of the footnote area." | 703 | i.e. before the beginning of the footnote area." |
| 707 | (< (point) (Footnote--get-area-point-min))) | 704 | (< (point) (footnote--get-area-point-min))) |
| 708 | 705 | ||
| 709 | (defun Footnote--get-area-point-min (&optional before-tag) | 706 | (defun footnote--get-area-point-min (&optional before-tag) |
| 710 | "Return start of the first footnote. | 707 | "Return start of the first footnote. |
| 711 | If there is no footnote area, returns `point-max'. | 708 | If there is no footnote area, returns `point-max'. |
| 712 | With optional arg BEFORE-TAG, return position of the `footnote-section-tag' | 709 | With optional arg BEFORE-TAG, return position of the `footnote-section-tag' |
| 713 | instead, if applicable." | 710 | instead, if applicable." |
| 714 | (cond | 711 | (cond |
| 715 | ;; FIXME: Shouldn't we use `Footnote--get-area-point-max' instead? | 712 | ;; FIXME: Shouldn't we use `footnote--get-area-point-max' instead? |
| 716 | ((not footnote-text-marker-alist) (point-max)) | 713 | ((not footnote-text-marker-alist) (point-max)) |
| 717 | ((not before-tag) (cdr (car footnote-text-marker-alist))) | 714 | ((not before-tag) (cdr (car footnote-text-marker-alist))) |
| 718 | ((string-equal footnote-section-tag "") | 715 | ((string-equal footnote-section-tag "") |
| @@ -741,28 +738,28 @@ instead, if applicable." | |||
| 741 | ;; TODO: integrate sanity checks at reasonable operational points. | 738 | ;; TODO: integrate sanity checks at reasonable operational points. |
| 742 | (cdr (car footnote-text-marker-alist))))))) | 739 | (cdr (car footnote-text-marker-alist))))))) |
| 743 | 740 | ||
| 744 | (defun Footnote--get-area-point-max () | 741 | (defun footnote--get-area-point-max () |
| 745 | "Return the end of footnote area. | 742 | "Return the end of footnote area. |
| 746 | This is either `point-max' or the start of a `.signature' string, as | 743 | This is either `point-max' or the start of a `.signature' string, as |
| 747 | defined by variable `footnote-signature-separator'. If there is no | 744 | defined by variable `footnote-signature-separator'. If there is no |
| 748 | footnote area, returns `point-max'." | 745 | footnote area, returns `point-max'." |
| 749 | (save-excursion (Footnote-goto-char-point-max))) | 746 | (save-excursion (footnote--goto-char-point-max))) |
| 750 | 747 | ||
| 751 | (defun Footnote--adaptive-fill-function (orig-fun) | 748 | (defun footnote--adaptive-fill-function (orig-fun) |
| 752 | (or | 749 | (or |
| 753 | (and | 750 | (and |
| 754 | footnote-mode | 751 | footnote-mode |
| 755 | footnote-align-to-fn-text | 752 | footnote-align-to-fn-text |
| 756 | (Footnote-text-under-cursor) | 753 | (footnote--text-under-cursor) |
| 757 | ;; (not (Footnote--point-in-body-p)) | 754 | ;; (not (footnote--point-in-body-p)) |
| 758 | ;; (< (point) (Footnote--signature-area-start-point)) | 755 | ;; (< (point) (footnote--signature-area-start-point)) |
| 759 | (Footnote--fill-prefix-string)) | 756 | (footnote--fill-prefix-string)) |
| 760 | ;; If not within a footnote's text, fallback to the default. | 757 | ;; If not within a footnote's text, fallback to the default. |
| 761 | (funcall orig-fun))) | 758 | (funcall orig-fun))) |
| 762 | 759 | ||
| 763 | ;;; User functions | 760 | ;;; User functions |
| 764 | 761 | ||
| 765 | (defun Footnote-make-hole () | 762 | (defun footnote--make-hole () |
| 766 | (save-excursion | 763 | (save-excursion |
| 767 | (let ((i 0) | 764 | (let ((i 0) |
| 768 | (notes (length footnote-pointer-marker-alist)) | 765 | (notes (length footnote-pointer-marker-alist)) |
| @@ -775,32 +772,32 @@ footnote area, returns `point-max'." | |||
| 775 | (setq rc (car alist-ptr))) | 772 | (setq rc (car alist-ptr))) |
| 776 | (save-excursion | 773 | (save-excursion |
| 777 | (message "Renumbering from %s to %s" | 774 | (message "Renumbering from %s to %s" |
| 778 | (Footnote-index-to-string (car alist-ptr)) | 775 | (footnote--index-to-string (car alist-ptr)) |
| 779 | (Footnote-index-to-string | 776 | (footnote--index-to-string |
| 780 | (1+ (car alist-ptr)))) | 777 | (1+ (car alist-ptr)))) |
| 781 | (Footnote-renumber (car alist-ptr) | 778 | (footnote--renumber (car alist-ptr) |
| 782 | (1+ (car alist-ptr)) | 779 | (1+ (car alist-ptr)) |
| 783 | alist-ptr | 780 | alist-ptr |
| 784 | alist-txt))) | 781 | alist-txt))) |
| 785 | (setq i (1+ i))) | 782 | (setq i (1+ i))) |
| 786 | rc))) | 783 | rc))) |
| 787 | 784 | ||
| 788 | (defun Footnote-add-footnote (&optional arg) | 785 | (defun footnote-add-footnote (&optional arg) |
| 789 | "Add a numbered footnote. | 786 | "Add a numbered footnote. |
| 790 | The number the footnote receives is dependent upon the relative location | 787 | The number the footnote receives is dependent upon the relative location |
| 791 | of any other previously existing footnotes. | 788 | of any other previously existing footnotes. |
| 792 | If the variable `footnote-narrow-to-footnotes-when-editing' is set, | 789 | If the variable `footnote-narrow-to-footnotes-when-editing' is set, |
| 793 | the buffer is narrowed to the footnote body. The restriction is removed | 790 | the buffer is narrowed to the footnote body. The restriction is removed |
| 794 | by using `Footnote-back-to-message'." | 791 | by using `footnote-back-to-message'." |
| 795 | (interactive "*P") | 792 | (interactive "*P") |
| 796 | (let ((num | 793 | (let ((num |
| 797 | (if footnote-text-marker-alist | 794 | (if footnote-text-marker-alist |
| 798 | (if (< (point) (cl-cadar (last footnote-pointer-marker-alist))) | 795 | (if (< (point) (cl-cadar (last footnote-pointer-marker-alist))) |
| 799 | (Footnote-make-hole) | 796 | (footnote--make-hole) |
| 800 | (1+ (caar (last footnote-text-marker-alist)))) | 797 | (1+ (caar (last footnote-text-marker-alist)))) |
| 801 | 1))) | 798 | 1))) |
| 802 | (message "Adding footnote %d" num) | 799 | (message "Adding footnote %d" num) |
| 803 | (Footnote-insert-footnote num) | 800 | (footnote--insert-footnote num) |
| 804 | (insert-before-markers (make-string footnote-body-tag-spacing ? )) | 801 | (insert-before-markers (make-string footnote-body-tag-spacing ? )) |
| 805 | (let ((opoint (point))) | 802 | (let ((opoint (point))) |
| 806 | (save-excursion | 803 | (save-excursion |
| @@ -809,18 +806,18 @@ by using `Footnote-back-to-message'." | |||
| 809 | "\n\n" | 806 | "\n\n" |
| 810 | "\n")) | 807 | "\n")) |
| 811 | (when footnote-narrow-to-footnotes-when-editing | 808 | (when footnote-narrow-to-footnotes-when-editing |
| 812 | (Footnote-narrow-to-footnotes))) | 809 | (footnote--narrow-to-footnotes))) |
| 813 | ;; Emacs/XEmacs bug? save-excursion doesn't restore point when using | 810 | ;; Emacs/XEmacs bug? save-excursion doesn't restore point when using |
| 814 | ;; insert-before-markers. | 811 | ;; insert-before-markers. |
| 815 | (goto-char opoint)))) | 812 | (goto-char opoint)))) |
| 816 | 813 | ||
| 817 | (defun Footnote-delete-footnote (&optional arg) | 814 | (defun footnote-delete-footnote (&optional arg) |
| 818 | "Delete a numbered footnote. | 815 | "Delete a numbered footnote. |
| 819 | With no parameter, delete the footnote under (point). With ARG specified, | 816 | With no parameter, delete the footnote under (point). With ARG specified, |
| 820 | delete the footnote with that number." | 817 | delete the footnote with that number." |
| 821 | (interactive "*P") | 818 | (interactive "*P") |
| 822 | (unless arg | 819 | (unless arg |
| 823 | (setq arg (Footnote-under-cursor))) | 820 | (setq arg (footnote--under-cursor))) |
| 824 | (when (and arg | 821 | (when (and arg |
| 825 | (or (not footnote-prompt-before-deletion) | 822 | (or (not footnote-prompt-before-deletion) |
| 826 | (y-or-n-p (format "Really delete footnote %d?" arg)))) | 823 | (y-or-n-p (format "Really delete footnote %d?" arg)))) |
| @@ -834,7 +831,7 @@ delete the footnote with that number." | |||
| 834 | (save-excursion | 831 | (save-excursion |
| 835 | (goto-char (car locn)) | 832 | (goto-char (car locn)) |
| 836 | (when (looking-back (concat (regexp-quote footnote-start-tag) | 833 | (when (looking-back (concat (regexp-quote footnote-start-tag) |
| 837 | (Footnote-current-regexp) | 834 | (footnote--current-regexp) |
| 838 | (regexp-quote footnote-end-tag)) | 835 | (regexp-quote footnote-end-tag)) |
| 839 | (line-beginning-position)) | 836 | (line-beginning-position)) |
| 840 | (delete-region (match-beginning 0) (match-end 0)))) | 837 | (delete-region (match-beginning 0) (match-end 0)))) |
| @@ -848,17 +845,17 @@ delete the footnote with that number." | |||
| 848 | (save-restriction ; <= 2017-12 Boruch: WHY?? I see no narrowing / widening here. | 845 | (save-restriction ; <= 2017-12 Boruch: WHY?? I see no narrowing / widening here. |
| 849 | (end-of-line) | 846 | (end-of-line) |
| 850 | (next-single-char-property-change | 847 | (next-single-char-property-change |
| 851 | (point) 'footnote-number nil (Footnote-goto-char-point-max)))))) | 848 | (point) 'footnote-number nil (footnote--goto-char-point-max)))))) |
| 852 | (setq footnote-pointer-marker-alist | 849 | (setq footnote-pointer-marker-alist |
| 853 | (delq alist-ptr footnote-pointer-marker-alist)) | 850 | (delq alist-ptr footnote-pointer-marker-alist)) |
| 854 | (setq footnote-text-marker-alist | 851 | (setq footnote-text-marker-alist |
| 855 | (delq alist-txt footnote-text-marker-alist)) | 852 | (delq alist-txt footnote-text-marker-alist)) |
| 856 | (Footnote-renumber-footnotes) | 853 | (footnote-renumber-footnotes) |
| 857 | (when (and (null footnote-text-marker-alist) | 854 | (when (and (null footnote-text-marker-alist) |
| 858 | (null footnote-pointer-marker-alist)) | 855 | (null footnote-pointer-marker-alist)) |
| 859 | (save-excursion | 856 | (save-excursion |
| 860 | (if (not (string-equal footnote-section-tag "")) | 857 | (if (not (string-equal footnote-section-tag "")) |
| 861 | (let* ((end (Footnote-goto-char-point-max)) | 858 | (let* ((end (footnote--goto-char-point-max)) |
| 862 | (start (1- (re-search-backward | 859 | (start (1- (re-search-backward |
| 863 | (concat "^" footnote-section-tag-regexp) | 860 | (concat "^" footnote-section-tag-regexp) |
| 864 | nil t)))) | 861 | nil t)))) |
| @@ -868,11 +865,11 @@ delete the footnote with that number." | |||
| 868 | (delete-region start (if (< end (point-max)) | 865 | (delete-region start (if (< end (point-max)) |
| 869 | end | 866 | end |
| 870 | (point-max)))) | 867 | (point-max)))) |
| 871 | (Footnote-goto-char-point-max) | 868 | (footnote--goto-char-point-max) |
| 872 | (when (looking-back "\n\n" (- (point) 2)) | 869 | (when (looking-back "\n\n" (- (point) 2)) |
| 873 | (kill-line -1)))))))) | 870 | (kill-line -1)))))))) |
| 874 | 871 | ||
| 875 | (defun Footnote-renumber-footnotes (&optional arg) | 872 | (defun footnote-renumber-footnotes (&optional arg) |
| 876 | "Renumber footnotes, starting from 1." | 873 | "Renumber footnotes, starting from 1." |
| 877 | (interactive "*P") | 874 | (interactive "*P") |
| 878 | (save-excursion | 875 | (save-excursion |
| @@ -883,16 +880,16 @@ delete the footnote with that number." | |||
| 883 | (setq alist-ptr (nth i footnote-pointer-marker-alist)) | 880 | (setq alist-ptr (nth i footnote-pointer-marker-alist)) |
| 884 | (setq alist-txt (nth i footnote-text-marker-alist)) | 881 | (setq alist-txt (nth i footnote-text-marker-alist)) |
| 885 | (unless (= (1+ i) (car alist-ptr)) | 882 | (unless (= (1+ i) (car alist-ptr)) |
| 886 | (Footnote-renumber (car alist-ptr) (1+ i) alist-ptr alist-txt)) | 883 | (footnote--renumber (car alist-ptr) (1+ i) alist-ptr alist-txt)) |
| 887 | (setq i (1+ i)))))) | 884 | (setq i (1+ i)))))) |
| 888 | 885 | ||
| 889 | (defun Footnote-goto-footnote (&optional arg) | 886 | (defun footnote-goto-footnote (&optional arg) |
| 890 | "Jump to the text of a footnote. | 887 | "Jump to the text of a footnote. |
| 891 | With no parameter, jump to the text of the footnote under (point). With ARG | 888 | With no parameter, jump to the text of the footnote under (point). With ARG |
| 892 | specified, jump to the text of that footnote." | 889 | specified, jump to the text of that footnote." |
| 893 | (interactive "P") | 890 | (interactive "P") |
| 894 | (unless arg | 891 | (unless arg |
| 895 | (setq arg (Footnote-under-cursor))) | 892 | (setq arg (footnote--under-cursor))) |
| 896 | (let ((footnote (assq arg footnote-text-marker-alist))) | 893 | (let ((footnote (assq arg footnote-text-marker-alist))) |
| 897 | (cond | 894 | (cond |
| 898 | (footnote | 895 | (footnote |
| @@ -908,13 +905,13 @@ specified, jump to the text of that footnote." | |||
| 908 | (t | 905 | (t |
| 909 | (error "I don't see a footnote here"))))) | 906 | (error "I don't see a footnote here"))))) |
| 910 | 907 | ||
| 911 | (defun Footnote-back-to-message (&optional arg) | 908 | (defun footnote-back-to-message (&optional arg) |
| 912 | "Move cursor back to footnote referent. | 909 | "Move cursor back to footnote referent. |
| 913 | If the cursor is not over the text of a footnote, point is not changed. | 910 | If the cursor is not over the text of a footnote, point is not changed. |
| 914 | If the buffer was narrowed due to `footnote-narrow-to-footnotes-when-editing' | 911 | If the buffer was narrowed due to `footnote-narrow-to-footnotes-when-editing' |
| 915 | being set it is automatically widened." | 912 | being set it is automatically widened." |
| 916 | (interactive "P") | 913 | (interactive "P") |
| 917 | (let ((note (Footnote-text-under-cursor))) | 914 | (let ((note (footnote--text-under-cursor))) |
| 918 | (when note | 915 | (when note |
| 919 | (when footnote-narrow-to-footnotes-when-editing | 916 | (when footnote-narrow-to-footnotes-when-editing |
| 920 | (widen)) | 917 | (widen)) |
| @@ -922,13 +919,13 @@ being set it is automatically widened." | |||
| 922 | 919 | ||
| 923 | (defvar footnote-mode-map | 920 | (defvar footnote-mode-map |
| 924 | (let ((map (make-sparse-keymap))) | 921 | (let ((map (make-sparse-keymap))) |
| 925 | (define-key map "a" 'Footnote-add-footnote) | 922 | (define-key map "a" 'footnote-add-footnote) |
| 926 | (define-key map "b" 'Footnote-back-to-message) | 923 | (define-key map "b" 'footnote-back-to-message) |
| 927 | (define-key map "c" 'Footnote-cycle-style) | 924 | (define-key map "c" 'footnote-cycle-style) |
| 928 | (define-key map "d" 'Footnote-delete-footnote) | 925 | (define-key map "d" 'footnote-delete-footnote) |
| 929 | (define-key map "g" 'Footnote-goto-footnote) | 926 | (define-key map "g" 'footnote-goto-footnote) |
| 930 | (define-key map "r" 'Footnote-renumber-footnotes) | 927 | (define-key map "r" 'footnote-renumber-footnotes) |
| 931 | (define-key map "s" 'Footnote-set-style) | 928 | (define-key map "s" 'footnote-set-style) |
| 932 | map)) | 929 | map)) |
| 933 | 930 | ||
| 934 | (defvar footnote-minor-mode-map | 931 | (defvar footnote-minor-mode-map |
| @@ -956,9 +953,9 @@ play around with the following keys: | |||
| 956 | ;; but only `ignore' behaves correctly with add/remove-function. | 953 | ;; but only `ignore' behaves correctly with add/remove-function. |
| 957 | (setq adaptive-fill-function #'ignore)) | 954 | (setq adaptive-fill-function #'ignore)) |
| 958 | (remove-function (local 'adaptive-fill-function) | 955 | (remove-function (local 'adaptive-fill-function) |
| 959 | #'Footnote--adaptive-fill-function) | 956 | #'footnote--adaptive-fill-function) |
| 960 | (when footnote-mode | 957 | (when footnote-mode |
| 961 | ;; (Footnote-setup-keybindings) | 958 | ;; (footnote-setup-keybindings) |
| 962 | (make-local-variable 'footnote-style) | 959 | (make-local-variable 'footnote-style) |
| 963 | (make-local-variable 'footnote-body-tag-spacing) | 960 | (make-local-variable 'footnote-body-tag-spacing) |
| 964 | (make-local-variable 'footnote-spaced-footnotes) | 961 | (make-local-variable 'footnote-spaced-footnotes) |
| @@ -968,7 +965,7 @@ play around with the following keys: | |||
| 968 | (make-local-variable 'footnote-end-tag) | 965 | (make-local-variable 'footnote-end-tag) |
| 969 | (make-local-variable 'adaptive-fill-function) | 966 | (make-local-variable 'adaptive-fill-function) |
| 970 | (add-function :around (local 'adaptive-fill-function) | 967 | (add-function :around (local 'adaptive-fill-function) |
| 971 | #'Footnote--adaptive-fill-function) | 968 | #'footnote--adaptive-fill-function) |
| 972 | 969 | ||
| 973 | ;; filladapt is an XEmacs package which AFAIK has never been ported | 970 | ;; filladapt is an XEmacs package which AFAIK has never been ported |
| 974 | ;; to Emacs. | 971 | ;; to Emacs. |