[cfe-commits] r91185 - /cfe/trunk/utils/clang-completion-mode.el

Douglas Gregor dgregor at apple.com
Fri Dec 11 15:47:56 PST 2009


Author: dgregor
Date: Fri Dec 11 17:47:56 2009
New Revision: 91185

URL: http://llvm.org/viewvc/llvm-project?rev=91185&view=rev
Log:
Switch the Emacs clang-completion-mode over to clang -cc1

Modified:
    cfe/trunk/utils/clang-completion-mode.el

Modified: cfe/trunk/utils/clang-completion-mode.el
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/clang-completion-mode.el?rev=91185&r1=91184&r2=91185&view=diff

==============================================================================
--- cfe/trunk/utils/clang-completion-mode.el (original)
+++ cfe/trunk/utils/clang-completion-mode.el Fri Dec 11 17:47:56 2009
@@ -15,7 +15,7 @@
 ;; completion based on Clang. It needs your help to make it better!
 ;;
 ;; To use the Clang code completion mode, first make sure that the
-;; "clang-cc" variable below refers to the "clang-cc" executable,
+;; "clang" variable below refers to the "clang" executable,
 ;; which is typically installed in libexec/. Then, place
 ;; clang-completion-mode.el somewhere in your Emacs load path. You can
 ;; add a new load path to Emacs by adding some like the following to
@@ -40,21 +40,20 @@
 ;; file up to the point where the cursor is located. Therefore, Clang
 ;; needs all of the various compilation flags (include paths, dialect
 ;; options, etc.) to provide code-completion results. Currently, these
-;; need to be placed into the clang-cc-flags variable in a format
-;; acceptable to clang-cc. This is a hack: patches are welcome to
+;; need to be placed into the clang-flags variable in a format
+;; acceptable to clang. This is a hack: patches are welcome to
 ;; improve the interface between this Emacs mode and Clang! 
 ;;
 
 ;;; Code:
-;;; The clang-cc executable
-(defcustom clang-cc "clang-cc"
-  "The location of the clang-cc executable of the Clang compiler.
-This executable is typically installed into the libexec subdirectory."
+;;; The clang executable
+(defcustom clang "clang"
+  "The location of the Clang compiler executable"
   :type 'file
   :group 'clang-completion-mode)
 
-;;; Extra compilation flags to pass to clang-cc.
-(defcustom clang-cc-flags ""
+;;; Extra compilation flags to pass to clang.
+(defcustom clang-flags ""
   "Extra flags to pass to the Clang executable.
 This variable will typically contain include paths, e.g., -I~/MyProject."
   :type 'string
@@ -69,7 +68,7 @@
 ;;; The current completion buffer
 (setq clang-completion-buffer nil)
 
-(setq clang-cc-result-string "")
+(setq clang-result-string "")
 
 ;;; Compute the current line in the buffer	
 (defun current-line ()
@@ -89,7 +88,7 @@
 ;; produced. We store all of the results in a string, then the
 ;; sentinel processes the entire string at once.
 (defun clang-completion-stash-filter (proc string)
-  (setq clang-cc-result-string (concat clang-cc-result-string string)))
+  (setq clang-result-string (concat clang-result-string string)))
 
 ;; Filter the given list based on a predicate.
 (defun filter (condp lst)
@@ -102,7 +101,7 @@
       (string-match (concat "COMPLETION: " clang-completion-substring) line)))
 
 (defun clang-completion-display (buffer)
-  (let* ((all-lines (split-string clang-cc-result-string "\n"))
+  (let* ((all-lines (split-string clang-result-string "\n"))
          (completion-lines (filter 'is-completion-line all-lines)))
     (if (consp completion-lines)
         (progn
@@ -125,7 +124,7 @@
 ;; contents of the code-completion buffer with the new code-completion results
 ;; and ensures that the buffer is visible.
 (defun clang-completion-sentinel (proc event)
-  (let* ((all-lines (split-string clang-cc-result-string "\n"))
+  (let* ((all-lines (split-string clang-result-string "\n"))
          (completion-lines (filter 'is-completion-line all-lines)))
     (if (consp completion-lines)
         (progn
@@ -145,8 +144,7 @@
          ))))
 
 (defun clang-complete ()
-  (let ((ccstring (concat "-code-completion-at="
-                          (buffer-file-name)
+  (let ((ccstring (concat (buffer-file-name)
                           ":"
                           (number-to-string (+ 1 (current-line)))
                           ":"
@@ -161,16 +159,18 @@
                 (delete-process cc-proc)))
 
           (setq clang-completion-substring "")
-          (setq clang-cc-result-string "")
+          (setq clang-result-string "")
           (setq clang-completion-buffer cc-buffer-name)
             
           (let ((cc-proc
                  (if (equal clang-completion-prefix-header "")
                      (start-process "Clang Code-Completion" cc-buffer-name
-                                    clang-cc "-fsyntax-only" ccstring 
+                                    clang "-cc1" "-fsyntax-only" 
+                                    "-code-completion-at" ccstring 
                                     (buffer-file-name))
                      (start-process "Clang Code-Completion" cc-buffer-name
-                                    clang-cc "-fsyntax-only" ccstring 
+                                    clang "-cc1" "-fsyntax-only" 
+                                    "-code-completion-at" ccstring 
                                     "-include-pch" 
                                     (concat clang-completion-prefix-header ".pch")
                                     (buffer-file-name)))))
@@ -252,6 +252,6 @@
 (define-minor-mode clang-completion-mode 
   "Clang code-completion mode"
   nil
-  " Clang-CC"
+  " Clang"
   clang-completion-mode-map)
 





More information about the cfe-commits mailing list