summaryrefslogtreecommitdiff
path: root/helm-semantic.el
diff options
context:
space:
mode:
authorThierry Volpiatto <thierry.volpiatto@gmail.com>2014-12-08 07:23:25 +0100
committerThierry Volpiatto <thierry.volpiatto@gmail.com>2014-12-08 07:28:18 +0100
commit97a8102850c47ef538940dafa7088f61d32c8f37 (patch)
treea63c1668f42c168fa65021bcb6d2a3d2fe0892b5 /helm-semantic.el
parent8df8215ac6ad26495bbd76d650c338fd22f9cc7f (diff)
Redefine source for semantic and imenu, fix setting of fuzzy for both (#145).
* helm-imenu.el (helm-imenu-source): new class. (helm-imenu-fuzzy-match): use a set function and move it below. (helm-imenu): Set the source here (should be set by the fuzzy var, but be sure it is done). * helm-semantic.el: Same.
Diffstat (limited to 'helm-semantic.el')
-rw-r--r--helm-semantic.el70
1 files changed, 45 insertions, 25 deletions
diff --git a/helm-semantic.el b/helm-semantic.el
index 614129c7..fc3b4e05 100644
--- a/helm-semantic.el
+++ b/helm-semantic.el
@@ -28,14 +28,13 @@
(declare-function pulse-momentary-highlight-one-line "pulse.el" (point &optional face))
+(defgroup helm-semantic nil
+ "Semantic tags related libraries and applications for helm."
+ :group 'helm)
+
(defcustom helm-semantic-lynx-style-map t
"Use Arrow keys to jump to occurences."
- :group 'helm-imenu
- :type 'boolean)
-
-(defcustom helm-semantic-fuzzy-match nil
- "Enable fuzzy matching in `helm-source-semantic'."
- :group 'helm-imenu
+ :group 'helm-semantic
:type 'boolean)
;;; keymap
@@ -112,23 +111,32 @@
(setq helm-cached-imenu-tick tick)
(semantic-parse-tree-set-needs-update)))))
-(defvar helm-source-semantic
- (helm-make-source "Semantic Tags" 'helm-source-sync
- :header-name "Semantic Tags"
- :init (lambda ()
- (helm-semantic--maybe-set-needs-update)
- (setq helm-semantic--tags-cache (semantic-fetch-tags))
- (with-current-buffer (helm-candidate-buffer 'global)
- (helm-semantic--fetch-candidates helm-semantic--tags-cache 0)))
- :candidates 'helm-semantic-get-candidates
- :fuzzy-match helm-semantic-fuzzy-match
- :persistent-help "Show this entry"
- :keymap 'helm-semantic-map
- :mode-line helm-semantic-mode-line
- :persistent-action (lambda (elm)
- (helm-semantic-default-action elm t)
- (helm-highlight-current-line))
- :action 'helm-semantic-default-action))
+(defvar helm-source-semantic nil)
+
+(defclass helm-semantic-source (helm-source-sync)
+ ((init :initform (lambda ()
+ (helm-semantic--maybe-set-needs-update)
+ (setq helm-semantic--tags-cache (semantic-fetch-tags))
+ (with-current-buffer (helm-candidate-buffer 'global)
+ (helm-semantic--fetch-candidates helm-semantic--tags-cache 0))))
+ (candidates :initform 'helm-semantic-get-candidates)
+ (persistent-help :initform "Show this entry")
+ (keymap :initform 'helm-semantic-map)
+ (mode-line :initform helm-semantic-mode-line)
+ (persistent-action :initform (lambda (elm)
+ (helm-semantic-default-action elm t)
+ (helm-highlight-current-line)))
+ (action :initform 'helm-semantic-default-action)))
+
+(defcustom helm-semantic-fuzzy-match nil
+ "Enable fuzzy matching in `helm-source-semantic'."
+ :group 'helm-semantic
+ :type 'boolean
+ :set (lambda (var val)
+ (set var val)
+ (setq helm-source-semantic
+ (helm-make-source "Semantic Tags" 'helm-semantic-source
+ :fuzzy-match helm-semantic-fuzzy-match))))
;;;###autoload
(defun helm-semantic (arg)
@@ -139,6 +147,10 @@ If ARG is supplied, pre-select symbol at point instead of current"
(cons (format "\\_<%s\\_>" (car it))
(format "\\_<%s\\_>" (car (semantic-current-tag))))
(format "\\_<%s\\_>" (car (semantic-current-tag))))))
+ (unless helm-source-semantic
+ (setq helm-source-semantic
+ (helm-make-source "Semantic Tags" 'helm-semantic-source
+ :fuzzy-match helm-semantic-fuzzy-match)))
(helm :sources 'helm-source-semantic
:candidate-number-limit 9999
:preselect (if arg
@@ -156,9 +168,17 @@ If `semantic-mode' is active in the current buffer, then use
semantic for generating tags, otherwise fall back to `imenu'.
Fill in the symbol at point by default."
(interactive "P")
+ (unless helm-source-semantic
+ (setq helm-source-semantic
+ (helm-make-source "Semantic Tags" 'helm-semantic-source
+ :fuzzy-match helm-semantic-fuzzy-match)))
+ (unless helm-source-imenu
+ (setq helm-source-imenu
+ (helm-make-source "Imenu" 'helm-imenu-source
+ :fuzzy-match helm-imenu-fuzzy-match)))
(let* ((source (if (semantic-active-p)
'helm-source-semantic
- 'helm-source-imenu))
+ 'helm-source-imenu))
(imenu-p (eq source 'helm-source-imenu))
(imenu-auto-rescan imenu-p)
(helm-execute-action-at-once-if-one
@@ -172,7 +192,7 @@ Fill in the symbol at point by default."
:candidate-number-limit 9999
:preselect (if (or arg imenu-p)
(thing-at-point 'symbol)
- tag)
+ tag)
:buffer "*helm semantic/imenu*")))
(provide 'helm-semantic)