Mercurial > hg > xemacs
view shared/refInsert.el @ 34:034ed479179e
new news server, needs acct/pwd in ~/.authinfo
author | Henry S Thompson <ht@inf.ed.ac.uk> |
---|---|
date | Tue, 21 Nov 2023 15:52:12 +0000 |
parents | 107d592c5f4a |
children |
line wrap: on
line source
;;; refInsert.el --- replace url with ref, resolve at end (provide 'refInsert) ;;; Code: (defun reference () "Insert a reference" (interactive) (let ((current-point (point)) (beginning (search-backward " " (point-min) t))) (save-excursion (if (not (equal beginning nil)) (goto-char beginning)) (let ((url-point (search-forward-regexp "[a-zA-Z]+:[^ ]+" (+ current-point 1) t)) (ref "http://www.w3.org/DOM")) (if (not (equal url-point nil)) (progn (setq ref (buffer-substring (match-beginning 0) (match-end 0))) (replace-match "") (setq current-point (point)))) (setq ref (read-string "Reference? " ref)) (setq nbReferences (string-to-number (read-string "Reference number? " (number-to-string (+ nbReferences 1))))) (let ((search-p (search-forward-regexp "^-- " (point-max) t))) (if (equal search-p nil) (end-of-buffer) (progn (goto-char search-p) (previous-line 1))) (insert (concat "[" (number-to-string nbReferences) "] " ref)) (newline)))) (goto-char current-point) (insert (concat "[" (number-to-string nbReferences) "]")) )) (setq nbReferences 0) (add-hook 'mail-setup-hook (lambda () (setq nbReferences 0))) (add-hook 'gnus-message-setup-hook (lambda () (setq nbReferences 0))) ;;; %F ends here