Compare commits

...

15 Commits

Author SHA1 Message Date
Case Duckworth 19cb761465 Require +chicken 2022-04-12 13:19:56 -05:00
Case Duckworth c6ccd9151d Configure modus-themes 2022-04-12 13:19:49 -05:00
Case Duckworth b391b15541 Add packages 2022-04-12 13:19:16 -05:00
Case Duckworth e0e49f18fd Add a keybind for timer-list-cancel 2022-04-12 13:18:55 -05:00
Case Duckworth 298ebabb88 Configure tab-bar 2022-04-12 13:18:48 -05:00
Case Duckworth 7d720a4793 Configure org-mode 2022-04-12 13:18:41 -05:00
Case Duckworth e64c1a2854 Change commenting form 2022-04-12 13:18:28 -05:00
Case Duckworth 869f2192bd Stop being compatible with Emacs < 28 2022-04-12 13:18:08 -05:00
Case Duckworth c0a0df1e3c Add comment 2022-04-12 13:17:54 -05:00
Case Duckworth 6068ebf457 Require '_work
Might still need some ... work
2022-04-12 13:17:42 -05:00
Case Duckworth a6db4c2295 Change auto-fill rules 2022-04-12 13:17:30 -05:00
Case Duckworth 6f1f0de1c1 Add dlet to compat.el 2022-04-12 13:16:49 -05:00
Case Duckworth 9ed685f740 Add +dired-goto-file
This function fixes dumbness in vertico-directory when jumping directories in
dired.
2022-04-12 13:16:15 -05:00
Case Duckworth 9b23b33921 Add +crux-kill-and-join-forward
This one is visual-line-mode aware
2022-04-12 13:15:36 -05:00
Case Duckworth c0fa442767 Start the server if not already 2022-04-12 13:15:08 -05:00
5 changed files with 168 additions and 85 deletions

210
init.el
View File

@ -40,18 +40,18 @@
"C-x C-o" #'+open-paragraph
"C-w" #'+kill-word-backward-or-region
"C-x C-m" #'execute-extended-command ; original: coding systems
;; "C-x C-1" #'delete-other-windows
;; "C-x 2" #'+split-window-below-then
;; "C-x C-2" #'+split-window-below-then
;; "C-x 3" #'+split-window-right-then
;; "C-x C-3" #'+split-window-right-then
;; Alright, Yegge... NOPE! C-x t is tab prefix ... (maybe F6 or something?)
;; "C-x t" #'beginning-of-buffer
;; "C-x e" #'end-of-buffer
)
;; Font-lock keywords
(add-hook 'prog-mode-hook #'font-lock-todo-insinuate)
;; C-h deletes backward - see https://idiomdrottning.org/bad-emacs-defaults
(global-set-key (kbd "C-h") 'delete-backward-char)
(keyboard-translate ?\C-h ?\C-?)
;; Hooks
(add-hook 'prog-mode-hook #'turn-on-auto-fill)
(add-hook 'prog-mode-hook #'font-lock-todo-insinuate)
(add-hook 'text-mode-hook #'turn-on-auto-fill)
(add-hook 'special-mode-hook #'turn-off-auto-fill)
;; Advice
;; https://old.reddit.com/r/emacs/comments/rlli0u/whats_your_favorite_defadvice/hph14un/
(define-advice keyboard-escape-quit (:around (fn &rest r))
@ -124,6 +124,10 @@
(setup +key
(+ensure-after-init #'+key-global-mode))
;;(setup _work
;; (+with-ensure-after-init
;; (require '_work)))
(setup abbrev
(:option abbrev-file-name (sync/ "abbrev.el")
save-abbrevs 'silent)
@ -168,6 +172,7 @@
browse-url-firefox-new-window-is-tab t)
(defvar +invidious-host
;; TODO: Add variables for other transformations and what-not.
;; ... or enable trying multiple servers
"invidious.snopyta.org"
"Host for invidious instance.")
;; Set up external browsing URLs.
@ -184,41 +189,42 @@
(add-to-list '+browse-url-secondary-browser-regexps
(replace-regexp-in-string "\\." "\\\\." domain)))
;; Set up URL handlers.
(require 'chd)
(+browse-url-set-handlers
(list
(cons (rx ; images
"." (or "jpeg" "jpg" "png" "bmp") eos)
(lambda (&rest args)
(apply
(cond ((executable-find "mpv") #'+browse-image-with-mpv)
(t #'eww-browse-url))
args)))
(cons (rx (or ;; videos
"youtube.com" "youtu.be" "invidious" "yewtu.be"
(seq "." (or "mp4" "gif" "mov" "MOV" "webm") eos)
;; music
"soundcloud.com" "bandcamp.com"
(seq "." (or "ogg" "mp3" "opus" "m4a") eos)))
(lambda (&rest args)
(apply (if (executable-find "mpv")
#'+browse-url-with-mpv
browse-url-secondary-browser-function)
args)))
(cons chd/url-regexps #'browse-url-chrome)
(cons (+browse-url-secondary-browser-regexps-combine) ; non-text websites
(lambda (&rest args)
(apply browse-url-secondary-browser-function args)))
(cons "xkcd\\.com"
(lambda (&rest args)
(apply (if (fboundp #'xkcd-get)
(progn (require '+xkcd)
#'+xkcd-get-from-url)
+browse-url-browser-function)
args)))
(cons "." ; everything else
(lambda (&rest args)
(apply +browse-url-browser-function args)))))
(:option browse-url-handlers
(list
(cons (rx ; images
"." (or "jpeg" "jpg" "png" "bmp") eos)
(lambda (&rest args)
(apply
(cond ((executable-find "mpv") #'+browse-image-with-mpv)
(t #'eww-browse-url))
args)))
(cons (rx (or ;; videos
"youtube.com" "youtu.be" "invidious" "yewtu.be"
(seq "." (or "mp4" "gif" "mov" "MOV" "webm") eos)
;; music
"soundcloud.com" "bandcamp.com"
(seq "." (or "ogg" "mp3" "opus" "m4a") eos)))
(lambda (&rest args)
(apply (if (executable-find "mpv")
#'+browse-url-with-mpv
browse-url-secondary-browser-function)
args)))
(cons (+browse-url-secondary-browser-regexps-combine) ; non-text websites
(lambda (&rest args)
(apply browse-url-secondary-browser-function args)))
(cons "xkcd\\.com"
(lambda (&rest args)
(apply (if (fboundp #'xkcd-get)
(progn (require '+xkcd)
#'+xkcd-get-from-url)
+browse-url-browser-function)
args)))
(cons "." ; everything else
(lambda (&rest args)
(apply +browse-url-browser-function args)))))
(with-eval-after-load 'chd
(add-to-list 'browse-url-handlers
(cons chd/url-regexps #'browse-url-chrome)))
;; Transform URLs before passing to `browse-url'
(:option +browse-url-transformations `((,(rx (or "youtube.com"
"youtu.be"))
@ -246,7 +252,7 @@
compilation-scroll-output t))
(setup dired
(:also-load dired-x)
(:also-load dired-x +dired)
(:also-straight dired+)
(:option dired-recursive-copies 'always
dired-recursive-deletes 'always
@ -266,7 +272,8 @@
shell touch)
dired-dwim-target t)
(:local-set truncate-lines t)
(:bind "<backspace>" #'dired-up-directory)
(:bind "<backspace>" #'dired-up-directory
"j" #'+dired-goto-file)
(:hook #'dired-hide-details-mode
#'hl-line-mode
#'lin-mode)
@ -290,18 +297,18 @@
"\\" #'+ecomplete-remove-email)))
(add-hook 'message-sent-hook #'message-put-addresses-in-ecomplete))
;; (setup ehelp
;; ;; Trying this instead of `helpful'
;; (:global [help] 'ehelp-command
;; [f1] 'ehelp-command)
;; (with-eval-after-load 'vertico-multiform
;; (dolist (cmd '(electric-describe-key
;; electric-describe-mode
;; electric-describe-syntax
;; electric-describe-bindings
;; electric-describe-function
;; electric-describe-variable))
;; (setf (alist-get cmd vertico-multiform-commands) nil))))
(setup ehelp (:quit)
;; Trying this instead of `helpful'
(:global [help] 'ehelp-command
[f1] 'ehelp-command)
(with-eval-after-load 'vertico-multiform
(dolist (cmd '(electric-describe-key
electric-describe-mode
electric-describe-syntax
electric-describe-bindings
electric-describe-function
electric-describe-variable))
(setf (alist-get cmd vertico-multiform-commands) nil))))
(setup eldoc
(:hook-into elisp-mode
@ -537,8 +544,7 @@
(setq load-path (cl-remove-if (lambda (path)
(string-match-p "lisp/org\\'" path))
load-path))
(:also-load +org
_work)
(:also-load +org)
(:option org-adapt-indentation nil
org-archive-mark-done t
org-catch-invisible-edits 'show-and-error
@ -561,8 +567,11 @@
org-image-actual-width (list (* (window-font-width)
(- fill-column 8)))
org-imenu-depth 3
org-indent-indentation-per-level 0
org-indent-mode-turns-on-hiding-stars nil
org-list-demote-modify-bullet '(("-" . "+")
("+" . "-"))
("+" . "*")
("*" . "-"))
org-log-done 'time
org-log-into-drawer t
org-num-skip-commented t
@ -604,7 +613,9 @@
"~" #'+org-insert-backtick)
(:global [f8] #'org-clock-in
[f9] #'org-clock-out)
(:hook #'variable-pitch-mode)
(:hook #'variable-pitch-mode
#'turn-off-auto-fill
#'org-indent-mode)
(:local-hook user-save-hook #'+org-before-save@prettify-buffer)
(advice-add #'org-delete-backward-char :override #'+org-delete-backward-char)
;; (define-advice org-open-at-point (:around (fn &rest r) open-external)
@ -626,10 +637,18 @@
;; NOTE: these `progn' and `default's are necessary; otherwise Emacs
;; complains about "Invalid face reference: t" in org-mode buffers, because
;; `compose-region' returns t.
("^ *\\([-]\\) "
(0 (progn (compose-region (match-beginning 1) (match-end 1) "") 'default)))
("^ *\\([+]\\) "
(0 (progn (compose-region (match-beginning 1) (match-end 1) "»") 'default)))))
("^[ \t]*\\([-]\\) "
(0 (progn (compose-region (match-beginning 1) (match-end 1) "") 'fixed-pitch)))
("^[ \t]*\\([+]\\) "
(0 (progn (compose-region (match-beginning 1) (match-end 1) "¬") 'fixed-pitch)))
("^[ \t]+\\([*]\\) "
(0 (progn (compose-region (match-beginning 1) (match-end 1) "") 'fixed-pitch)))
;; Fancy numbered lists (well, monospaced)
("^[ \t]*\\(\\(?:[0-9]+\\|[A-Za-z]\\)[.)]\\) " 0 'fixed-pitch t)))
;; Make nobreak-space fixed-pitch as well, for better alignment (is this the
;; best way to do this? probably not!)
(:face org-indent ((t (:inherit (fixed-pitch))))
nobreak-space ((t (:inherit (fixed-pitch)))))
(with-eval-after-load 'form-feed
;; Horizontal lines
(font-lock-add-keywords
@ -743,8 +762,7 @@
(setup prog
(:local-set comment-auto-fill-only-comments t)
(:hook #'prettify-symbols-mode
#'turn-on-auto-fill))
(:hook #'prettify-symbols-mode))
(setup scratch
(:require +scratch)
@ -768,11 +786,11 @@
tab-bar-tab-name-ellipsis truncate-string-ellipsis
tab-bar-show t
tab-bar-close-button-show t
tab-bar-new-button-show nil
tab-bar-new-button-show t
+tab-bar-menu-bar-icon " ; "
tab-bar-close-button (propertize "(x)"
tab-bar-close-button (propertize " × "
'display t
'close-tab t)
'close-tab nil)
tab-bar-new-button (propertize "+ " 'display t))
;; I need to set these here so that they take effect /before/ `display-time-mode'
(:option display-time-format "%H:%M"
@ -794,10 +812,8 @@
(tab-bar-mode +1)
(display-time-mode +1))
(setup text
(:hook #'turn-on-auto-fill))
(setup timer-list
(:bind "d" #'timer-list-cancel)
(:hook #'hl-line-mode
#'lin-mode))
@ -1288,7 +1304,7 @@ They are completed by \"M-x TAB\" only in Tramp debug buffers."
(:global "C-o" #'crux-smart-open-line
"C-x 4 t" #'crux-transpose-windows
"M-w" #'+crux-kill-ring-save
"C-k" #'crux-kill-and-join-forward
"C-k" #'+crux-kill-and-join-forward
"C-c d" #'+crux-insert-date-or-time)
(crux-with-region-or-buffer indent-region)
@ -1310,6 +1326,8 @@ See also `crux-reopen-as-root-mode'."
(crux-find-alternate-file-as-root buffer-file-name))))
(crux-reopen-as-root-mode +1))
(setup (:straight csv-mode))
(setup (:straight dictionary)
(:option dictionary-use-single-buffer t)
(autoload 'dictionary-search "dictionary"
@ -1501,6 +1519,11 @@ See also `crux-reopen-as-root-mode'."
:repo "duckwork/filldent.el"))
(:+key "M-q" #'filldent-dwim))
(setup (:straight (flymake-collection
:host github
:repo "mohkale/flymake-collection"))
(+ensure-after-init #'flymake-collection-hook-setup))
(setup (:straight (flyspell-correct
:fork (:host github :repo "duckwork/flyspell-correct"
:branch "metadata-category")))
@ -1543,7 +1566,7 @@ See also `crux-reopen-as-root-mode'."
geiser-chicken
macrostep-geiser
scheme-complete)
(:also-load +chicken)
(:require +chicken)
(setf (alist-get "\\.scm\\'" auto-mode-alist nil nil #'string=)
'scheme-mode))
@ -1777,7 +1800,7 @@ See also `crux-reopen-as-root-mode'."
(require 'modus-themes (.etc "straight/build/modus-themes/modus-themes"))
(:also-load dawn)
(:option modus-themes-mixed-fonts t
modus-themes-bold-constructs nil
modus-themes-bold-constructs t
modus-themes-italic-constructs t
modus-themes-headings '((t . (background regular rainbow))))
(dotimes (facen-1 8)
@ -1796,21 +1819,33 @@ See also `crux-reopen-as-root-mode'."
"Set up mdous-themes to be mostly monochrome."
(modus-themes-with-colors
(custom-set-faces
`(font-lock-builtin-face ((,class :inherit modus-themes-bold :foreground unspecified)))
`(font-lock-builtin-face ((,class :inherit modus-themes-bold
:foreground unspecified)))
`(font-lock-comment-delimiter-face ((,class :inherit font-lock-comment-face)))
`(font-lock-comment-face ((,class :inherit modus-themes-slant :foreground ,fg-docstring)))
`(font-lock-constant-face ((,class :foreground unspecified)))
`(font-lock-doc-face ((,class :inherit modus-themes-slant :foreground ,fg-docstring)))
`(font-lock-comment-face ((,class :inherit modus-themes-slant
:foreground ,fg-docstring)))
`(font-lock-constant-face ((,class :inherit underline
:foreground unspecified)))
`(font-lock-doc-face ((,class :inherit modus-themes-slant
:foreground ,fg-docstring)))
`(font-lock-function-name-face ((,class :foreground unspecified)))
`(font-lock-keyword-face ((,class :inherit modus-themes-bold :foreground unspecified)))
`(font-lock-negation-char-face ((,class :inherit modus-themes-bold :foreground unspecified)))
`(font-lock-keyword-face ((,class :inherit modus-themes-bold
:foreground unspecified)))
`(font-lock-negation-char-face ((,class :inherit modus-themes-bold
:foreground unspecified)))
`(font-lock-preprocessor-face ((,class :foreground unspecified)))
`(font-lock-regexp-grouping-backslash ((,class :foreground ,fg-escape-char-backslash)))
`(font-lock-regexp-grouping-construct ((,class :foreground ,fg-escape-char-construct)))
`(font-lock-string-face ((,class :inherit modus-themes-slant :foreground unspecified)))
`(font-lock-type-face ((,class :inherit modus-themes-bold :foreground unspecified)))
`(font-lock-string-face ((,class :inherit modus-themes-slant
:foreground unspecified)))
`(font-lock-type-face ((,class :inherit modus-themes-bold
:foreground unspecified)))
`(font-lock-variable-name-face ((,class :foreground unspecified)))
`(font-lock-warning-face ((,class :inherit modus-themes-bold :foreground ,red-nuanced-fg)))))))
`(font-lock-warning-face ((,class :inherit modus-themes-bold
:foreground ,red-nuanced-fg)))
`(font-lock-todo-face ((,class :inherit font-lock-comment-face
:foreground ,fg-header
:background ,yellow-intense-bg)))))))
(dawn-schedule #'modus-themes-load-operandi
#'modus-themes-load-vivendi))
@ -1960,6 +1995,9 @@ See also `crux-reopen-as-root-mode'."
(define-key +link-hint-map "M-\"" #'+link-hint-pocket-add)
(define-key +link-hint-map "\"" #'+link-hint-pocket-add))))
(setup (:straight rainbow-mode)
(:hook-into prog-mode))
(setup (:straight (shell-command+
:host nil
:repo "https://git.sr.ht/~pkal/shell-command-plus"))
@ -2191,6 +2229,10 @@ See also `crux-reopen-as-root-mode'."
(setup (:straight vlf)
(:require vlf-setup))
(setup (:straight (vundo
:host github
:repo "casouri/vundo")))
;; (setup (:straight-when vterm
;; (and module-file-suffix
;; (executable-find "cmake")))

View File

@ -12,7 +12,10 @@
(save-buffer)
(condition-case e
(url-retrieve-synchronously "http://localhost:8080/reload")
(file-error (message "Couldn't ping awful's server. Is it running?"))
(file-error (progn
(message "Couldn't ping awful's server. Starting...")
(start-process "awful" (generate-new-buffer "*awful*")
"awful" "--development-mode" (buffer-file-name))))
(t (message "Some awful error occurred!"))))
(provide '+chicken)

View File

@ -44,5 +44,15 @@ prompt for the time format."
(format-time-string +crux-alternate-date-format time))
(t (format-time-string (read-string "Time Format: ") time))))))
(defun +crux-kill-and-join-forward (&optional arg)
"If at end of line, join with following; else (visual)-kill line.
In `visual-line-mode', runs command `kill-visual-line'; in other
modes, runs command `kill-line'. Passes ARG to command when
provided. Deletes whitespace at join."
(interactive "P")
(if (and (eolp) (not (bolp)))
(delete-indentation 1)
(funcall (if visual-line-mode #'kill-visual-line #'kill-line) arg)))
(provide '+crux)
;;; +crux.el ends here

View File

@ -2,7 +2,18 @@
;;; Code:
(require 'vertico)
(defun +dired-goto-file (file)
"ADVICE for `dired-goto-file' to make RET call `vertico-exit'."
(interactive ; stolen from `dired-goto-file'
(prog1
(list (dlet ((vertico-map (copy-keymap vertico-map)))
(define-key vertico-map (kbd "RET") #'vertico-exit)
(expand-file-name (read-file-name "Goto file: "
(dired-current-directory)))))
(push-mark)))
(dired-goto-file file))
(provide '+dired)
;;; +dired.el ends here

View File

@ -13,5 +13,22 @@
(dolist (file (directory-files (locate-user-emacs-file "lisp/compat") :full "\\.el\\'"))
(load file :noerror))
;; Other stuff...
(unless (fboundp 'dlet)
(defmacro dlet (binders &rest body)
"Like `let' but using dynamic scoping."
(declare (indent 1) (debug let))
;; (defvar FOO) only affects the current scope, but in order for
;; this not to affect code after the main `let' we need to create a new scope,
;; which is what the surrounding `let' is for.
;; FIXME: (let () ...) currently doesn't actually create a new scope,
;; which is why we use (let (_) ...).
`(let (_)
,@(mapcar (lambda (binder)
`(defvar ,(if (consp binder) (car binder) binder)))
binders)
(let ,binders ,@body))))
(provide 'compat)
;;; compat.el ends here