Created
June 10, 2015 12:10
-
-
Save tripleee/bb3036c8575adc945f0b to your computer and use it in GitHub Desktop.
Simple Emacs function to renumber tables in a document
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun renumber-tables (n m) | |
"Renumber remaining tables starting with index N, adjust by M. | |
For example, `(renumber-tables 3 -1)` will renumber \"Table 3\" to | |
\"Table 2\", \"Table 4\" to \"Table 3\", etc." | |
(interactive "NStart at: \nNAdjust: ") | |
(save-excursion | |
(save-match-data | |
(while (re-search-forward "Table \\([1-9][0-9]*\\)" nil t) | |
(let ((i (string-to-number (match-string-no-properties 1)))) | |
(when (>= i n) | |
(replace-match (format "Table %i" (+ i m))) ))) ))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment