blob: df49de12fe1f19382a7c85f823406d90c977631c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
;;; mf-perspective.el --- Configuration for perspective.el -*- lexical-binding: t -*-
;;; Commentary:
;; Use `perspective' to separate project views.
;;; Code:
(mf/install perspective)
(setq
persp-mode-prefix-key (kbd "C-z")
persp-state-default-file (concat user-emacs-directory "persp-state"))
(persp-mode)
(define-key perspective-map (kbd "TAB") #'persp-switch-last)
(advice-add #'shell :after #'(lambda (&rest _) (persp-set-buffer (buffer-name))))
(mf/install f)
(require 'f)
(defmacro with-perspective (perspective &rest body)
"Execute `BODY' in `PERSPECTIVE'."
`(progn
(persp-switch ,perspective)
,@body))
(defun mf/project-find-file-and-persp ()
"Do a `project-find-file' and open files in a dedicated project perspective."
(interactive)
(let* ((pr (project-current t))
(dir (project-root pr)))
(with-perspective (f-base dir)
(cd dir)
(project-find-file-in (thing-at-point 'filename) (list dir) pr))))
;; keybindings
(global-set-key (kbd "C-x p f") #'mf/project-find-file-and-persp)
(global-set-key (kbd "C-x k") #'persp-kill-buffer*)
(with-eval-after-load 'consult
;; hide full buffer list (still available with "b")
(consult-customize consult--source-buffer :hidden t :default t)
;; set consult-workspace buffer list
(defvar consult--source-workspace
(list :name "Workspace Buffers"
:narrow ?w
:category 'buffer
:state #'consult--buffer-state
:default t
:items #'persp-current-buffer-names
:action #'consult--buffer-action)
"Set workspace buffer list for consult-buffer.")
(push 'consult--source-workspace consult-buffer-sources))
(provide 'mf-perspective)
;;; mf-perspective.el ends here
|