summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/ai-config.el4
-rw-r--r--modules/calibredb-epub-config.el4
-rw-r--r--modules/dirvish-config.el121
-rw-r--r--modules/elfeed-config.el2
-rw-r--r--modules/epa-config.el3
-rw-r--r--modules/games-config.el5
-rw-r--r--modules/mail-config.el26
-rw-r--r--modules/modeline-config.el4
-rw-r--r--modules/prog-general.el3
-rw-r--r--modules/prog-training.el2
-rw-r--r--modules/system-utils.el5
-rw-r--r--modules/user-constants.el50
12 files changed, 121 insertions, 108 deletions
diff --git a/modules/ai-config.el b/modules/ai-config.el
index e4ef932e..01b089ce 100644
--- a/modules/ai-config.el
+++ b/modules/ai-config.el
@@ -50,8 +50,8 @@
. "You are a large language model and a conversation partner. Respond
concisely.")))
- ;; grab the secret from ~/.authinfo.gpg
- (setq auth-sources '((:source "~/.authinfo.gpg")))
+ ;; grab the secret from the auth file
+ (setq auth-sources `((:source ,authinfo-file)))
(setq gptel-api-key (auth-source-pick-first-password :host "api.openai.com")))
(provide 'ai-config)
diff --git a/modules/calibredb-epub-config.el b/modules/calibredb-epub-config.el
index 11aca93d..db86dd1e 100644
--- a/modules/calibredb-epub-config.el
+++ b/modules/calibredb-epub-config.el
@@ -24,8 +24,8 @@
("l" . calibredb-filter-by-tag))
:config
;; basic config
- (setq calibredb-root-dir "~/sync/books/")
- (setq calibredb-library-alist '(("~/sync/books/")))
+ (setq calibredb-root-dir books-dir)
+ (setq calibredb-library-alist (list books-dir))
(setq calibredb-db-dir (expand-file-name "metadata.db" calibredb-root-dir))
(setq calibredb-program "/usr/bin/calibredb")
(setq calibredb-preferred-format "epub")
diff --git a/modules/dirvish-config.el b/modules/dirvish-config.el
index 12f67519..d5dc6c33 100644
--- a/modules/dirvish-config.el
+++ b/modules/dirvish-config.el
@@ -17,7 +17,7 @@
(:map dired-mode-map
([remap dired-summary] . which-key-show-major-mode)
("E" . wdired-change-to-wdired-mode) ;; edit names/properties in buffer
- ("e" . cj/dired-ediff-files)) ;; ediff files
+ ("e" . cj/dired-ediff-files)) ;; ediff files
:custom
(dired-use-ls-dired nil) ;; non GNU FreeBSD doesn't support a "--dired" switch
:config
@@ -31,6 +31,20 @@
;; (add-hook 'dired-mode-hook 'auto-revert-mode) ;; auto revert dired when files change
+;; ------------------------------ Dired Open With ------------------------------
+
+
+(defun cj/dired-open-with (command)
+ "Open the dired file at point with a user-specified COMMAND.
+This function is meant to be called interactively. It prompts for the command to
+open the file with if called without a parameter. The command runs
+asynchronously and its output is saved in a buffer, but the buffer is not
+automatically displayed."
+ (interactive "sCommand to use to open the file: ")
+ (let* ((file (dired-get-file-for-visit))
+ (buff (generate-new-buffer (concat "*dired-open-with output: " file "*"))))
+ (start-process-shell-command command buff (concat command " " file))))
+
;; -------------------------- Dired Copy Path As Kill --------------------------
;; copies the full path of the file at point to the clipboard
@@ -38,11 +52,11 @@
"Copy the full path of file at point in dired to the clipboard."
(interactive)
(let ((filename (dired-get-file-for-visit)))
- (if (and filename (file-exists-p filename))
- (progn
- (kill-new filename)
- (message "Copied '%s' to clipboard." filename))
- (message "No file at point."))))
+ (if (and filename (file-exists-p filename))
+ (progn
+ (kill-new filename)
+ (message "Copied '%s' to clipboard." filename))
+ (message "No file at point."))))
;; ------------------------ Dired Convert Image To Jpeg ------------------------
;; converts the image at point to a jpeg
@@ -50,16 +64,16 @@
(defun cj/dired-convert-image-to-jpeg ()
(interactive)
(let* ((original-file (dired-get-file-for-visit))
- (file-extension (file-name-extension original-file))
- (jpeg-file (concat (file-name-sans-extension original-file) ".jpeg")))
- (if (member file-extension '("png" "bmp" "gif" "tif" "tiff" "svg" "webp"))
- (if (string= file-extension "jpeg")
- (message "File is already in JPEG format.")
- (start-process "convert-to-jpeg" nil "convert" original-file jpeg-file)
- (message "Conversion started for %s" original-file))
- (message (concat "File is not a supported image file type."
- "Current supported types: "
- "'png' 'bmp' 'gif' 'tif' 'tiff' 'svg' 'webp'")))))
+ (file-extension (file-name-extension original-file))
+ (jpeg-file (concat (file-name-sans-extension original-file) ".jpeg")))
+ (if (member file-extension '("png" "bmp" "gif" "tif" "tiff" "svg" "webp"))
+ (if (string= file-extension "jpeg")
+ (message "File is already in JPEG format.")
+ (start-process "convert-to-jpeg" nil "convert" original-file jpeg-file)
+ (message "Conversion started for %s" original-file))
+ (message (concat "File is not a supported image file type."
+ "Current supported types: "
+ "'png' 'bmp' 'gif' 'tif' 'tiff' 'svg' 'webp'")))))
;; ------------------------ Dired Mark All Visible Files -----------------------
;; convenience function to mark all visible files in dired
@@ -81,30 +95,26 @@
:after dired
:custom
(dirvish-quick-access-entries
- '(("h" "~/" "home")
+ `(("h" ,user-home-dir "home")
+ ("cx" ,code-dir "code diredtory")
+ ("ws" ,(concat code-dir "/website") "website staging")
+ ("dr" ,(concat sync-dir "/drill/") "drill files")
+ ("s" ,sync-dir "sync directory")
+ ("mp" ,(concat sync-dir "/playlists") "music playlists")
+ ("px" ,projects-dir "projects directory")
+ ("tg" ,(concat sync-dir "/text.games") "text games")
+ ("ps" ,(concat pix-dir "/screenshots/") "pictures screenshots")
+ ("pw" ,(concat pix-dir "/wallpaper/") "pictures wallpaper")
+ ("px" ,pix-dir "pictures directory")
+ ("dl" ,dl-dir "downloads")
+ ("dt" ,(concat dl-dir "/torrents/complete/") "torrents")
+ ("vx" ,videos-dir "videos")
+ ("df" "~/.dotfiles/" "dotfiles")
+ ("dx" "~/documents/" "documents")
+ ("mx" "~/music/" "music")
+ ("rcj" "/sshx:cjennings@cjennings.net:~" "remote cjennings.net")
("rsb" "/sshx:cjennings@wolf.usbx.me:/home/cjennings/" "remote seedbox")
- ("rcj" "/sshx:cjennings@cjennings.net:~" "remote cjennings.net")
- ("co" "~/code" "code")
- ("cj" "~/code/cjennings-net" "cjennings.net hugo")
- ("df" "~/.dotfiles/" "dotfiles")
- ("dn" "~/downloads/" "downloads")
- ("dr" "~/sync/org/drill/" "org drill files")
- ("dt" "~/downloads/torrents/complete/" "torrents")
- ("dx" "~/documents/" "documents")
- ("gc" "~/code/golangcourse" "golang course")
- ("lt" "~/.local/share/Trash" "trash")
- ("mp" "~/sync/playlists/" "playlists")
- ("mv" "~/magic/video/" "magic/video")
- ("mx" "~/music/" "music")
- ("my" "~/magic/youtube/" "magic/youtube")
- ("or" "~/sync/org/" "sync")
- ("pl" "~/sync/playlists" "playlists")
- ("pr" "~/projects/" "projects")
- ("ps" "~/pictures/screenshots/" "screenshots")
- ("pw" "~/pictures/wallpaper" "wallpaper")
- ("px" "~/pictures/" "pictures")
- ("tg" "~/sync/org/text.games" "text games")
- ("vx" "~/videos/" "videos")))
+ )) ;; end dirvish-quick-access-entries
(dirvish-attributes '(vscode-icon file-size))
(dirvish-override-dired-mode t)
(dirvish-preview-dispatchers '(image gif video audio epub pdf archive))
@@ -124,8 +134,9 @@
("bg" . (lambda () (interactive) ; set background image
(shell-command (concat "nitrogen --save --set-zoom-fill "
(dired-file-name-at-point) " >>/dev/null 2>&1" ))))
- ("Z" . (lambda () (interactive) (cj/open-file-with-command "zathura")))
- ("P" . (lambda () (interactive) (cj/open-file-with-command "gimp")))
+ ("Z" . (lambda () (interactive) (cj/dired-open-with "zathura")))
+ ("P" . (lambda () (interactive) (cj/dired-open-with "gimp")))
+ ("O" . (lambda () (interactive) (call-interactively 'cj/dired-open-with)))
("<left>" . dired-up-directory)
("<right>" . dired-find-file)
("f" . dirvish-file-info-menu)
@@ -194,20 +205,20 @@
"Ediff two selected files within Dired."
(interactive)
(let ((files (dired-get-marked-files))
- (wnd (current-window-configuration)))
- (if (<= (length files) 2)
- (let ((file1 (car files))
- (file2 (if (cdr files)
- (cadr files)
- (read-file-name
- "file: "
- (dired-dwim-target-directory)))))
- (if (file-newer-than-file-p file1 file2)
- (ediff-files file2 file1)
- (ediff-files file1 file2))
- (add-hook 'ediff-after-quit-hook-internal
- (lambda ()
- (setq ediff-after-quit-hook-internal nil)
+ (wnd (current-window-configuration)))
+ (if (<= (length files) 2)
+ (let ((file1 (car files))
+ (file2 (if (cdr files)
+ (cadr files)
+ (read-file-name
+ "file: "
+ (dired-dwim-target-directory)))))
+ (if (file-newer-than-file-p file1 file2)
+ (ediff-files file2 file1)
+ (ediff-files file1 file2))
+ (add-hook 'ediff-after-quit-hook-internal
+ (lambda ()
+ (setq ediff-after-quit-hook-internal nil)
(set-window-configuration wnd))))
(error "No more than 2 files should be marked"))))
diff --git a/modules/elfeed-config.el b/modules/elfeed-config.el
index 4d4a80d1..076b6f1f 100644
--- a/modules/elfeed-config.el
+++ b/modules/elfeed-config.el
@@ -127,7 +127,7 @@
(defun cj/yt-dl-it (url)
"Downloads the URL in an async shell."
- (let ((default-directory "~/videos"))
+ (let ((default-directory videos-dir))
(save-window-excursion
(async-shell-command (format "tsp yt-dlp --add-metadata -ic -o '%%(channel)s-%%(title)s.%%(ext)s' '%s'" url)))))
diff --git a/modules/epa-config.el b/modules/epa-config.el
index 0e3972a0..8d902ae4 100644
--- a/modules/epa-config.el
+++ b/modules/epa-config.el
@@ -12,8 +12,7 @@
:ensure nil ;; built in
:demand t ;; load this package early
:config
- (setq auth-sources '("~/.authinfo.gpg"))
- ;; (setq auth-sources '((:source "~/.authinfo.gpg")))
+ (setq auth-sources `(,authinfo-file))
(setenv "GPG_AGENT_INFO" nil) ;; emacs use internal prompt, not gpg agent
(setq auth-source-debug t)) ;; echo debug info to Messages
diff --git a/modules/games-config.el b/modules/games-config.el
index e0439630..eab245e7 100644
--- a/modules/games-config.el
+++ b/modules/games-config.el
@@ -24,7 +24,7 @@
(use-package malyon
:defer 1
:config
- (setq malyon-stories-directory "~/sync/org/text.games/"))
+ (setq malyon-stories-directory (concat sync-dir "text.games/"))
;; ------------------------------------ 2048 -----------------------------------
;; combine numbered tiles to create the elusive number 2048.
@@ -37,7 +37,8 @@
:defer 1
:config
(setq chess-default-display 'chess-images)
- (setq chess-images-directory (concat user-emacs-directory "assets/chess/pieces/xboard/"))
+ (setq chess-images-directory
+ (concat user-emacs-directory "assets/chess/pieces/xboard/"))
(setq chess-images-dark-color "#779556")
(setq chess-images-light-color "#EBECD0")
(setq chess-images-default-size 100)
diff --git a/modules/mail-config.el b/modules/mail-config.el
index ac982814..2d9288ac 100644
--- a/modules/mail-config.el
+++ b/modules/mail-config.el
@@ -40,7 +40,7 @@
(setq mu4e-confirm-quit nil) ;; don't ask when quitting
(setq mu4e-context-policy 'pick-first) ;; start with the first (default) context
(setq mu4e-headers-auto-update nil) ;; updating headers buffer on email is too jarring
- (setq mu4e-root-maildir "~/.mail") ;; root directory for all email accounts
+ (setq mu4e-root-maildir mail-dir) ;; root directory for all email accounts
(setq mu4e-sent-messages-behavior 'delete) ;; don't save to "Sent", IMAP does this already
(setq mu4e-show-images t) ;; show embedded images
(setq mu4e-update-interval nil) ;; don't update automatically
@@ -149,15 +149,14 @@
;; ----------------------------- Compose Mode Hydra ----------------------------
-;; menu available in compose mode
+;; WIP: menu available in compose mode
(defhydra hydra-mu4e-compose (:color blue :timeout 10 :hint nil)
"Compose Mode Menu\n\n"
("q" quit-window "Quit" :column "")
("a" mail-add-attachment "Add Attachment" :column "")
("r" message-new-line-and-reformat "Newline and Reformat" :column "")
- ("d" message-delete-not-region "Delete Outside Region" :column "")
- )
+ ("d" message-delete-not-region "Delete Outside Region" :column ""))
(defun mu4e-compose-mode-hook-hydra-setup ()
"Create hydra/menu keybinding when entering compose mode."
@@ -177,34 +176,17 @@ Prompts user for the action when executing."
;;; ------------------ Smtpmail & Easy PG Assistant -----------------
-;; Send Mail to smtp host from smtpmail temp buffer.
+;; send mail to smtp host from smtpmail temp buffer.
(use-package smtpmail
:ensure nil ;; built-in
:defer .5
:config
- ;; (require 'epa-file)
- ;; (epa-file-enable)
- ;; (setq epa-pinentry-mode 'loopback)
- ;; (auth-source-forget-all-cached)
-
(setq message-kill-buffer-on-exit t) ;; don't keep compose buffers after sending
(setq sendmail-program (executable-find "msmtp"))
(setq send-mail-function 'message-send-mail-with-sendmail
message-send-mail-function 'message-send-mail-with-sendmail)
(setq message-sendmail-envelope-from 'header)
- ;; (setq smtpmail-auth-credentials (expand-file-name "~/.authinfo.gpg"))
- ;; (setq starttls-use-gnutls t)
- ;; (setq smtpmail-starttls-credentials '(("smtp.gmail.com" 587 nil nil)))
- ;; (setq smtpmail-default-smtp-server "smtp.gmail.com")
- ;; (setq smtpmail-smtp-server "smtp.gmail.com")
- ;; (setq smtpmail-smtp-service 587)
(setq smtpmail-debug-info t))
-;; BUG: queuing mu4e email doesn't currently work.
-;; if you need offline mode, set these -- and create the queue dir
-;; with 'mu mkdir', i.e.. mu mkdir ~/.mail/queued-mail/"
-;; (setq smtpmail-queue-mail nil)
-;; (setq smtpmail-queue-dir "~/.mail/queued-mail/"))
-
(provide 'mail-config)
;;; mail-config.el ends here
diff --git a/modules/modeline-config.el b/modules/modeline-config.el
index cea31660..6e45fc43 100644
--- a/modules/modeline-config.el
+++ b/modules/modeline-config.el
@@ -11,11 +11,13 @@
;;; Code:
-(defvar feebleline-working-directory "~/code/feebleline"
+(defvar feebleline-working-directory (concat code-dir "/feebleline")
"The working directory for the feebleline mode line.")
;; --------------------------------- Feebleline --------------------------------
;; ultrathin simple modeline. adds only useful info to echo area.
+;; working on a patch to fix a few issues
+;; load the non-packaged version only if the directory exists
(use-package feebleline
:if (file-readable-p feebleline-working-directory)
diff --git a/modules/prog-general.el b/modules/prog-general.el
index 2338564f..ee25c62b 100644
--- a/modules/prog-general.el
+++ b/modules/prog-general.el
@@ -81,8 +81,7 @@ If none exists, it opens magit-status."
("r" . projectile-replace-regexp))
:custom
(projectile-auto-discover nil)
- (projectile-project-search-path '("~/code"
- "~/projects"))
+ (projectile-project-search-path `(,code-dir ,projects-dir))
:config
;; scan for projects if none are defined
(cj/projectile-schedule-project-discovery)
diff --git a/modules/prog-training.el b/modules/prog-training.el
index 801b1982..bada3a0b 100644
--- a/modules/prog-training.el
+++ b/modules/prog-training.el
@@ -22,7 +22,7 @@
(url-debug t)
:config
(setq leetcode-prefer-language "golang")
- (setq leetcode-directory "~/code/leetcode")
+ (setq leetcode-directory (concat code-dir "/leetcode"))
(setq leetcode-save-solutions t))
diff --git a/modules/system-utils.el b/modules/system-utils.el
index 0ec287b9..bc1bba64 100644
--- a/modules/system-utils.el
+++ b/modules/system-utils.el
@@ -106,10 +106,11 @@ With a prefix argument, add the TARGET-BUFFER to \='cj/buffer-bury-alive-list\='
;; opens the current buffer's file with a command. Prompts if interactive.
(defun cj/open-file-with-command (command)
- "Asynchronously open the file for the current buffer with a specified COMMAND.
+ "Asynchronously open the file assocated with the current buffer with COMMAND.
Don't automatically display output buffers, but keep them in buffer list."
(interactive "MOpen with program: ")
- (let ((display-buffer-keywords '(("*Async Shell Command*" display-buffer-no-window (nil)))))
+ (let ((display-buffer-keywords
+ '(("*Async Shell Command*" display-buffer-no-window (nil)))))
(add-to-list 'display-buffer-alist display-buffer-keywords))
(async-shell-command (format "%s \"%s\"" command buffer-file-name)))
diff --git a/modules/user-constants.el b/modules/user-constants.el
index 6ed74d37..97cba1f4 100644
--- a/modules/user-constants.el
+++ b/modules/user-constants.el
@@ -10,55 +10,73 @@
;; ------------------------ Directory And File Constants -----------------------
;; DIRECTORIES
-(defconst user-home-dir (getenv "HOME")
- "The user's home directory per the environment variable.")
-
(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/")
+(defconst user-home-dir (getenv "HOME")
+ "The user's home directory per the environment variable.")
+
+(defconst books-dir (concat user-home-dir "/sync/books/")
+ "The location of org-roam files.")
+
+(defconst code-dir (concat user-home-dir "/code/")
"Code repositories are located in this directory.")
-(defconst projects-dir (concat user-home-dir "/projects/")
+(defconst dl-dir (concat user-home-dir "/downloads/")
+ "Location of the general downloads directory.")
+
+(defconst pix-dir (concat user-home-dir "/pictures/")
+ "Location of where pictures and images are stored.")
+
+(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/")
+(defconst videos-dir (concat user-home-dir "/videos/")
+ "Location of where videos are stored.")
+
+(defconst mail-dir (concat user-home-dir ".mail/")
+ "Root directory where the mail folders are located.")
+
+(defconst sync-dir (concat user-home-dir "/sync/org/")
"This directory is synchronized across machines.")
-(defconst roam-dir (concat sync-dir "roam/")
+(defconst roam-dir (concat sync-dir "roam/")
"The location of org-roam files.")
-(defconst drill-dir (concat sync-dir "drill/")
+(defconst drill-dir (concat sync-dir "drill/")
"The location of org-drill org files.")
-(defconst snippets-dir (concat sync-dir "snippets/")
+(defconst snippets-dir (concat sync-dir "snippets/")
"The location of ya-snippet snippets.")
;; FILES
-(defvar schedule-file (concat sync-dir "schedule.org")
+(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")
+(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")
+(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")
+(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")
+(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")
+(defvar ledger-file (concat sync-dir "main.ledger")
"The location of the user's ledger file.")
-(defvar macros-file (concat sync-dir "macros.el")
+(defvar macros-file (concat sync-dir "macros.el")
"The location of the macros file for recorded saved macros via M-f3.")
+(defvar authinfo-file (concat user-home-dir "/.authinfo.gpg")
+ "The location of the encrypted .authinfo or .netrc file.")
+
;; ------------------------- Verify Or Create Functions ------------------------
(defun cj/verify-or-create-dir (dir)