summaryrefslogtreecommitdiff
path: root/.config/emacs
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2024-11-02 13:14:28 -0400
committerbd <bdunahu@operationnull.com>2024-11-02 13:14:28 -0400
commit13d96f5b959c3c2a6d64910a7b719999489661d1 (patch)
treeeb1f4a978c0a77e40aaf99588c727b3ca476bfed /.config/emacs
parent0e971a7d8be33c208394d9b195985794284317a7 (diff)
Scratch buffers categorized in switch-to-buffer
Diffstat (limited to '.config/emacs')
-rw-r--r--.config/emacs/init.el4
-rw-r--r--.config/emacs/modules/bd--files.el11
-rw-r--r--.config/emacs/modules/bd--minibuffer.el6
-rw-r--r--.config/emacs/modules/bd--notes.el9
4 files changed, 27 insertions, 3 deletions
diff --git a/.config/emacs/init.el b/.config/emacs/init.el
index 38e6c1c..25a3234 100644
--- a/.config/emacs/init.el
+++ b/.config/emacs/init.el
@@ -72,7 +72,7 @@
;; external package manager
(setopt package-archives nil
package-enable-at-startup t)
-;; path to system-level packages
+;; path to guix-provided packages
(add-to-list 'load-path (expand-file-name "~/.guix-home/profile/share/emacs/site-lisp"))
(guix-emacs-autoload-packages)
;; use-package
@@ -88,7 +88,7 @@
;;;; load modules
-(require 'bd--secret) ;; (gitignored)
+(require 'bd--secret) ;; (contains bookmarks/email vars---git ignored)
(require 'bd--browse)
(require 'bd--rss)
(require 'bd--gpg)
diff --git a/.config/emacs/modules/bd--files.el b/.config/emacs/modules/bd--files.el
index f050132..ab6c56a 100644
--- a/.config/emacs/modules/bd--files.el
+++ b/.config/emacs/modules/bd--files.el
@@ -20,6 +20,15 @@
(defun bd/nsxiv (file)
"Open FILE with nsxiv."
(start-process "nsxiv" nil "nsxiv" (expand-file-name file)))
+(defun bd/rom (file)
+ "Open FILE with an emulator."
+ (let ((command
+ (cdr (assoc (file-name-extension file)
+ '(("gba" . "mgba")
+ ("z64" . "mupen64plus")
+ ("n64" . "mupen64plus")
+ ("sfc" . "bsnes"))))))
+ (start-process command nil command (expand-file-name file))))
(defun bd/external-find-file-wrapper (f &rest args)
"Wrapper around F (find-file), passing ARGS."
@@ -37,6 +46,8 @@
((string-match (regexp-opt '("jpg" "jpeg" "png" "webp"
"ico" "gif" "JPG" "PNG")) ext)
(runner #'bd/nsxiv))
+ ((string-match (regexp-opt '("gba" "z64" "n64" "sfc")) ext)
+ (runner #'bd/rom))
(t (apply f args)))))
(advice-add 'find-file :around #'bd/external-find-file-wrapper)
diff --git a/.config/emacs/modules/bd--minibuffer.el b/.config/emacs/modules/bd--minibuffer.el
index 844f7b3..2827cff 100644
--- a/.config/emacs/modules/bd--minibuffer.el
+++ b/.config/emacs/modules/bd--minibuffer.el
@@ -28,6 +28,10 @@ selection commands.")
(buffer-local-value 'major-mode (get-buffer buf))
'(exwm-mode)))
+(defun bd/buffer-scratch-p (buf)
+ "Return non-nil if BUF is a scratch buffer."
+ (buffer-local-value 'scratch-buffer (get-buffer buf)))
+
(defun bd/buffer-text-p (buf)
"Return non-nil if BUF derives from `text-mode'."
(provided-mode-derived-p (buffer-local-value 'major-mode (get-buffer buf)) 'text-mode))
@@ -58,6 +62,7 @@ selection commands.")
(not (or (bd/buffer-exwm-p buf)
(bd/buffer-text-p buf)
(bd/buffer-prog-p buf)
+ (bd/buffer-scratch-p buf)
(bd/buffer-dired-p buf)
(bd/buffer-erc-p buf))))
@@ -102,6 +107,7 @@ selection commands.")
(bd/selector-buffer-type "EXWM" #'bd/buffer-exwm-p)
(bd/selector-buffer-type "Text" #'bd/buffer-text-p)
(bd/selector-buffer-type "Source" #'bd/buffer-prog-p)
+ (bd/selector-buffer-type "Scratch" #'bd/buffer-scratch-p)
(bd/selector-buffer-type "Directories" #'bd/buffer-dired-p)
(bd/selector-buffer-type "IRC" #'bd/buffer-erc-p)
(bd/selector-buffer-type "Ordinary" #'bd/buffer-ordinary-p)
diff --git a/.config/emacs/modules/bd--notes.el b/.config/emacs/modules/bd--notes.el
index b83b71e..678e4d9 100644
--- a/.config/emacs/modules/bd--notes.el
+++ b/.config/emacs/modules/bd--notes.el
@@ -3,6 +3,9 @@
;;; Code:
+(defvar scratch-buffer nil
+ "Non-nil if the current buffer is a scratch buffer.")
+(make-variable-buffer-local 'scratch-buffer)
(defun bd/send-to-scratch ()
"Creates/switches to the scratch for `major-mode',
then pastes the active region."
@@ -16,10 +19,15 @@ then pastes the active region."
(pop-to-buffer
(with-current-buffer (get-buffer-create name)
(funcall mode)
+ (setq-local scratch-buffer t)
(when contents
(insert (format "\n\n%s" contents)))
(current-buffer)))))
(keymap-global-set "C-c s" #'bd/send-to-scratch)
+(add-hook 'emacs-startup-hook
+ (lambda ()
+ (with-current-buffer "*scratch*"
+ (setq-local scratch-buffer t))))
(use-package denote
:hook
@@ -31,7 +39,6 @@ then pastes the active region."
:config
(require 'denote-journal-extras)
-;;;; skribe
(defvar bd/denote-skribe-front-matter
"(post
:title \"%s\"