annotate lisp/oobr/br-compl.el @ 36:c53a95d3c46d r19-15b101

Import from CVS: tag r19-15b101
author cvs
date Mon, 13 Aug 2007 08:53:38 +0200
parents 4103f0995bd7
children 131b0175ea99
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-compl.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; SUMMARY: Most functions for performing completion on OO constructs.
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: matching, oop, 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
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 0
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: 27-Mar-90
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 0
diff changeset
12 ;; LAST-MOD: 20-Feb-97 at 06:58:31 by Bob Weiner
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 0
diff changeset
14 ;; Copyright (C) 1990-1995, 1997 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 (global-set-key "\M-\C-i" 'br-complete-symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;; Other required Elisp libraries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; Requires a number of functions from "br-lib.el", part of the OO-Browser
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; package. See the code for functions called but not defined within this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; Public functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (defun br-buffer-menu ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 "Display list of buffers for current browser language in the viewer window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (or (br-in-view-window-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (setq *br-prev-listing-window* (selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (let ((owind (selected-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (ovbuf (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (br-to-view-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (current-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (buffer-menu 'files-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (narrow-to-region (point) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (let ((buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (buf-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (while (setq buf-name (br-buffer-menu-buffer-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (if (not (string-match br-src-file-regexp buf-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (delete-region (point) (progn (forward-line 1) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (forward-line 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (if (looking-at "^$") ;; No matching buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (switch-to-buffer ovbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (select-window owind)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 "(OO-Browser): No appropriate buffers available for selection."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (set-window-start nil 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (substitute-key-definition 'Buffer-menu-select 'br-buffer-menu-select
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 Buffer-menu-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (message "(OO-Browser): Select a buffer for display."))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (defun br-buffer-menu-buffer-name ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 "Return name of buffer on curren buffer menu line or nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 Leaves point at the beginning of the current line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (if (= (point) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (forward-char Buffer-menu-buffer-column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (let ((start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;; End of buffer name marked by tab or two spaces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (if (not (re-search-forward "\t\\| "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (buffer-substring start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (beginning-of-line))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (defun br-buffer-menu-select ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 "Display buffer associated with the line that point is on."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (substitute-key-definition 'br-buffer-menu-select 'Buffer-menu-select
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 Buffer-menu-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (let ((buff (Buffer-menu-buffer t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (menu (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (if buff
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (progn (switch-to-buffer buff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (or (eq menu buff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (bury-buffer menu)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (beep))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (defun br-complete-entry (&optional prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 "Interactively completes class or feature name and returns it or nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 Optional PROMPT is initial prompt string for user."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (let ((default (and (br-in-browser)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (not (br-in-view-window-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (br-find-class-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (completion-ignore-case t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 completions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 element-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (if (not (br-class-path default)) (setq default nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ;; Prompt with possible completions of element-name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (setq prompt (or prompt "Class/Element name:")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 completions (append (br-class-completions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (br-feature-completions))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 element-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (if completions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (completing-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (format "%s (default %s) " prompt (or default "<None>"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 completions nil 'must-match)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (read-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (format "%s (default %s) " prompt (or default "<None>")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (if (equal element-name "") (setq element-name default))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 element-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (defun br-complete-symbol ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 "Complete symbol preceding point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (cond ((and (fboundp 'br-lang-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (eq major-mode (symbol-function 'br-lang-mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (br-complete-type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (lisp-complete-symbol))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (defun br-complete-class-name (&optional must-match prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 "Interactively completes class name if possible, and returns class name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 Optional MUST-MATCH means class name must match a completion table entry.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 Optional PROMPT is intial prompt string for user."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (let ((default (br-find-class-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (completion-ignore-case t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 completions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 class-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ;; Prompt with possible completions of class-name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (setq prompt (or prompt "Class name:")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 completions (br-class-completions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 class-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (if completions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (completing-read
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (format "%s (default %s) " prompt default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 completions nil must-match)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (read-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (format "%s (default %s) " prompt default))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (if (equal class-name "") default class-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (defun br-lisp-mode-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (or (eq major-mode 'lisp-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (eq major-mode 'emacs-lisp-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (eq major-mode 'scheme-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (eq major-mode 'lisp-interaction-mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (defun br-complete-type ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 "Perform in-buffer completion of a type or element identifier before point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 That symbol is compared against current Environment entries and any needed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 characters are inserted."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (let* ((completion-ignore-case nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (beg (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (if (br-lisp-mode-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (skip-chars-backward "^()")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (if (eq (preceding-char) ?\()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (skip-chars-backward " \t\(")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (goto-char end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (skip-chars-backward (concat br-identifier-chars ":"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (pattern (br-set-case (buffer-substring beg end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (type-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (completion-alist (if (string-match br-feature-signature-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 pattern)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (br-feature-completions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (setq type-p t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (br-class-completions)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (completion (try-completion pattern completion-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (cond ((eq completion t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ((null completion)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (message "Can't find completion for '%s'" pattern)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (ding))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ((not (string-equal pattern completion))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (delete-region beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (insert (if type-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (br-set-case-type completion)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 completion)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (message "Making completion list...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (let ((list (sort (all-completions pattern completion-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 'string-lessp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (let (new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (while list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (setq new (cons (car list) new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 list (cdr list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (setq list (nreverse new)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (with-output-to-temp-buffer "*Completions*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (display-completion-list list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (message "Making completion list...%s" "done")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 ;; Derived from saveconf.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (defun br-window-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 "Returns a list of Lisp window objects for all Emacs windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 Do not count the minibuffer window even if it is active."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (let* ((first-window (next-window (previous-window (selected-window))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (windows (cons first-window nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (current-cons windows)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (w (next-window first-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (while (not (eq w first-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (setq current-cons (setcdr current-cons (cons w nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (setq w (next-window w)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 windows))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 ;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 ;; Private functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 ;; ************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (defun br-all-classes (&optional htable-type duplicates-flag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 "Return list of class names in Environment or optional HTABLE-TYPE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 HTABLE-TYPE may be \"sys\" or \"lib\" or an actual hash table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 List is not sorted unless optional DUPLICATES-FLAG is non-nil, which means cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 the the sorted list of duplicate classes onto the front of the unique class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 names list."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (let ((classes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (apply 'append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (hash-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (function (lambda (val-key-cons)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 ;; Copy so that hash-table values are not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 ;; disturbed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (copy-sequence (car val-key-cons))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (cond ((and (stringp htable-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (not (string-equal htable-type "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (br-get-htable (concat htable-type "-paths")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 ((hashp htable-type) htable-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (t (br-get-paths-htable)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (if duplicates-flag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (br-duplicate-and-unique-strings (sort classes 'string-lessp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 classes)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (defun br-class-completions ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 "Return alist of elements whose cars are all class names in lookup table."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (mapcar (function (lambda (elt) (cons elt nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (br-class-list-filter (sort (br-all-classes) 'string-lessp))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (defun br-find-class-name (&optional keep-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 "Return class name that point is within in a listing buffer, else nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 Optional KEEP-INDENT non-nil means keep indentation preceding class name."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (if (= (point) (point-max)) (skip-chars-backward " \t\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (if (looking-at (concat "[ \t]*" br-feature-type-regexp "?[ \t]+"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (goto-char (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (let ((objc (string-equal br-lang-prefix "objc-"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (class))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (if objc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 ;; Include [] characters for default classes, <> for Objective-C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 ;; protocols and () for Objective-C class categories.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (skip-chars-backward (concat "\]\[()<>" br-identifier-chars))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (skip-chars-backward (concat "\]\[" br-identifier-chars)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (if (or (and objc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 ;; Objective-C protocol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (looking-at (concat "<" br-identifier ">"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 ;; Objective-C class(category)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (looking-at (concat br-identifier "(" br-identifier ")"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 ;; Objective-C class(category)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (if (looking-at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (concat "\\((" br-identifier ")\\)" br-identifier))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (setq class (concat (buffer-substring (match-end 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (match-end 1)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (looking-at br-identifier)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 ;; default class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (looking-at (concat "\\[" br-identifier "\\]")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (progn (if keep-indent (beginning-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (br-set-case (or class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (buffer-substring (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (match-end 0)))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (provide 'br-compl)