summaryrefslogtreecommitdiff
path: root/helm-semantic.el
diff options
context:
space:
mode:
authorThierry Volpiatto <thierry.volpiatto@gmail.com>2015-05-21 09:42:13 +0200
committerThierry Volpiatto <thierry.volpiatto@gmail.com>2015-05-21 09:42:13 +0200
commit577642985933a75a92e5724700b75855d174d3c5 (patch)
tree9a4d6f7173c97eb37137b25bda4767277a32533a /helm-semantic.el
parente01555d60d17401b3444bdf408d9d64dc2476721 (diff)
Allow setting helm-semantic-display-style according to major-mode (#1027).
* helm-semantic.el: Do it.
Diffstat (limited to 'helm-semantic.el')
-rw-r--r--helm-semantic.el20
1 files changed, 14 insertions, 6 deletions
diff --git a/helm-semantic.el b/helm-semantic.el
index 3da708bf..c050f336 100644
--- a/helm-semantic.el
+++ b/helm-semantic.el
@@ -37,15 +37,20 @@
:group 'helm-semantic
:type 'boolean)
-(defcustom helm-semantic-display-style 'semantic-format-tag-summarize
- "Function to present a semantic tag.
+(defcustom helm-semantic-display-style '((python-mode . semantic-format-tag-summarize)
+ (c-mode . semantic-format-tag-name-c-mode))
+ "Function to present a semantic tag according to `major-mode'.
+
+If no function is found for current `major-mode', fall back to
+`semantic-format-tag-summarize' default function.
+
You can have more or less informations depending of the `semantic-format-tag-*'
function you choose.
All the supported functions are prefixed with \"semantic-format-tag-\",
you have completion on these functions with `C-M i' in the customize interface."
:group 'helm-semantic
- :type 'function)
+ :type '(alist :key-type symbol :value-type symbol))
;;; keymap
(defvar helm-semantic-map
@@ -62,7 +67,10 @@ you have completion on these functions with `C-M i' in the customize interface."
(defun helm-semantic--fetch-candidates (tags depth &optional class)
"Write the contents of TAGS to the current buffer."
- (let ((class class) cur-type)
+ (let ((class class) cur-type
+ (stylefn (or (with-helm-current-buffer
+ (assoc-default major-mode helm-semantic-display-style))
+ semantic-format-tag-summarize)))
(cl-dolist (tag tags)
(when (listp tag)
(cl-case (setq cur-type (semantic-tag-class tag))
@@ -77,7 +85,7 @@ you have completion on these functions with `C-M i' in the customize interface."
spaces (if (< depth 2) "" "├►") class)
spaces)
;; Save the tag for later
- (propertize (funcall helm-semantic-display-style tag nil t)
+ (propertize (funcall stylefn tag nil t)
'semantic-tag tag)
"\n")
(and type-p (setq class (car tag)))
@@ -89,7 +97,7 @@ you have completion on these functions with `C-M i' in the customize interface."
;; Don't do anything with packages or includes for now
((package include)
(insert
- (propertize (funcall helm-semantic-display-style tag nil t)
+ (propertize (funcall stylefn tag nil t)
'semantic-tag tag)
"\n")
)