From 6d892691ae5cb3747538930051eea97cc558a750 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Mon, 17 Mar 2014 21:17:36 +0200 Subject: [PATCH] company-semantic: don't try to fetch doc for tag without buffer Fixes #74 --- company-semantic.el | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/company-semantic.el b/company-semantic.el index 4fddf284f..617388ab8 100644 --- a/company-semantic.el +++ b/company-semantic.el @@ -53,19 +53,25 @@ "Tags for the current context.") (make-variable-buffer-local 'company-semantic--current-tags) +(defun company-semantic-documentation-for-tag (tag) + (when (semantic-tag-buffer tag) + ;; When TAG's buffer is unknown, the function below raises an error. + (semantic-documentation-for-tag tag))) + (defun company-semantic-doc-or-summary (tag) - (or (semantic-documentation-for-tag tag) + (or (company-semantic-documentation-for-tag tag) (and (require 'semantic-idle nil t) (require 'semantic/idle nil t) (funcall semantic-idle-summary-function tag nil t)))) (defun company-semantic-summary-and-doc (tag) - (let ((doc (semantic-documentation-for-tag tag)) + (debug) + (let ((doc (company-semantic-documentation-for-tag tag)) (summary (funcall semantic-idle-summary-function tag nil t))) (and (stringp doc) (string-match "\n*\\(.*\\)$" doc) (setq doc (match-string 1 doc))) - (concat (funcall semantic-idle-summary-function tag nil t) + (concat summary (when doc (if (< (+ (length doc) (length summary) 4) (window-width)) " -- " @@ -73,7 +79,7 @@ doc))) (defun company-semantic-doc-buffer (tag) - (let ((doc (semantic-documentation-for-tag tag))) + (let ((doc (company-semantic-documentation-for-tag tag))) (when doc (company-doc-buffer (concat (funcall semantic-idle-summary-function tag nil t) -- 2.39.2