annotate lisp/oobr/br-c-ft.el @ 211:78478c60bfcd r20-4b4

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