annotate shared/refInsert.el @ 41:1ff8b5045b1f

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