comparison lisp/oobr/br-c-ft.el @ 0:376386a54a3c r19-14

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