Mercurial > hg > xemacs
comparison shared/refInsert.el @ 0:107d592c5f4a
DICE versions, used by pers/common, recursive, I think/hope
author | Henry S. Thompson <ht@inf.ed.ac.uk> |
---|---|
date | Mon, 08 Feb 2021 11:44:37 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:107d592c5f4a |
---|---|
1 ;;; refInsert.el --- replace url with ref, resolve at end | |
2 | |
3 (provide 'refInsert) | |
4 ;;; Code: | |
5 | |
6 (defun reference () | |
7 "Insert a reference" | |
8 (interactive) | |
9 (let ((current-point (point)) | |
10 (beginning (search-backward " | |
11 " (point-min) t))) | |
12 (save-excursion | |
13 (if (not (equal beginning nil)) | |
14 (goto-char beginning)) | |
15 (let ((url-point (search-forward-regexp "[a-zA-Z]+:[^ | |
16 ]+" (+ current-point 1) t)) | |
17 (ref "http://www.w3.org/DOM")) | |
18 (if (not (equal url-point nil)) | |
19 (progn | |
20 (setq ref (buffer-substring (match-beginning 0) (match-end 0))) | |
21 (replace-match "") | |
22 (setq current-point (point)))) | |
23 | |
24 (setq ref (read-string "Reference? " ref)) | |
25 (setq nbReferences | |
26 (string-to-number (read-string "Reference number? " | |
27 (number-to-string (+ nbReferences 1))))) | |
28 (let ((search-p (search-forward-regexp "^-- | |
29 " (point-max) t))) | |
30 (if (equal search-p nil) | |
31 (end-of-buffer) | |
32 (progn (goto-char search-p) (previous-line 1))) | |
33 (insert (concat "[" (number-to-string nbReferences) "] " | |
34 ref)) | |
35 (newline)))) | |
36 (goto-char current-point) | |
37 (insert (concat "[" (number-to-string nbReferences) "]")) | |
38 )) | |
39 | |
40 (setq nbReferences 0) | |
41 | |
42 (add-hook 'mail-setup-hook (lambda () (setq nbReferences 0))) | |
43 (add-hook 'gnus-message-setup-hook (lambda () (setq nbReferences 0))) | |
44 | |
45 ;;; %F ends here |