]> code.delx.au - gnu-emacs-elpa/commitdiff
company-clang: show meta
authorDmitry Gutov <dgutov@yandex.ru>
Sun, 17 Mar 2013 23:44:41 +0000 (03:44 +0400)
committerDmitry Gutov <dgutov@yandex.ru>
Sun, 17 Mar 2013 23:44:41 +0000 (03:44 +0400)
company-clang.el
company.el

index 160b9f8a9662f902f195b8a0d6f8ed2ba19fadea..966ef79ec8c3bf4ffed7053edf46ccbf7ad6f89d 100644 (file)
@@ -101,18 +101,24 @@ Prefix files (-include ...) can be selected with
 
 ;; TODO: How to handle OVERLOAD and Pattern?
 (defconst company-clang--completion-pattern
-  "^COMPLETION: \\_<\\(%s[a-zA-Z0-9_:]*\\)")
+  "^COMPLETION: \\_<\\(%s[a-zA-Z0-9_:]*\\)\\(?: : \\(.*\\)$\\)?")
 
 (defconst company-clang--error-buffer-name "*clang error*")
 
+(defvar company-clang--meta-cache nil)
+
 (defun company-clang--parse-output (prefix)
   (goto-char (point-min))
   (let ((pattern (format company-clang--completion-pattern
                          (regexp-quote prefix)))
         (case-fold-search nil)
         lines match)
+    (setq company-clang--meta-cache (make-hash-table :test 'equal))
     (while (re-search-forward pattern nil t)
       (setq match (match-string-no-properties 1))
+      (let ((meta (match-string-no-properties 2)))
+        (when (and meta (not (string= match meta)))
+          (puthash match meta company-clang--meta-cache)))
       (unless (equal match "Pattern")
         (push match lines)))
     lines))
@@ -225,6 +231,12 @@ Completions only work correctly when the buffer has been saved.
                  (not (company-in-string-or-comment))
                  (or (company-grab-symbol) 'stop)))
     (candidates (company-clang--candidates arg))
+    (meta (let ((meta (gethash arg company-clang--meta-cache)))
+            (when meta
+              (replace-regexp-in-string
+               "#]" " "
+               (replace-regexp-in-string "[<{[]#\\|#[>}]" "" meta t)
+               t))))
     (post-completion (and (derived-mode-p 'objc-mode)
                           (string-match ":" arg)
                           (company-clang-objc-templatify arg)))))
index a841f98f41fe0603a5bcce15bafa85f9455722fa..f728ca2c5e243dbcb5af297762f5ec03806a563e 100644 (file)
@@ -77,6 +77,7 @@
 ;;    accidentally when it's enabled.
 ;;    Fixed two old tooltip annoyances.
 ;;    Some performance improvements.
+;;    `company-clang' now shows meta information, too.
 ;;
 ;; 2010-02-24 (0.5)
 ;;    `company-ropemacs' now provides location and docs.  (Fernando H. Silva)