Lines Matching full:clang
0 ;;; Clang Code-Completion minor mode, for use with C/Objective-C/C++.
5 ;; This minor mode uses Clang's command line interface for code
7 ;; and C++ source files. When enabled, Clang will provide
10 ;; space), Clang will provide the names of all structs visible from
12 ;; Clang will provide the names of all of the members of whatever
15 ;; completion based on Clang. It needs your help to make it better!
17 ;; To use the Clang code completion mode, first make sure that the
18 ;; "clang" variable below refers to the "clang" executable,
20 ;; clang-completion-mode.el somewhere in your Emacs load path. You can
33 ;; (load-library "clang-completion-mode")
35 ;; Finally, to try Clang-based code completion in a particular buffer,
36 ;; use M-x clang-completion-mode. When "Clang-CC" shows up in the mode
37 ;; line, Clang's code-completion is enabled.
39 ;; Clang's code completion is based on parsing the complete source
40 ;; file up to the point where the cursor is located. Therefore, Clang
43 ;; need to be placed into the clang-flags variable in a format
44 ;; acceptable to clang. This is a hack: patches are welcome to
45 ;; improve the interface between this Emacs mode and Clang!
49 ;;; The clang executable
50 (defcustom clang "clang"
51 "The location of the Clang compiler executable"
53 :group 'clang-completion-mode)
55 ;;; Extra compilation flags to pass to clang.
56 (defcustom clang-flags nil
57 "Extra flags to pass to the Clang executable.
60 :group 'clang-completion-mode)
62 ;;; The prefix header to use with Clang code completion.
63 (setq clang-completion-prefix-header "")
66 (setq clang-completion-substring "")
69 (setq clang-completion-buffer nil)
71 (setq clang-result-string "")
80 ;;; Set the Clang prefix header
81 (defun clang-prefix-header ()
83 (setq clang-completion-prefix-header
84 (read-string "Clang prefix header> " "" clang-completion-prefix-header
90 (defun clang-completion-stash-filter (proc string)
91 (setq clang-result-string (concat clang-result-string string)))
101 (string-match (concat "COMPLETION: " clang-completion-substring) line)))
103 (defun clang-completion-display (buffer)
104 (let* ((all-lines (split-string clang-result-string "\n"))
126 (defun clang-completion-sentinel (proc event)
127 (let* ((all-lines (split-string clang-result-string "\n"))
146 (defun clang-complete ()
152 (cc-pch (if (equal clang-completion-prefix-header "") nil
154 (concat clang-completion-prefix-header ".pch"))))
155 (cc-flags (if (listp clang-flags) clang-flags nil))
156 (cc-command (append `(,clang "-cc1" "-fsyntax-only")
161 (cc-buffer-name (concat "*Clang Completion for " (buffer-name) "*")))
166 (let ((cc-proc (get-process "Clang Code-Completion")))
170 (setq clang-completion-substring "")
171 (setq clang-result-string "")
172 (setq clang-completion-buffer cc-buffer-name)
175 (append (list "Clang Code-Completion" cc-buffer-name)
177 (set-process-filter cc-proc 'clang-completion-stash-filter)
178 (set-process-sentinel cc-proc 'clang-completion-sentinel)
183 (defun clang-complete-self-insert (arg)
187 (clang-complete))
191 (defun clang-update-filter ()
192 (setq clang-completion-substring (thing-at-point 'symbol))
193 (if (get-process "Clang Code-Completion")
195 (clang-completion-display clang-completion-buffer)
200 (defun clang-filter-self-insert (arg)
203 (clang-update-filter)
208 (defun clang-backspace ()
211 (clang-update-filter))
215 (defun clang-delete ()
218 (clang-update-filter))
220 ;; Set up the keymap for the Clang minor mode.
221 (defvar clang-completion-mode-map nil
222 "Keymap for Clang Completion Mode.")
224 (if (null clang-completion-mode-map)
225 (fset 'clang-completion-mode-map
226 (setq clang-completion-mode-map (make-sparse-keymap))))
228 (if (not (assq 'clang-completion-mode minor-mode-map-alist))
230 (cons (cons 'clang-completion-mode clang-completion-mode-map)
235 (define-key clang-completion-mode-map char 'clang-complete-self-insert))
244 (define-key clang-completion-mode-map char 'clang-filter-self-insert))
248 (define-key clang-completion-mode-map [(backspace)] 'clang-backspace)
249 (define-key clang-completion-mode-map [(delete)] 'clang-delete)
251 ;; Set up the Clang minor mode.
252 (define-minor-mode clang-completion-mode
253 "Clang code-completion mode"
255 " Clang"
256 clang-completion-mode-map)