+(defvar elpher--link-number-counter 0)
+(defun elpher-reset-link-number-counter ()
+ (setq-local elpher--link-number-counter 0))
+
+(defun elpher--insert-text-button (label &rest properties)
+ "Inserts a potentially-numbered button into the current buffer.
+The text for the button is provided by LABEL, while the button
+properties in PROPERTIES are as per `insert-text-button'."
+
+ (if elpher-number-links
+ (setq-local elpher--link-number-counter (+ elpher--link-number-counter 1)))
+ (let ((pref (if elpher-number-links
+ (concat "[" (number-to-string elpher--link-number-counter) "] ")
+ "")))
+ (apply #'insert-text-button (cons (concat pref label) properties))))
+