annotate lisp/w3/w3-annotat.el @ 17:4579af9d8826

Added tag r19-15b91 for changeset 0293115a14e9
author cvs
date Mon, 13 Aug 2007 08:49:21 +0200
parents 0293115a14e9
children 859a2309aef8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1 ;;; w3-annotat.el --- Annotation functions for Emacs-W3
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;; Author: wmperry
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
3 ;; Created: 1997/01/10 00:13:05
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
4 ;; Version: 1.6
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Keywords: faces, help, comm, news, mail, processes, mouse, hypermedia
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
8 ;;; Copyright (c) 1993 - 1996 by William M. Perry (wmperry@cs.indiana.edu)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
9 ;;; Copyright (c) 1996, 1997 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;;
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
11 ;;; This file is part of GNU Emacs.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;; You should have received a copy of the GNU General Public License
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
24 ;;; along with GNU Emacs; see the file COPYING. If not, write to the
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
25 ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 2
diff changeset
26 ;;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; Private annotation support
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (defun w3-parse-personal-annotations ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; Read in personal annotation file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 (if (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (file-exists-p (format "%s/LOG" w3-personal-annotation-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (file-readable-p (format "%s/LOG" w3-personal-annotation-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (setq w3-personal-annotations nil);; nuke the old list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (let ((start nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (end nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (txt nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (url nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (num nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (set-buffer (get-buffer-create " *panno*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (insert-file-contents-literally
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (format "%s/LOG" w3-personal-annotation-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (w3-replace-regexp "\n+" "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;; nuke the header lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (delete-region (point-min) (progn (forward-line 2) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ((eobp) nil) ; Empty LOG file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (if (/= (char-after (1- (point-max))) ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (insert "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (while (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (setq start (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 end (prog2 (end-of-line) (point) (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 txt (buffer-substring start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 url (substring txt 0 (string-match " " txt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 num (url-split
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (substring txt (1+ (string-match " " txt)) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 "[ \t]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (while num
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (setq w3-personal-annotations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (list url
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (list (car (car num))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (w3-grok-annotation-format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (car (car num)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 w3-personal-annotations)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 num (cdr num))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (kill-buffer " *panno*")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (defun w3-grok-annotation-format (anno)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;; Grab the title from an annotation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (let ((fname (format "%s/PAN-%s.html"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 w3-personal-annotation-directory anno)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (set-buffer (get-buffer-create " *annotmp*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (if (file-exists-p fname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (insert-file-contents-literally fname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (if (re-search-forward "<title>\\(.*\\)</title>" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (buffer-substring (match-beginning 1) (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (concat "Annotation on "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (current-time-string (nth 5 (file-attributes fname)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (kill-buffer " *annotmp*")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (defun w3-is-personal-annotation (url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;; Is URL a personal annotation?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (string-match "file:/.*/PAN-.*\\.html" url))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (defun w3-delete-personal-annotation-internal (url num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (set-buffer (get-buffer-create " *annotmp*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (insert-file-contents-literally (format "%s/LOG"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 w3-personal-annotation-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (replace-regexp (format "[ \t]+\\b%s\\b[ \t]*" num) " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (delete-matching-lines (format "^%s +$" url))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (let ((make-backup-files nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (version-control nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (require-final-newline t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (write-region (point-min) (point-max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (format "%s/LOG"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 w3-personal-annotation-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (kill-buffer " *annotmp*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (let ((anno w3-personal-annotations))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (setq w3-personal-annotations nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (while anno
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (if (not (string= num (car (car (cdr (car anno))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (setq w3-personal-annotations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (cons (car anno) w3-personal-annotations)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (setq anno (cdr anno)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (delete-file (format "%s/PAN-%s.html"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 w3-personal-annotation-directory num)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (defun w3-delete-personal-annotation ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 "Delete a personal annotation."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (let ((url (url-view-url t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ((w3-is-personal-annotation (url-view-url t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (let ((num nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (annotated-url nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (anno w3-personal-annotations))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (string-match "file:/.*/PAN-\\(.*\\)\\.html" url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (setq num (match-string 1 url))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (while anno
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (if (equal num (car (car (cdr (car anno)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (setq annotated-url (car (car anno))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (setq anno (cdr anno)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (if (not annotated-url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (message "Couldn't find url that this is annotating!")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (w3-delete-personal-annotation-internal annotated-url num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (w3-quit))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (let* ((tmp w3-personal-annotations)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (thelist nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (node nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (todel nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (if (not (assoc url tmp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (message "No personal annotations.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (while tmp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (setq node (car tmp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (if (string= (car node) url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (setq thelist (cons (cons (nth 1 (nth 1 node)) "") thelist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (setq tmp (cdr tmp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (setq todel (completing-read "Delete annotation: " thelist nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 ;; WORK ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (message "I should delete %s, but can't." todel)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (defun w3-personal-annotation-add ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 "Add an annotation to this document."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (let ((url (url-view-url t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (buf (get-buffer-create "*Personal Annotation*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (title (read-string "Title: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (format "Annotation by %s on %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (user-real-login-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (current-time-string)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (switch-to-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (if (and w3-annotation-mode (fboundp w3-annotation-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (funcall w3-annotation-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (message "%S is undefined, using %s" w3-annotation-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 default-major-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (funcall default-major-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (w3-annotation-minor-mode 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (setq w3-current-annotation (cons url title))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (insert "<html>\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 " <head>\n"
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
182 " <title>" (url-insert-entities-in-string title) "</title>"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 " </head>\n"
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
184 " <h1>" (url-insert-entities-in-string title) "</h1>\n"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 " <p>\n"
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
186 " <address>" (url-insert-entities-in-string (user-full-name))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (if (stringp url-personal-mail-address)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
188 (concat " &lt;" (url-insert-entities-in-string
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 url-personal-mail-address) "&gt;")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 "</address>\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 " <address>" (current-time-string) "</address>\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 " </p>\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 " <pre>\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (insert "\n\n\n </pre>\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 "</html>"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (message "Hit C-cC-c to send this annotation.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (defun w3-annotation-minor-mode (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 "Minimal minor mode for entering annotations. Just rebinds C-cC-c to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 finish the annotation."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 ((null arg) (setq w3-annotation-minor-mode (not w3-annotation-minor-mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 ((= 0 arg) (setq w3-annotation-minor-mode nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (t (setq w3-annotation-minor-mode t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 ((or w3-running-FSF19 w3-running-xemacs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (t (local-set-key "\C-c\C-c" 'w3-personal-annotation-finish)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (defun w3-annotation-find-highest-number ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 ;; Find the highest annotation number in this buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (let (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (while (re-search-forward "[^ \t\n]*[ \t]\\(.*\\)" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (setq x (nconc (mapcar (function (lambda (x) (string-to-int (car x))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (url-split (buffer-substring (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 "[ \t]")) x)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (if (not x) (setq x '(0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (1+ (car (sort x '>)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (defun w3-personal-annotation-finish ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 "Finish doing a personal annotation."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 ((or w3-running-FSF19 w3-running-xemacs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (t (local-set-key "\C-c\C-c" 'undefined)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (if (or (not w3-personal-annotation-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (not (file-exists-p w3-personal-annotation-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (not (file-directory-p w3-personal-annotation-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (error "No personal annotation directory!")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (let ((url (car w3-current-annotation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (txt (buffer-string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (title (cdr w3-current-annotation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (fname nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (num nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (not-modified)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (kill-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (set-buffer (get-buffer-create " *annotmp*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (if (file-exists-p ; Insert current LOG file if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 ; it exists.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (format "%s/LOG" w3-personal-annotation-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (insert-file-contents-literally
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (format "%s/LOG" w3-personal-annotation-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (progn ; Otherwise, create a file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (goto-char (point-min)) ; that conforms to first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 ; annotation format from NCSA
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (insert "ncsa-mosaic-personal-annotation-log-format-1\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (insert "Personal\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (setq num (int-to-string (w3-annotation-find-highest-number))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 fname (format "%s/PAN-%s.html"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 w3-personal-annotation-directory num))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (if (re-search-forward (regexp-quote url) nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (insert " "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (insert "\n" url " "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (insert num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (let ((make-backup-files nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (version-control nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (require-final-newline t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (write-region (point-min) (point-max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (format "%s/LOG" w3-personal-annotation-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (insert w3-annotation-marker txt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (write-region (point-min) (point-max) fname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (setq w3-personal-annotations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (cons (list url (list num title)) w3-personal-annotations))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (defun w3-annotation-add ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 "Add an annotation to the current document."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (w3-personal-annotation-add))