blob: f42389d551e9a08111f2b468d43aacb23a7e9dd5 (
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
;;; user-constants.el --- User Constants -*- lexical-binding: t; -*-
;;; Commentary:
;; User file locations are defined here. A file or directory is created if it
;; doesn't exist. Note the keybindings at the bottom for quick access.
;;; Code:
;; ------------------------ Directory And File Constants -----------------------
## DIRECTORIES
(defconst emacs-init-file (concat user-emacs-directory "init.el")
"The location of Emacs's main init file.")
(defconst emacs-early-init-file (concat user-emacs-directory "early-init.el")
"The location of Emacs's early init file.")
(defconst code-dir (concat user-home-dir "/code/")
"Code repositories are located in this directory.")
(defconst projects-dir (concat user-home-dir "/projects/")
"Non-code projects and repositories are located in this directory.")
(defconst sync-dir (concat user-home-dir "/sync/org/")
"This directory is synchronized across machines.")
(defconst roam-dir (concat sync-dir "roam/")
"The location of org-roam files.")
(defconst drill-dir (concat sync-dir "drill/")
"The location of org-drill org files.")
(defconst snippets-dir (concat sync-dir "snippets/")
"The location of ya-snippet snippets.")
### FILES
(defvar schedule-file (concat sync-dir "schedule.org")
"The location of the org file containing scheduled events.")
(defvar inbox-file (concat roam-dir "inbox.org")
"The location of the org file that serves as the task inbox.")
(defvar contacts-file (concat sync-dir "contacts.org")
"The location of the org file containing org-contacts information.")
(defvar article-file (concat sync-dir "article-inbox.org")
"The location of the org file containing new clipped pages to review.")
(defvar article-archive (concat sync-dir "article-archive.org")
"The location of the org file that stores saved articples to keep.")
;
(defvar ledger-file (concat sync-dir "main.ledger")
"The location of the user's ledger file.")
(defvar macros-file (concat sync-dir "macros.el")
"The location of the macros file for recorded saved macros via M-f3.")
;; ------------------------- Verify Or Create Functions ------------------------
(defun cj/verify-or-create-dir (dir)
"Verify the directory DIR exists; create it if it doesn't."
(unless (file-directory-p dir)
(make-directory dir t)
(message "Warning: Directory %s not found, so created it" dir)))
(defun cj/verify-or-create-file (file)
"Verify the file FILE exists; create it if it doesn't."
(unless (file-exists-p file)
(write-region "" nil file)
(message "Warning: File %s not found, so created it" file)))
;; ------------------------- Verify Or Create Constants ------------------------
(mapc 'cj/verify-or-create-dir (list sync-dir
roam-dir
snippets-dir))
(mapc 'cj/verify-or-create-file (list schedule-file
inbox-file
contacts-file
article-file
article-archive
ledger-file
macros-file))
;; ------------------------------ Jump To Commands -----------------------------
;; quick access for commonly used files
(defvar jump-to-keymap nil "Jump-to commonly used files/directories/commands.")
(setq jump-to-keymap (make-sparse-keymap))
(global-set-key (kbd "C-c j") jump-to-keymap)
(define-key jump-to-keymap (kbd "s") #'(lambda () (interactive) (find-file schedule-file)))
(define-key jump-to-keymap (kbd "i") #'(lambda () (interactive) (find-file inbox-file)))
(define-key jump-to-keymap (kbd "c") #'(lambda () (interactive) (find-file contacts-file)))
(define-key jump-to-keymap (kbd "a") #'(lambda () (interactive) (find-file article-file)))
(define-key jump-to-keymap (kbd "A") #'(lambda () (interactive) (find-file article-archive)))
(define-key jump-to-keymap (kbd "$") #'(lambda () (interactive) (find-file ledger-file)))
(define-key jump-to-keymap (kbd "m") #'(lambda () (interactive) (find-file macros-file)))
(define-key jump-to-keymap (kbd "I") #'(lambda () (interactive) (find-file emacs-init-file)))
(provide 'user-constants)
;;; user-constants.el ends here.
|