comparison lisp/utils/docref.el @ 2:ac2d302a0011 r19-15b2

Import from CVS: tag r19-15b2
author cvs
date Mon, 13 Aug 2007 08:46:35 +0200
parents 376386a54a3c
children
comparison
equal deleted inserted replaced
1:c0c6a60d29db 2:ac2d302a0011
4 ;; Author: Vadim Geshel <vadik@unas.cs.kiev.ua> 4 ;; Author: Vadim Geshel <vadik@unas.cs.kiev.ua>
5 ;; Created: 12 Jul 1994 5 ;; Created: 12 Jul 1994
6 ;; Keywords: docs, help, lisp 6 ;; Keywords: docs, help, lisp
7 ;; original name was cross-ref.el. 7 ;; original name was cross-ref.el.
8 8
9 ;; This file is part of GNU Emacs. 9 ;; This file is part of XEmacs.
10 10
11 ;; GNU Emacs is free software; you can redistribute it and/or modify 11 ;; XEmacs is free software; you can redistribute it and/or modify it
12 ;; it under the terms of the GNU General Public License as published by 12 ;; under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option) 13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version. 14 ;; any later version.
15 15
16 ;; GNU Emacs is distributed in the hope that it will be useful, 16 ;; XEmacs is distributed in the hope that it will be useful, but
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ;; GNU General Public License for more details. 19 ;; General Public License for more details.
20 20
21 ;; You should have received a copy of the GNU General Public License 21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to 22 ;; along with XEmacs; see the file COPYING. If not, write to the Free
23 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 23 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24 24 ;; 02111-1307, USA.
25 ;;; Synched up with: FSF 19.30. 25
26 ;;; Synched up with: FSF 19.34.
26 27
27 ;;; Commentary: 28 ;;; Commentary:
28 ;; 29
29 ;; This package allows you to use a simple form of cross references in 30 ;; This package allows you to use a simple form of cross references in
30 ;; your Emacs Lisp documentation strings. Cross-references look like 31 ;; your Emacs Lisp documentation strings. Cross-references look like
31 ;; \\(type@[label@]data), where type defines a method for retrieving 32 ;; \\(type@[label@]data), where type defines a method for retrieving
32 ;; reference informatin, data is used by a method routine as an argument, 33 ;; reference informatin, data is used by a method routine as an argument,
33 ;; and label "represents" the reference in text. If label is absent, data 34 ;; and label "represents" the reference in text. If label is absent, data
127 128
128 Find cross-reference information in a buffer and 129 Find cross-reference information in a buffer and
129 highlight them with face defined by \\(v@docref-highlight-face). 130 highlight them with face defined by \\(v@docref-highlight-face).
130 131
131 Cross-reference has the following format: \\ (TYPE[@LABEL]@DATA), where 132 Cross-reference has the following format: \\ (TYPE[@LABEL]@DATA), where
132 TYPE defines method used to retrive xref data (like reading from file or 133 TYPE defines method used to retrieve xref data (like reading from file or
133 calling \\(f@describe-function)), DATA is an argument to this method 134 calling \\(f@describe-function)), DATA is an argument to this method
134 \(like file name or function name), and LABEL is displayed in text using 135 \(like file name or function name), and LABEL is displayed in text using
135 \\(v@docref-highlight-face). 136 \\(v@docref-highlight-face).
136 137
137 The special reference `back' can be used to return back. 138 The special reference `back' can be used to return back.
146 ;; buffer's contents already, so don't do it again. 147 ;; buffer's contents already, so don't do it again.
147 (if (not (get-text-property (point-min) 'docref-seen)) 148 (if (not (get-text-property (point-min) 'docref-seen))
148 (let ((old-modified (buffer-modified-p))) 149 (let ((old-modified (buffer-modified-p)))
149 (while (re-search-forward "[\\](\\([^\)\@]+\\)\\(@[^\)\@]+\\)?@\\([^\)]*\\))" 150 (while (re-search-forward "[\\](\\([^\)\@]+\\)\\(@[^\)\@]+\\)?@\\([^\)]*\\))"
150 nil t) 151 nil t)
151 (let* ((type (buffer-substring (match-beginning 1) (match-end 1))) 152 (let* ((start (match-beginning 0))
153 (type (buffer-substring (match-beginning 1) (match-end 1)))
152 (data (buffer-substring (match-beginning 3) (match-end 3))) 154 (data (buffer-substring (match-beginning 3) (match-end 3)))
153 (label 155 (label
154 (if (match-beginning 2) 156 (if (match-beginning 2)
155 (buffer-substring (+ (match-beginning 2) 1) (match-end 2)) 157 (buffer-substring (+ (match-beginning 2) 1) (match-end 2))
156 data))) 158 data)))
167 (docref-insert-label docref-back-label docref-back-reference))) 169 (docref-insert-label docref-back-label docref-back-reference)))
168 (put-text-property (point-min) (1+ (point-min)) 'docref-seen t) 170 (put-text-property (point-min) (1+ (point-min)) 'docref-seen t)
169 (set-buffer-modified-p old-modified))))) 171 (set-buffer-modified-p old-modified)))))
170 172
171 (defun docref-insert-label (string ref) 173 (defun docref-insert-label (string ref)
172 (let ((label (concat string))) 174 (let ((label (concat string))
175 (pos (point)))
173 ;; decorate the label 176 ;; decorate the label
174 (let ((leading-space-end (save-match-data 177 (let ((leading-space-end (save-match-data
175 (if (string-match "^\\([ \t\n]+\\)" label) 178 (if (string-match "^\\([ \t\n]+\\)" label)
176 (match-end 1) 179 (match-end 1)
177 0))) 180 0)))