aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorAdrian Kummerlaender2020-06-11 20:27:25 +0200
committerAdrian Kummerlaender2020-06-11 20:27:25 +0200
commit8a80e2e6645c261d69480beb0c1695164f64cdfb (patch)
tree4357b6c3fd3af78654c3cb73d792311ec864aa73 /gui
parent8b41edda483921cdfce8b8a3d51f7028584a36bf (diff)
downloadnixos_home-8a80e2e6645c261d69480beb0c1695164f64cdfb.tar
nixos_home-8a80e2e6645c261d69480beb0c1695164f64cdfb.tar.gz
nixos_home-8a80e2e6645c261d69480beb0c1695164f64cdfb.tar.bz2
nixos_home-8a80e2e6645c261d69480beb0c1695164f64cdfb.tar.lz
nixos_home-8a80e2e6645c261d69480beb0c1695164f64cdfb.tar.xz
nixos_home-8a80e2e6645c261d69480beb0c1695164f64cdfb.tar.zst
nixos_home-8a80e2e6645c261d69480beb0c1695164f64cdfb.zip
Implement custom related file jumping logic in Emacs
Neither projectile nor ff-find-other-file's offering do what I want in a straight forward manner. The former is still added as it is useful for project management (currently mostly regenerating ctags files).
Diffstat (limited to 'gui')
-rw-r--r--gui/conf/init.el24
1 files changed, 24 insertions, 0 deletions
diff --git a/gui/conf/init.el b/gui/conf/init.el
index c9d2da4..1359f52 100644
--- a/gui/conf/init.el
+++ b/gui/conf/init.el
@@ -247,3 +247,27 @@
(add-hook 'c-mode-common-hook 'hs-minor-mode t)
(add-hook 'c-mode-common-hook 'hs-hide-initial-comment-block t)
+
+(use-package projectile
+ :ensure t
+ :config
+ (setq projectile-completion-system 'ivy))
+
+(defun get-related-files ()
+ (let ((common-basename-files (seq-filter (lambda (file) (string= (file-name-sans-extension file) (file-name-base)))
+ (directory-files "."))))
+ (sort (seq-remove (lambda (file) (string= file (buffer-name)))
+ common-basename-files)
+ #'string-greaterp)))
+
+(defun jump-to-related ()
+ (interactive)
+ (find-file (ivy-read "related:" (get-related-files))))
+
+(defun jump-to-first-related ()
+ (interactive)
+ (find-file (car (get-related-files))))
+
+(evil-define-key 'normal prog-mode-map
+ (kbd "<tab>") 'jump-to-first-related
+ (kbd "M-r") 'jump-to-related)