73
73
74
74
(defcustom footnote-mode-line-string " FN"
75
75
" String to display in modes section of the mode-line."
76
- :type 'string
77
- :group 'footnote )
78
-
79
- (defcustom footnote-mode-hook nil
80
- " Hook functions run when footnote-mode is activated."
81
- :type 'hook
82
- :group 'footnote )
76
+ :type 'string )
83
77
84
78
(defcustom footnote-narrow-to-footnotes-when-editing nil
85
79
" If non-nil, narrow to footnote text body while editing a footnote."
86
- :type 'boolean
87
- :group 'footnote )
80
+ :type 'boolean )
88
81
89
82
(defcustom footnote-prompt-before-deletion t
90
83
" If non-nil, prompt before deleting a footnote.
91
84
There is currently no way to undo deletions."
92
- :type 'boolean
93
- :group 'footnote )
85
+ :type 'boolean )
94
86
95
87
(defcustom footnote-spaced-footnotes t
96
88
" If non-nil, insert an empty line between footnotes.
97
89
Customizing this variable has no effect on buffers already
98
90
displaying footnotes."
99
- :type 'boolean
100
- :group 'footnote )
91
+ :type 'boolean )
101
92
102
93
(defcustom footnote-use-message-mode t ; Nowhere used.
103
94
" If non-nil, assume Footnoting will be done in `message-mode' ."
104
- :type 'boolean
105
- :group 'footnote )
95
+ :type 'boolean )
106
96
107
97
(defcustom footnote-body-tag-spacing 2
108
98
" Number of spaces separating a footnote body tag and its text.
109
99
Customizing this variable has no effect on buffers already
110
100
displaying footnotes."
111
- :type 'integer
112
- :group 'footnote )
101
+ :type 'integer )
113
102
114
103
(defcustom footnote-prefix [(control ?c ) ?! ]
115
104
" Prefix key to use for Footnote command in Footnote minor mode.
116
105
The value of this variable is checked as part of loading Footnote mode.
117
106
After that, changing the prefix key requires manipulating keymaps."
118
- :type 'key-sequence
119
- :group 'footnote )
107
+ :type 'key-sequence )
120
108
121
109
; ;; Interface variables that probably shouldn't be changed
122
110
@@ -127,8 +115,7 @@ value of `footnote-section-tag-regexp' is ignored. Customizing
127
115
this variable has no effect on buffers already displaying
128
116
footnotes."
129
117
:version " 27.1"
130
- :type 'string
131
- :group 'footnote )
118
+ :type 'string )
132
119
133
120
(defcustom footnote-section-tag-regexp
134
121
; ; Even if `footnote-section-tag' has a trailing space, let's not require it
@@ -139,31 +126,27 @@ This variable is disregarded when `footnote-section-tag' is the
139
126
empty string. Customizing this variable has no effect on buffers
140
127
already displaying footnotes."
141
128
:version " 27.1"
142
- :type 'regexp
143
- :group 'footnote )
129
+ :type 'regexp )
144
130
145
131
; ; The following three should be consumed by footnote styles.
146
132
(defcustom footnote-start-tag " ["
147
133
" String used to denote start of numbered footnote.
148
134
Should not be set to the empty string. Customizing this variable
149
135
has no effect on buffers already displaying footnotes."
150
- :type 'string
151
- :group 'footnote )
136
+ :type 'string )
152
137
153
138
(defcustom footnote-end-tag " ]"
154
139
" String used to denote end of numbered footnote.
155
140
Should not be set to the empty string. Customizing this variable
156
141
has no effect on buffers already displaying footnotes."
157
- :type 'string
158
- :group 'footnote )
142
+ :type 'string )
159
143
160
144
(defcustom footnote-signature-separator
161
145
(if (boundp 'message-signature-separator )
162
146
message-signature-separator
163
147
" ^-- $" )
164
148
" Regexp used by Footnote mode to recognize signatures."
165
- :type 'regexp
166
- :group 'footnote )
149
+ :type 'regexp )
167
150
168
151
(defcustom footnote-align-to-fn-text t
169
152
" How to left-align footnote text.
@@ -187,6 +170,8 @@ left with the first character of footnote text."
187
170
(make-variable-buffer-local 'footnote-pointer-marker-alist )
188
171
189
172
(defvar footnote-mouse-highlight 'highlight
173
+ ; ; FIXME: This `highlight' property is not currently used.
174
+ ; ; We should use `mouse-face' and make mouse clicks work on them.
190
175
" Text property name to enable mouse over highlight." )
191
176
192
177
(defvar footnote-mode )
@@ -441,20 +426,15 @@ Customizing this variable has no effect on buffers already
441
426
displaying footnotes. To change the style of footnotes in such a
442
427
buffer use the command `footnote-set-style' ."
443
428
:type (cons 'choice (mapcar (lambda (x ) (list 'const (car x)))
444
- footnote-style-alist))
445
- :group 'footnote )
429
+ footnote-style-alist)))
446
430
447
431
; ;; Style utilities & functions
448
- (defun footnote--style-p (style )
449
- " Return non-nil if style is a valid style known to `footnote-mode' ."
450
- (assq style footnote-style-alist))
451
432
452
433
(defun footnote--index-to-string (index )
453
434
" Convert a binary index into a string to display as a footnote.
454
435
Conversion is done based upon the current selected style."
455
- (let ((alist (if (footnote--style-p footnote-style)
456
- (assq footnote-style footnote-style-alist)
457
- (nth 0 footnote-style-alist))))
436
+ (let ((alist (or (assq footnote-style footnote-style-alist)
437
+ (nth 0 footnote-style-alist))))
458
438
(funcall (nth 1 alist) index)))
459
439
460
440
(defun footnote--current-regexp ()
@@ -522,41 +502,27 @@ styles."
522
502
nil " \\ 1" ))
523
503
(setq i (1+ i))))))
524
504
525
- (defun footnote--assoc-index (key alist )
526
- " Give index of key in alist."
527
- (let ((i 0 ) (max (length alist)) rc)
528
- (while (and (null rc)
529
- (< i max ))
530
- (when (eq key (car (nth i alist)))
531
- (setq rc i))
532
- (setq i (1+ i)))
533
- rc))
534
-
535
505
(defun footnote-cycle-style ()
536
506
" Select next defined footnote style."
537
507
(interactive )
538
- (let ((old (footnote--assoc-index footnote-style footnote-style-alist))
539
- (max (length footnote-style-alist))
540
- idx)
541
- (setq idx (1+ old))
542
- (when (>= idx max )
543
- (setq idx 0 ))
544
- (setq footnote-style (car (nth idx footnote-style-alist)))
545
- (footnote--refresh-footnotes (nth 2 (nth old footnote-style-alist)))))
546
-
547
- (defun footnote-set-style (&optional style )
508
+ (let ((old-desc (assq footnote-style footnote-style-alist)))
509
+ (setq footnote-style (caar (or (cdr (memq old-desc footnote-style-alist))
510
+ footnote-style-alist)))
511
+ (footnote--refresh-footnotes (nth 2 old-desc))))
512
+
513
+ (defun footnote-set-style (style )
548
514
" Select a specific style."
549
515
(interactive
550
516
(list (intern (completing-read
551
517
" Footnote Style: "
552
- obarray # ' footnote-- style-p 'require-match ))))
553
- (let ((old (footnote--assoc-index footnote-style footnote-style-alist)))
518
+ footnote-style-alist nil 'require-match ))))
519
+ (let ((old-desc ( assq footnote-style footnote-style-alist)))
554
520
(setq footnote-style style)
555
- (footnote--refresh-footnotes (nth 2 ( nth old footnote-style-alist) ))))
521
+ (footnote--refresh-footnotes (nth 2 old-desc ))))
556
522
557
523
; ; Internal functions
558
524
(defun footnote--insert-numbered-footnote (arg &optional mousable )
559
- " Insert numbered footnote at ( point) ."
525
+ " Insert numbered footnote at point."
560
526
(let ((string (concat footnote-start-tag
561
527
(footnote--index-to-string arg)
562
528
footnote-end-tag)))
@@ -566,7 +532,7 @@ styles."
566
532
string 'footnote-number arg footnote-mouse-highlight t )
567
533
(propertize string 'footnote-number arg)))))
568
534
569
- (defun footnote--renumber (_from to pointer-alist text-alist )
535
+ (defun footnote--renumber (to pointer-alist text-alist )
570
536
" Renumber a single footnote."
571
537
(let* ((posn-list (cdr pointer-alist)))
572
538
(setcar pointer-alist to)
@@ -675,8 +641,7 @@ styles."
675
641
(footnote--insert-text-marker arg old-point)))
676
642
677
643
(defun footnote--sort (list )
678
- (sort list (lambda (e1 e2 )
679
- (< (car e1) (car e2)))))
644
+ (sort list #'car-less-than-car ))
680
645
681
646
(defun footnote--text-under-cursor ()
682
647
" Return the number of the current footnote if in footnote text.
@@ -795,8 +760,7 @@ footnote area, returns `point-max'."
795
760
(footnote--index-to-string (car alist-ptr))
796
761
(footnote--index-to-string
797
762
(1+ (car alist-ptr))))
798
- (footnote--renumber (car alist-ptr)
799
- (1+ (car alist-ptr))
763
+ (footnote--renumber (1+ (car alist-ptr))
800
764
alist-ptr
801
765
alist-txt)))
802
766
(setq i (1+ i)))
@@ -900,7 +864,7 @@ delete the footnote with that number."
900
864
(setq alist-ptr (nth i footnote-pointer-marker-alist))
901
865
(setq alist-txt (nth i footnote-text-marker-alist))
902
866
(unless (= (1+ i) (car alist-ptr))
903
- (footnote--renumber (car alist-ptr) ( 1+ i) alist-ptr alist-txt))
867
+ (footnote--renumber (1+ i) alist-ptr alist-txt))
904
868
(setq i (1+ i))))))
905
869
906
870
(defun footnote-goto-footnote (&optional arg )
0 commit comments