Skip to content

Commit

Permalink
Minor comments and changes to clang-completion-mode.el, from David Wood!
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158174 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
DougGregor committed Jun 7, 2012
1 parent 783f008 commit 3f1a5a2
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions utils/clang-completion-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@
;;
;; (load-library "clang-completion-mode")
;;
;; Once you have done this, you can set various parameters with
;;
;; M-x customize-group RET clang-completion-mode RET
;;
;; Finally, to try Clang-based code completion in a particular buffer,
;; use M-x clang-completion-mode. When "Clang-CC" shows up in the mode
;; use M-x clang-completion-mode. When "Clang" shows up in the mode
;; line, Clang's code-completion is enabled.
;;
;; Clang's code completion is based on parsing the complete source
Expand Down Expand Up @@ -100,7 +104,12 @@ This variable will typically contain include paths, e.g., -I~/MyProject."
(or (string-match "OVERLOAD:" line)
(string-match (concat "COMPLETION: " clang-completion-substring) line)))


;; re-process the completions when further input narrows the field
(defun clang-completion-display (buffer)
(fill-buffer buffer))

(defun fill-buffer (buffer)
(let* ((all-lines (split-string clang-result-string "\n"))
(completion-lines (filter 'is-completion-line all-lines)))
(if (consp completion-lines)
Expand All @@ -124,24 +133,7 @@ This variable will typically contain include paths, e.g., -I~/MyProject."
;; 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-result-string "\n"))
(completion-lines (filter 'is-completion-line all-lines)))
(if (consp completion-lines)
(progn
;; Erase the process buffer.
(let ((cur (current-buffer)))
(set-buffer (process-buffer proc))
(goto-char (point-min))
(erase-buffer)
(set-buffer cur))

;; Display the process buffer.
(display-buffer (process-buffer proc))

;; Insert the code-completion string into the process buffer.
(with-current-buffer (process-buffer proc)
(insert (mapconcat 'identity completion-lines "\n")))
))))
(fill-buffer (process-buffer proc)))

(defun clang-complete ()
(let* ((cc-point (concat (buffer-file-name)
Expand Down

0 comments on commit 3f1a5a2

Please sign in to comment.