comparison lisp/hyperbole/kotl/klink.el @ 70:131b0175ea99 r20-0b30

Import from CVS: tag r20-0b30
author cvs
date Mon, 13 Aug 2007 09:02:59 +0200
parents c53a95d3c46d
children 4be1180a9e89
comparison
equal deleted inserted replaced
69:804d1389bcd6 70:131b0175ea99
6 ;; KEYWORDS: extensions, hypermedia, outlines, wp 6 ;; KEYWORDS: extensions, hypermedia, outlines, wp
7 ;; 7 ;;
8 ;; AUTHOR: Bob Weiner & Kellie Clark 8 ;; AUTHOR: Bob Weiner & Kellie Clark
9 ;; 9 ;;
10 ;; ORIG-DATE: 15-Nov-93 at 12:15:16 10 ;; ORIG-DATE: 15-Nov-93 at 12:15:16
11 ;; LAST-MOD: 6-Mar-97 at 01:19:19 by Bob Weiner 11 ;; LAST-MOD: 1-Nov-95 at 23:07:37 by Bob Weiner
12 ;; 12 ;;
13 ;; DESCRIPTION: 13 ;; DESCRIPTION:
14 ;; 14 ;;
15 ;;; link = 15 ;;; link =
16 ;; < pathname [, cell-ref] [, position] > 16 ;; < pathname [, cell-ref] [, position] >
63 63
64 ;;;###autoload 64 ;;;###autoload
65 (defun klink:create (reference) 65 (defun klink:create (reference)
66 "Insert at point an implicit link to REFERENCE. 66 "Insert at point an implicit link to REFERENCE.
67 REFERENCE should be a cell-ref or a string containing \"filename, cell-ref\". 67 REFERENCE should be a cell-ref or a string containing \"filename, cell-ref\".
68 See documentation for `kcell:ref-to-id' for valid cell-ref formats." 68 See documentation for 'kcell:ref-to-id' for valid cell-ref formats."
69 (interactive 69 (interactive
70 ;; Don't change the name or delete default-dir used here. It is referenced 70 ;; Don't change the name or delete default-dir used here. It is referenced
71 ;; in "hargs.el" for argument getting. 71 ;; in "hargs.el" for argument getting.
72 (let ((default-dir default-directory)) 72 (let ((default-dir default-directory))
73 (barf-if-buffer-read-only) 73 (barf-if-buffer-read-only)
96 (setq file-ref (substring file-ref (match-end 0)))) 96 (setq file-ref (substring file-ref (match-end 0))))
97 (insert "<" file-ref) 97 (insert "<" file-ref)
98 (if cell-ref (insert ", " cell-ref)) 98 (if cell-ref (insert ", " cell-ref))
99 (insert ">")) 99 (insert ">"))
100 (cell-ref (insert "<@ " cell-ref ">")) 100 (cell-ref (insert "<@ " cell-ref ">"))
101 (t (error "(klink:create) Invalid reference, `%s'" reference))))) 101 (t (error "(klink:create) Invalid reference, '%s'" reference)))))
102 102
103 (defun klink:at-p () 103 (defun klink:at-p ()
104 "Return non-nil iff point is within a klink. 104 "Return non-nil iff point is within a klink.
105 See documentation for the `actypes::link-to-kotl' function for valid klink 105 See documentation for the `link-to-kotl' function for valid klink formats.
106 formats. Value returned is a list of: link-label, link-start-position, and 106 Value returned is a list of: link-label, link-start-position, and
107 link-end-position, (including delimiters)." 107 link-end-position, (including delimiters)."
108 (let (bol klink referent) 108 (let (bol klink referent)
109 (if (and 109 (if (and
110 ;; If this is an OO-Browser listing buffer, ignore anything that 110 ;; If this is an OO-Browser listing buffer, ignore anything that
111 ;; looks like a klink, e.g. a C++ <template> class. 111 ;; looks like a klink, e.g. a C++ <template> class.
125 ;; Don't match to \<(explicit)> Hyperbole buttons 125 ;; Don't match to \<(explicit)> Hyperbole buttons
126 (/= (char-after (1+ (point))) ?\())) 126 (/= (char-after (1+ (point))) ?\()))
127 (setq klink (hbut:label-p t "<" ">" t)) 127 (setq klink (hbut:label-p t "<" ">" t))
128 (stringp (setq referent (car klink))) 128 (stringp (setq referent (car klink)))
129 ;; Eliminate matches to e-mail address like, <user@domain>. 129 ;; Eliminate matches to e-mail address like, <user@domain>.
130 (not (string-match "[^<> \t\n][!&@]" referent)) 130 (not (string-match "[^<> \t\n][!&@]" referent)))
131 ;; Eliminate matches to URLs
132 (not (string-match "\\`[a-zA-Z]+:" referent))
133 ;; Don't match to <HTML> and </SGML> tags.
134 (not (and (memq major-mode
135 (if (boundp 'id-select-markup-modes)
136 id-select-markup-modes
137 '(html-mode sgml-mode)))
138 ;; Assume , followed by a number is a klink.
139 (not (string-match ",\\s *[0-9]" referent))
140 (string-match "\\`[a-zA-Z!/]" referent))))
141 klink))) 131 klink)))
142 132
143 ;;; ************************************************************************ 133 ;;; ************************************************************************
144 ;;; Hyperbole type definitions 134 ;;; Hyperbole type definitions
145 ;;; ************************************************************************ 135 ;;; ************************************************************************
159 LINK may be of any of the following forms, with or without delimiters: 149 LINK may be of any of the following forms, with or without delimiters:
160 < pathname [, cell-ref] > 150 < pathname [, cell-ref] >
161 < [-!&] pathname > 151 < [-!&] pathname >
162 < @ cell-ref > 152 < @ cell-ref >
163 153
164 See documentation for `kcell:ref-to-id' for valid cell-ref formats." 154 See documentation for 'kcell:ref-to-id' for valid cell-ref formats."
165 155
166 (interactive "sKotl link specifier: ") 156 (interactive "sKotl link specifier: ")
167 (or (stringp link) (error "(link-to-kotl): Non-string link argument, %s" 157 (or (stringp link) (error "(link-to-kotl): Non-string link argument, %s"
168 link)) 158 link))
169 (cond 159 (cond
214 pathname, cell-ref 204 pathname, cell-ref
215 cell-ref 205 cell-ref
216 |viewspec 206 |viewspec
217 :augment-viewspec (ignored for now) 207 :augment-viewspec (ignored for now)
218 208
219 See documentation for `kcell:ref-to-id' for valid cell-ref formats." 209 See documentation for 'kcell:ref-to-id' for valid cell-ref formats."
220 210
221 (or (stringp reference) 211 (or (stringp reference)
222 (error "(klink:parse): Non-string reference argument, %s" 212 (error "(klink:parse): Non-string reference argument, %s"
223 reference)) 213 reference))
224 (cond 214 (cond