@@ -1921,11 +1921,15 @@ Quote newlines if ARG isn't 1."
1921
1921
t)))
1922
1922
1923
1923
;; ——— Locals: tags ———————————————————————————————————————————————————————————
1924
- (defun lispy-goto ()
1925
- "Jump to symbol within files in current directory."
1926
- (interactive)
1924
+ (defun lispy-goto (&optional arg)
1925
+ "Jump to symbol within files in current directory.
1926
+ When ARG isn't nil, call `lispy-goto-projectile' instead."
1927
+ (interactive "P")
1927
1928
(deactivate-mark)
1928
- (lispy--goto 'lispy--fetch-tags))
1929
+ (lispy--goto
1930
+ (if arg
1931
+ #'lispy--fetch-tags-projectile
1932
+ #'lispy--fetch-tags)))
1929
1933
1930
1934
(defun lispy-goto-recursive ()
1931
1935
"Jump to symbol within files in current directory and its subdiretories."
@@ -1936,8 +1940,15 @@ Quote newlines if ARG isn't 1."
1936
1940
(defun lispy-goto-local ()
1937
1941
"Jump to symbol within current file."
1938
1942
(interactive)
1943
+ (deactivate-mark)
1939
1944
(lispy--goto 'lispy--fetch-this-file-tags))
1940
1945
1946
+ (defun lispy-goto-projectile ()
1947
+ "Jump to symbol within files in (`projectile-project-root')."
1948
+ (interactive)
1949
+ (deactivate-mark)
1950
+ (lispy--goto 'lispy--fetch-tags-projectile))
1951
+
1941
1952
(defun lispy-goto-def-down (arg)
1942
1953
"Jump to definition of ARGth element of current list."
1943
1954
(interactive "p")
@@ -2564,6 +2575,7 @@ With ARG, use the contents of `lispy-store-region-and-buffer' instead."
2564
2575
2565
2576
(declare-function projectile-find-file "ext:projectile")
2566
2577
(declare-function projectile-find-file-other-window "ext:projectile")
2578
+ (declare-function projectile-project-root "ext:projectile")
2567
2579
2568
2580
(defun lispy-visit (arg)
2569
2581
"Forward to find file in project depending on ARG."
@@ -3155,12 +3167,17 @@ For example, a `setq' statement is amended with variable name that it uses."
3155
3167
(let ((dirs
3156
3168
(split-string
3157
3169
(shell-command-to-string
3158
- (format "find %s -type d ! -regex \".*\\.git.*\"" default-directory))
3170
+ (format "find %s -type d ! -regex \".*\\(\\ .git\\|\\.cask\\) .*\"" default-directory))
3159
3171
"\n"
3160
3172
t)))
3161
3173
(apply #'append
3162
3174
(mapcar #'lispy--fetch-tags dirs))))
3163
3175
3176
+ (defun lispy--fetch-tags-projectile ()
3177
+ "Fetch all tags in the projectile directory recursively."
3178
+ (let ((default-directory (projectile-project-root)))
3179
+ (lispy--fetch-tags-recursive)))
3180
+
3164
3181
(defun lispy--set-file-to-tags (file tags)
3165
3182
"Put FILE as property of each tag in TAGS."
3166
3183
(mapcar
@@ -3185,7 +3202,7 @@ For example, a `setq' statement is amended with variable name that it uses."
3185
3202
"Fetch this file tags."
3186
3203
(let ((tags
3187
3204
(lispy--set-file-to-tags
3188
- (file-name-nondirectory ( buffer-file-name) )
3205
+ (buffer-file-name)
3189
3206
(semantic-fetch-tags))))
3190
3207
(when (memq major-mode '(lisp-mode emacs-lisp-mode))
3191
3208
(lexical-let ((arity (cdr (assoc major-mode lispy-tag-arity)))
@@ -3859,6 +3876,15 @@ Unless inside string or comment, or `looking-back' at CONTEXT."
3859
3876
3860
3877
(declare-function helm "ext:helm")
3861
3878
3879
+ (defun lispy--current-tag ()
3880
+ "Forward to `semantic-current-tag'.
3881
+ Try to refresh if nil is returned."
3882
+ (let ((tag (semantic-current-tag)))
3883
+ (unless tag
3884
+ (semantic-clear-toplevel-cache)
3885
+ (semantic-fetch-tags))
3886
+ (semantic-tag-name tag)))
3887
+
3862
3888
(defun lispy--select-candidate (candidates action)
3863
3889
"Select from CANDIDATES list with `helm'.
3864
3890
ACTION is called for the selected candidate."
@@ -3877,7 +3903,9 @@ ACTION is called for the selected candidate."
3877
3903
(cons (car x) x))
3878
3904
x))
3879
3905
candidates))
3880
- (action . ,action)))))
3906
+ (action . ,action))
3907
+ :preselect (regexp-quote (or (lispy--current-tag)
3908
+ "")))))
3881
3909
3882
3910
(defun lispy--action-jump (tag)
3883
3911
"Jump to TAG."
@@ -3888,8 +3916,8 @@ ACTION is called for the selected candidate."
3888
3916
(semantic--tag-set-overlay
3889
3917
tag
3890
3918
(setq overlay
3891
- (make-overlay (aref overlay 0)
3892
- (aref overlay 1)
3919
+ (make-overlay (or ( aref overlay 0) 1 )
3920
+ (or ( aref overlay 1) 1)
3893
3921
(find-file (aref overlay 2))))))
3894
3922
(t (error "Unexpected")))
3895
3923
(push-mark)
@@ -4413,25 +4441,27 @@ FUNC is obtained from (`lispy--insert-or-call' DEF PLIST)"
4413
4441
(eldoc-add-command func)
4414
4442
(define-key keymap (kbd key) func)))
4415
4443
4416
- (lispy-defverb
4417
- "other"
4418
- (("h" lispy-move-left)
4419
- ("j" lispy-down-slurp)
4420
- ("k" lispy-up-slurp)
4421
- ("l" lispy-move-right)
4422
- ("SPC" lispy-other-space)))
4423
-
4424
4444
(lispy-defverb
4425
4445
"goto"
4426
4446
(("d" lispy-goto)
4427
- ("f " lispy-goto-local)
4447
+ ("l " lispy-goto-local)
4428
4448
("r" lispy-goto-recursive)
4429
- ("c" lispy-follow)
4430
- ("b" pop-global-mark)
4449
+ ("p" lispy-goto-projectile)
4450
+ ("f" lispy-follow)
4451
+ ("b" pop-tag-mark)
4431
4452
("q" lispy-quit)
4432
4453
("j" lispy-goto-def-down)
4433
4454
("a" lispy-goto-def-ace)))
4434
4455
4456
+ (lispy-defverb
4457
+ "other"
4458
+ (("h" lispy-move-left)
4459
+ ("j" lispy-down-slurp)
4460
+ ("k" lispy-up-slurp)
4461
+ ("l" lispy-move-right)
4462
+ ("SPC" lispy-other-space)
4463
+ ("g" lispy-goto-mode)))
4464
+
4435
4465
(lispy-defverb
4436
4466
"transform"
4437
4467
(("o" lispy-oneline)
0 commit comments