Fix an issue with eglot and projects.el loading
This commit is contained in:
parent
db3638593a
commit
66c5ef25cf
2 changed files with 8 additions and 3 deletions
80
userland/theurgy-projects.el
Normal file
80
userland/theurgy-projects.el
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
;;; theurgy-projects.el --- Project management configuration with whaler -*- lexical-binding: t -*-
|
||||
|
||||
;; This file is not part of GNU Emacs
|
||||
|
||||
;; This program is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; commentary
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'subr-x)
|
||||
|
||||
(defcustom theurgy-project-default-file-alist '(("~/.emacs.d" . "init.el"))
|
||||
"This alist specifies which file (relative to the project root) to open in the main frame by default when opening a project."
|
||||
:group 'theurgy
|
||||
:group 'theurgy-projects
|
||||
:group 'whaler)
|
||||
|
||||
(use-package whaler
|
||||
:ensure t
|
||||
:config
|
||||
(whaler-populate-projects-directories)
|
||||
)
|
||||
|
||||
(defun get-project-default-file (dir)
|
||||
"Get the project default file for `DIR', regardless of whether either path is absolute or relative."
|
||||
(let ((absolute-project-dir (expand-file-name (string-remove-suffix "/" dir)))
|
||||
(absolute-project-default-file-alist (mapcar (lambda (x) `(,(string-remove-suffix "/" (expand-file-name (car x))) . ,(cdr x)))
|
||||
theurgy-project-default-file-alist)))
|
||||
(or (file-name-concat dir (cdr (assoc absolute-project-dir absolute-project-default-file-alist))) dir)))
|
||||
|
||||
(defun theurgy-open-project ()
|
||||
"Select a project and update neotree to use it as root."
|
||||
(interactive)
|
||||
(whaler :action (lambda (dir)
|
||||
(find-file (get-project-default-file dir))
|
||||
(tab-rename (file-name-nondirectory (string-remove-suffix "/" dir)))
|
||||
(tab-bar-change-tab-group (concat "project: " dir)) ;; We use the tab group name to store the project working directory
|
||||
(save-selected-window
|
||||
(neotree-dir dir)))))
|
||||
|
||||
(defun theurgy-swap-to-tab-project ()
|
||||
"Go to the project dir of the tab group."
|
||||
(let ((tab-group-name (tab-bar-tab-group-default (tab-bar--current-tab))))
|
||||
(when (and tab-group-name (string-match-p "^project:" tab-group-name))
|
||||
(save-selected-window
|
||||
(neotree-dir (string-remove-prefix "project: " tab-group-name))))))
|
||||
|
||||
(defun theurgy-get-tab-project-dir ()
|
||||
"Get the directory of the project in the current tab.
|
||||
This returns nil if no project is found."
|
||||
(let ((tab-group-name (tab-bar-tab-group-default (tab-bar--current-tab))))
|
||||
(if (and tab-group-name (string-match-p "^project:" tab-group-name))
|
||||
(string-remove-prefix "project: " tab-group-name)
|
||||
nil)))
|
||||
|
||||
(add-hook 'tab-bar-select-tab-hook #'theurgy-swap-to-tab-project)
|
||||
|
||||
(defun theurgy-edit-projects-list ()
|
||||
"Open list of projects in customize."
|
||||
(interactive)
|
||||
(customize-group 'whaler))
|
||||
|
||||
(provide 'theurgy-projects)
|
||||
|
||||
;;; theurgy-projects.el ends here
|
||||
Loading…
Add table
Add a link
Reference in a new issue