From f219f7fdcc19575c7890b7a7405bcdd1dd993881 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Mon, 18 Mar 2013 03:44:41 +0400 Subject: [PATCH] company-clang: show meta --- company-clang.el | 14 +++++++++++++- company.el | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/company-clang.el b/company-clang.el index 160b9f8a9..966ef79ec 100644 --- a/company-clang.el +++ b/company-clang.el @@ -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))))) diff --git a/company.el b/company.el index a841f98f4..f728ca2c5 100644 --- a/company.el +++ b/company.el @@ -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) -- 2.39.2