annotate lisp/oobr/br-c-ft.el @ 70:131b0175ea99 r20-0b30

Import from CVS: tag r20-0b30
author cvs
date Mon, 13 Aug 2007 09:02:59 +0200
parents 4103f0995bd7
children 4be1180a9e89
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;!emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; FILE: br-c-ft.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; SUMMARY: OO-Browser C construct handling.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; USAGE: GNU Emacs Lisp Library
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; KEYWORDS: c, tools
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; AUTHOR: Bob Weiner
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
9 ;; ORG: Motorola, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; ORIG-DATE: 3-May-95 at 16:47:05
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
12 ;; LAST-MOD: 21-Oct-95 at 04:30:51 by Bob Weiner
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
14 ;; Copyright (C) 1995 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; See the file BR-COPY for license information.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; This file is part of the OO-Browser.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; DESCRIPTION:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; DESCRIP-END.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;;; ************************************************************************
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
23 ;;; Other required Elisp libraries
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
24 ;;; ************************************************************************
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
25
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
26 ;;; ************************************************************************
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;; Public variables
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 (defvar c-default-classes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 '("[constant]" "[enumeration]" "[function]" "[macro]"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 "[structure]" "[type]" "[union]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 "*List of default class names of C constructs handled by the OO-Browser.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 If you add a class to this list, you also need to add appropriate filtering
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 code for features of the class to \"br-c-tags\".")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;;; Public functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (defun c-add-default-classes ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;; Add to 'system' class table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (lambda (class)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (br-add-class class br-null-path nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 c-default-classes))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (defun c-build-element-tags ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 "Create C constructs tags file for the current Environment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 This excludes functions. Call this after building the language-specific
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 feature tags file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;; If c-tags have already been added to feature tags, then the feature tags
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;; buffer ends with ^L.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (set-buffer (funcall br-find-file-noselect-function br-feature-tags-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (if (or (not (stringp br-tags-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (progn (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (skip-chars-backward "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (if (/= (point) (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (backward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (= (following-char) ?\^L)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (message "Building C construct index...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ; For debugging.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ; (message "%s %s %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ; (expand-file-name "br-c-tags" br-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ; br-tags-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ; (mapcar 'expand-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ; (delq nil (append br-sys-search-dirs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ; br-lib-search-dirs))))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
72 (apply 'call-process (expand-file-name "br-c-tags" br-directory)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
73 nil nil nil
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
74 ;; If no etags program in exec-directory, use one in user's $PATH.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
75 (let ((etags (expand-file-name "etags" exec-directory)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
76 (if (file-executable-p etags) etags "etags"))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
77 br-tags-file
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
78 (mapcar 'expand-file-name
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
79 (delq nil (append br-sys-search-dirs br-lib-search-dirs))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (let ((c-tags-start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (insert-file-contents br-tags-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (insert "\^L\n") ;; To mark end of C tags insertion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (delete-file br-tags-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (goto-char c-tags-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;; Remove tag files which have no entries.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (while (re-search-forward "^\^L\n.*\n\^L\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (replace-match "\^L\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (forward-line -1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (message "Building C construct index...Done")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (defun c-within-comment-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 "Return non-nil if point is within a multi-line C comment."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;; Generally don't have to check whether patterns are matched on single line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;; comments ( // ...) since the regexps to match to will preclude this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;; Ignore comments of the form //***, which look like C comments when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;; searching backward but are actually single line comments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (and (re-search-backward "\\(^\\|[^/]\\)/\\*\\|\\*/" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (not (looking-at "\\*/")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
103 ;;; ************************************************************************
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
104 ;;; Private functions
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
105 ;;; ************************************************************************
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
106
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
107 ;;; ************************************************************************
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
108 ;;; Private variables
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
109 ;;; ************************************************************************
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 24
diff changeset
110
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (provide 'br-c-ft)