summaryrefslogtreecommitdiffstats
path: root/utils/clang-completion-mode.el
diff options
context:
space:
mode:
Diffstat (limited to 'utils/clang-completion-mode.el')
-rw-r--r--utils/clang-completion-mode.el40
1 files changed, 16 insertions, 24 deletions
diff --git a/utils/clang-completion-mode.el b/utils/clang-completion-mode.el
index 36d8181..6cf5cb5 100644
--- a/utils/clang-completion-mode.el
+++ b/utils/clang-completion-mode.el
@@ -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
@@ -95,24 +99,29 @@ This variable will typically contain include paths, e.g., -I~/MyProject."
(delq nil
(mapcar (lambda (x) (and (funcall condp x) x)) lst)))
-;; Determine whether
+;; Determine whether FIXME: explain better
(defun is-completion-line (line)
(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)
(progn
- ;; Erase the process buffer
+ ;; Erase the process buffer.
(let ((cur (current-buffer)))
(set-buffer buffer)
(goto-char (point-min))
(erase-buffer)
(set-buffer cur))
- ;; Display the process buffer
+ ;; Display the process buffer.
(display-buffer buffer)
;; Insert the code-completion string into the process buffer.
@@ -120,28 +129,11 @@ This variable will typically contain include paths, e.g., -I~/MyProject."
(insert (mapconcat 'identity completion-lines "\n")))
))))
-;; Process "sentinal" that, on successful code completion, replaces the
+;; Process "sentinel" that, on successful code completion, replaces the
;; 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)
@@ -159,7 +151,7 @@ This variable will typically contain include paths, e.g., -I~/MyProject."
`("-code-completion-at" ,cc-point)
(list (buffer-file-name))))
(cc-buffer-name (concat "*Clang Completion for " (buffer-name) "*")))
- ;; Start the code-completion process
+ ;; Start the code-completion process.
(if (buffer-file-name)
(progn
;; If there is already a code-completion process, kill it first.
OpenPOWER on IntegriCloud