0
|
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
|
100
|
9 ;; ORG: InfoDock Associates
|
0
|
10 ;;
|
|
11 ;; ORIG-DATE: 3-May-95 at 16:47:05
|
100
|
12 ;; LAST-MOD: 21-Feb-97 at 17:31:44 by Bob Weiner
|
0
|
13 ;;
|
100
|
14 ;; Copyright (C) 1995, 1996 Free Software Foundation, Inc.
|
0
|
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 ;;; Public variables
|
|
24 ;;; ************************************************************************
|
|
25
|
|
26 (defvar c-default-classes
|
|
27 '("[constant]" "[enumeration]" "[function]" "[macro]"
|
|
28 "[structure]" "[type]" "[union]")
|
|
29 "*List of default class names of C constructs handled by the OO-Browser.
|
|
30
|
|
31 If you add a class to this list, you also need to add appropriate filtering
|
|
32 code for features of the class to \"br-c-tags\".")
|
|
33
|
|
34 ;;; ************************************************************************
|
|
35 ;;; Public functions
|
|
36 ;;; ************************************************************************
|
|
37
|
|
38 (defun c-add-default-classes ()
|
|
39 ;; Add to 'system' class table.
|
|
40 (mapcar
|
|
41 (function
|
|
42 (lambda (class)
|
|
43 (br-add-class class br-null-path nil)))
|
|
44 c-default-classes))
|
|
45
|
|
46 (defun c-build-element-tags ()
|
|
47 "Create C constructs tags file for the current Environment.
|
|
48 This excludes functions. Call this after building the language-specific
|
|
49 feature tags file."
|
|
50 ;; If c-tags have already been added to feature tags, then the feature tags
|
|
51 ;; buffer ends with ^L.
|
|
52 (set-buffer (funcall br-find-file-noselect-function br-feature-tags-file))
|
|
53 (if (or (not (stringp br-tags-file))
|
|
54 (progn (goto-char (point-max))
|
|
55 (skip-chars-backward "\n")
|
|
56 (if (/= (point) (point-min))
|
|
57 (backward-char 1))
|
|
58 (= (following-char) ?\^L)))
|
|
59 nil
|
|
60 (message "Building C construct index...")
|
|
61 ; For debugging.
|
|
62 ; (message "%s %s %s"
|
|
63 ; (expand-file-name "br-c-tags" br-directory)
|
|
64 ; br-tags-file
|
|
65 ; (mapcar 'expand-file-name
|
|
66 ; (delq nil (append br-sys-search-dirs
|
|
67 ; br-lib-search-dirs))))
|
100
|
68 (if hyperb:microcruft-os-p
|
|
69 (apply 'call-process "bash"
|
|
70 nil nil nil
|
|
71 (expand-file-name "br-c-tags" br-directory)
|
|
72 ;; If no etags program in exec-directory, use one in user's $PATH.
|
|
73 (let ((etags (expand-file-name "etags" exec-directory)))
|
|
74 (if (file-executable-p etags) etags "etags"))
|
|
75 br-tags-file
|
|
76 (mapcar 'expand-file-name
|
|
77 (delq nil (append br-sys-search-dirs br-lib-search-dirs))))
|
|
78 (apply 'call-process (expand-file-name "br-c-tags" br-directory)
|
|
79 nil nil nil
|
|
80 ;; If no etags program in exec-directory, use one in user's $PATH.
|
|
81 (let ((etags (expand-file-name "etags" exec-directory)))
|
|
82 (if (file-executable-p etags) etags "etags"))
|
|
83 br-tags-file
|
|
84 (mapcar 'expand-file-name
|
|
85 (delq nil (append br-sys-search-dirs br-lib-search-dirs)))))
|
0
|
86 (goto-char (point-max))
|
|
87 (let ((c-tags-start (point)))
|
|
88 (insert-file-contents br-tags-file)
|
|
89 (goto-char (point-max))
|
|
90 (insert "\^L\n") ;; To mark end of C tags insertion.
|
|
91 (delete-file br-tags-file)
|
|
92 (goto-char c-tags-start)
|
|
93 ;; Remove tag files which have no entries.
|
|
94 (while (re-search-forward "^\^L\n.*\n\^L\n" nil t)
|
|
95 (replace-match "\^L\n")
|
|
96 (forward-line -1)))
|
|
97 (message "Building C construct index...Done")))
|
|
98
|
|
99 (defun c-within-comment-p ()
|
|
100 "Return non-nil if point is within a multi-line C comment."
|
|
101 ;; Generally don't have to check whether patterns are matched on single line
|
|
102 ;; comments ( // ...) since the regexps to match to will preclude this.
|
|
103 ;; Ignore comments of the form //***, which look like C comments when
|
|
104 ;; searching backward but are actually single line comments.
|
|
105 (save-excursion
|
|
106 (and (re-search-backward "\\(^\\|[^/]\\)/\\*\\|\\*/" nil t)
|
|
107 (not (looking-at "\\*/")))))
|
|
108
|
|
109 (provide 'br-c-ft)
|