summaryrefslogtreecommitdiff
path: root/init.el
diff options
context:
space:
mode:
authorGravatar Uko Kokņevičs2024-11-02 21:41:25 +0200
committerGravatar Uko Kokņevičs2024-11-02 21:41:25 +0200
commit097d54aeb3536a63b63ae8d0249c203bb1e84202 (patch)
tree3e085ca93bfbd843d398be7773c51c81550a4aca /init.el
parentReplace catppuccin theme with modus-operandi (diff)
downloademacs.d-097d54aeb3536a63b63ae8d0249c203bb1e84202.tar.gz
emacs.d-097d54aeb3536a63b63ae8d0249c203bb1e84202.tar.xz
emacs.d-097d54aeb3536a63b63ae8d0249c203bb1e84202.zip
Move my project implementation into a new file.
Diffstat (limited to 'init.el')
-rw-r--r--init.el141
1 files changed, 4 insertions, 137 deletions
diff --git a/init.el b/init.el
index 37c43b1..c2bca95 100644
--- a/init.el
+++ b/init.el
@@ -41,6 +41,8 @@
41(when (file-exists-p custom-file) 41(when (file-exists-p custom-file)
42 (load custom-file)) 42 (load custom-file))
43 43
44(add-to-list 'load-path (expand-file-name "arkta" user-emacs-directory))
45
44;; Improve Emacs security somewhat 46;; Improve Emacs security somewhat
45(setq gnutls-min-prime-bits 3072 47(setq gnutls-min-prime-bits 3072
46 gnutls-verify-error (and (fboundp 'gnutls-available-p) 48 gnutls-verify-error (and (fboundp 'gnutls-available-p)
@@ -520,143 +522,8 @@
520 :hook (prog-mode . prettify-prog-mode) 522 :hook (prog-mode . prettify-prog-mode)
521 :hook (scheme-mode . prettify-lisp-modes)) 523 :hook (scheme-mode . prettify-lisp-modes))
522 524
523;; TODO: See about porting this to project.el: 525;; use-package project
524;; (define-key map (kbd "a") #'projectile-find-other-file) 526(require 'arkta-project)
525;; (define-key map (kbd "E") #'projectile-edit-dir-locals)
526;; (define-key map (kbd "g") #'projectile-find-file-dwim)
527;; (define-key map (kbd "i") #'projectile-invalidate-cache)
528;; (define-key map (kbd "I") #'projectile-ibuffer)
529;; (define-key map (kbd "j") #'projectile-find-tag)
530;; (define-key map (kbd "l") #'projectile-find-file-in-directory)
531;; (define-key map (kbd "m") #'projectile-commander)
532;; (define-key map (kbd "o") #'projectile-multi-occur)
533;; (define-key map (kbd "q") #'projectile-switch-open-project)
534;; (define-key map (kbd "R") #'projectile-regenerate-tags)
535
536;; (define-key map (kbd "s r") #'projectile-ripgrep)
537;; (define-key map (kbd "s s") #'projectile-ag)
538
539;; (define-key map (kbd "S") #'projectile-save-project-buffers)
540;; (define-key map (kbd "t") #'projectile-toggle-between-implementation-and-test)
541;; (define-key map (kbd "T") #'projectile-find-test-file)
542;; ;; project lifecycle external commands
543;; ;; TODO: Bundle those under some prefix key
544;; (define-key map (kbd "C") #'projectile-configure-project)
545;; (define-key map (kbd "K") #'projectile-package-project)
546;; (define-key map (kbd "L") #'projectile-install-project)
547;; (define-key map (kbd "P") #'projectile-test-project)
548;; (define-key map (kbd "u") #'projectile-run-project)
549
550;; ;; integration with utilities
551;; (define-key map (kbd "x i") #'projectile-run-ielm)
552;; (define-key map (kbd "x t") #'projectile-run-term)
553;; (define-key map (kbd "x g") #'projectile-run-gdb)
554;; (define-key map (kbd "x v") #'projectile-run-vterm)
555;; (define-key map (kbd "x 4 v") #'projectile-run-vterm-other-window)
556
557;; ;; misc
558;; (define-key map (kbd "z") #'projectile-cache-current-file)
559;; (define-key map (kbd "<left>") #'projectile-previous-project-buffer)
560;; (define-key map (kbd "<right>") #'projectile-next-project-buffer)
561;; (define-key map (kbd "ESC") #'projectile-project-buffers-other-buffer)
562
563(use-package project
564 :straight '(project :type built-in)
565 :init
566 (cl-defun arkta/project-completing-read (prompt choices &key initial-input action (project (project-current t)))
567 "Present a project tailored PROMPT with CHOICES."
568 (require 'ivy)
569 (let ((prompt (arkta/project-prepend-project-name prompt project)))
570 (ivy-read prompt choices
571 :initial-input initial-input
572 :action action
573 :caller 'arkta/project-completing-read)))
574
575 (defun arkta/project-expand-root (name &optional project)
576 "Expand NAME to project root."
577 (let (project (or project (project-current t)))
578 (expand-file-name name (project-root project))))
579
580 (defun arkta/project-find-references (&optional symbol)
581 "Find all references to SYMBOL in the current project.
582
583A thin wrapper around `xref-references-in-directory'."
584 (interactive)
585 (require 'xref)
586 (let ((project-root (project-root (project-current t)))
587 (symbol (or symbol
588 (read-from-minibuffer "Lookup in project: " (arkta/symbol-at-point)))))
589 (xref-show-xrefs (xref-references-in-directory symbol project-root) nil)))
590
591 (defun arkta/project-magit-status ()
592 (interactive)
593 (magit-status (project-root (project-current t))))
594
595 (defun arkta/project-prepend-project-name (string &optional project)
596 "Prepend the current project's name to STRING."
597 (let ((project (or project (project-current t))))
598 (format "[%s] %s" (project-name project) string)))
599
600 (defun arkta/project-recentf ()
601 "Show a list of recently visited files in a project."
602 (interactive)
603 (let ((project (project-current t)))
604 (find-file (arkta/project-expand-root
605 (arkta/project-completing-read
606 "Recently visited files: "
607 (arkta/project-recentf-files project)
608 :project project)
609 project))))
610
611 (defun arkta/project-recentf-files (&optional project)
612 "Return a list of recently visited files in a project."
613 (require 'recentf)
614 (let* ((project (or project (project-current t)))
615 (project-root (expand-file-name (project-root project))))
616 (mapcar
617 (lambda (f) (file-relative-name f project-root))
618 (cl-remove-if-not
619 (lambda (f) (string-prefix-p project-root (expand-file-name f)))
620 recentf-list))))
621
622 (defun arkta/symbol-at-point ()
623 "Get the symbol at point and strip its properties."
624 (substring-no-properties (or (thing-at-point 'symbol) "")))
625
626 (defvar-keymap arkta/project-prefix-map
627 :parent project-prefix-map
628 "C-b" 'project-list-buffers
629
630 "!" 'project-shell-command
631 "&" 'project-async-shell-command
632
633 "4" 'project-other-window-command
634 "5" 'project-other-frame-command
635
636 "D" 'project-dired
637 "F" 'project-or-external-find-file
638 "V" 'project-vc-dir
639
640 "b" 'project-switch-to-buffer
641 "c" 'project-compile
642 "d" 'project-find-dir
643 "e" 'arkta/project-recentf
644 "f" 'project-find-file
645 "k" 'project-kill-buffers
646 "p" 'project-switch-project
647 "r" 'project-query-replace-regexp
648 "v" 'arkta/project-magit-status
649
650 "M-x" 'project-execute-extended-command
651
652 "s g" 'project-find-regexp
653 "s r" 'project-find-regexp
654 "s x" 'arkta/project-find-references
655
656 "x e" 'project-eshell
657 "x s" 'project-shell)
658 (fset 'arkta/project-prefix-map arkta/project-prefix-map)
659 :bind (("C-c p" . arkta/project-prefix-map)))
660 527
661(use-package prolog 528(use-package prolog
662 :straight '(prolog :type built-in) 529 :straight '(prolog :type built-in)