This commit is contained in:
Jeffrey Serio 2023-08-28 00:35:48 -05:00
parent 90e85dbcd1
commit f555801946
2 changed files with 145 additions and 22 deletions

159
config.el
View File

@ -3,6 +3,10 @@
;;;; Misc settings ;;;; Misc settings
;; start Emacs as a server process
(server-start)
;; user info
(setq user-full-name "Jeffrey Serio" (setq user-full-name "Jeffrey Serio"
user-mail-address "hyperreal@fedoraproject.org") user-mail-address "hyperreal@fedoraproject.org")
@ -17,7 +21,7 @@
(when (string= (system-name) "moonshadow") (when (string= (system-name) "moonshadow")
(setq fontsize 18) (setq fontsize 18)
(setq default-frame-alist (setq default-frame-alist
'((height . 53) '((height . 54)
(width . 154) (width . 154)
(left . 1720) (left . 1720)
(top . 0) (top . 0)
@ -41,6 +45,34 @@
(setq doom-theme 'catppuccin) (setq doom-theme 'catppuccin)
(setq catppuccin-flavor 'mocha) (setq catppuccin-flavor 'mocha)
;; Backups
(setq backup-directory-alist '(("." . "~/sync/emacs/backups")))
(with-eval-after-load 'tramp
(add-to-list 'tramp-backup-directory-alist
(cons tramp-file-name-regexp nil)))
(setq delete-old-versions -1)
(setq version-control t)
(setq vc-make-backup-files t)
(setq auto-save-file-name-transforms '((".*" "~/sync/emacs/auto-save-list/" t)))
;; History
(setq savehist-file "~/sync/emacs/savehist")
(savehist-mode 1)
(setq history-length t)
(setq history-delete-duplicates t)
(setq savehist-save-minibuffer-history 1)
(setq savehist-additional-variables
'(kill-ring
search-ring
regexp-search-ring))
;; Display time in the modeline
(display-time-mode 1)
;; Sentences end with a single space because it's right and proper
(setq sentence-end-double-space nil)
;; This determines the style of line numbers in effect. If set to `nil', line ;; This determines the style of line numbers in effect. If set to `nil', line
;; numbers are disabled. For relative line numbers, set this to `relative'. ;; numbers are disabled. For relative line numbers, set this to `relative'.
(setq display-line-numbers-type 'relative) (setq display-line-numbers-type 'relative)
@ -51,6 +83,21 @@
;; Keybinding to kill-whole-line ;; Keybinding to kill-whole-line
(global-set-key (kbd "M-9") 'kill-whole-line) (global-set-key (kbd "M-9") 'kill-whole-line)
;; trim newline from string output
(defun string-trim-final-newline (string)
"Trim the last newline character from string.
Used with `shell-command-to-string'.
Source: https://emacs.stackexchange.com/a/21906"
(let ((len (length string)))
(cond
((and (> len 0) (eql (aref string (- len 1)) ?\n))
(substring string 0 (- len 1)))
(t string))))
;; wrapper around `shell-command-to-string' to remove newline
(defun shell-command-output-string (command)
(string-trim-final-newline (shell-command-to-string command)))
;; Copy all or text selection ;; Copy all or text selection
(defun xah-copy-all-or-region () (defun xah-copy-all-or-region ()
"Put the whole buffer content to `kill-ring', or text selection if there's one. "Put the whole buffer content to `kill-ring', or text selection if there's one.
@ -118,6 +165,41 @@ If point was already at that position, move point to beginning of line."
'(emacs-lisp-mode '(emacs-lisp-mode
python-mode)) python-mode))
;; UTF-8
(prefer-coding-system 'utf-8)
(when (display-graphic-p)
(setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING)))
;;;; artbollocks-mode
;;;; https://github.com/sachac/artbollocks-mode
(setq artbollocks-weasel-words-regex
(concat "\\b" (regexp-opt
'("one of the"
"should"
"just"
"etc"
"sort of"
"kind of"
"a lot"
"probably"
"maybe"
"perhaps"
"I think"
"really"
"pretty"
"utilize"
"leverage") t) "\\b"))
;;;; undo-tree-mode - visualize undos and branches
(global-undo-tree-mode)
(setq undo-tree-visualizer-timestamps t)
(setq undo-tree-visualizer-diff t)
(setq undo-tree-history-directory-alist '(("." . "~/sync/emacs/backups/undo-tree")))
;;;; evil-nerd-commenter ;;;; evil-nerd-commenter
@ -130,6 +212,7 @@ If point was already at that position, move point to beginning of line."
;;;; org-mode ;;;; org-mode
(add-hook 'org-mode-hook (lambda () (org-superstar-mode 1))) (add-hook 'org-mode-hook (lambda () (org-superstar-mode 1)))
(require 'org-protocol)
(setq org-modules '(org-agenda (setq org-modules '(org-agenda
org-annotate-file org-annotate-file
@ -140,7 +223,7 @@ If point was already at that position, move point to beginning of line."
'(org-load-modules-maybe t)) '(org-load-modules-maybe t))
(setq org-directory "~/sync/org/") (setq org-directory "~/sync/org/")
(setq org-default-notes-file "~/sync/org/notes.org") (setq org-default-notes-file "~/sync/org/inbox.org")
;; support selecting lines by using shift ;; support selecting lines by using shift
(setq org-support-shift-select t) (setq org-support-shift-select t)
@ -181,7 +264,6 @@ If point was already at that position, move point to beginning of line."
"~/sync/org/computing.org" "~/sync/org/computing.org"
"~/sync/org/general.org" "~/sync/org/general.org"
"~/sync/org/orders.org" "~/sync/org/orders.org"
"~/sync/org/notes.org"
"~/sync/org/reading.org" "~/sync/org/reading.org"
"~/sync/org/grocery.org") "~/sync/org/grocery.org")
. (:maxlevel .5)))) . (:maxlevel .5))))
@ -218,9 +300,7 @@ If point was already at that position, move point to beginning of line."
(setq org-log-done 'time) (setq org-log-done 'time)
;; org-roam
;;;; org-roam
(setq org-roam-directory "~/sync/org-roam") (setq org-roam-directory "~/sync/org-roam")
(org-roam-db-autosync-mode) (org-roam-db-autosync-mode)
@ -235,7 +315,7 @@ If point was already at that position, move point to beginning of line."
("r" "reference" plain ("r" "reference" plain
"%?" "%?"
:if-new (file+head "reference/${title}.org" :if-new (file+head "reference/${title}.org"
"#+title: ${title}\n") "#+title: ${title}\n")
:immediate-finish t :immediate-finish t
:unnarrowed t) :unnarrowed t)
("s" "self" plain ("s" "self" plain
@ -253,10 +333,15 @@ If point was already at that position, move point to beginning of line."
:if-new (file "recipes/${title}.org") :if-new (file "recipes/${title}.org")
:unnarrowed t))) :unnarrowed t)))
;; org-capture templates ;; org-capture-templates
(setq org-capture-templates (setq org-capture-templates
'(("t" "Todo" entry (file "~/sync/org/inbox.org") '(("p" "Inbox" entry (file+headline "~/sync/org/inbox.org" "Inbox")
"* TODO %?" "* %^{Title}\nSource: %u, %c\n #+BEGIN_QUOTE\n%i\n#+END_QUOTE\n\n%?"
:empty-lines-before 1
:unnarrowed t
:immediate-finish t)
("L" "Link" entry (file+headline "~/sync/org/inbox.org" "Inbox")
"* %? [[%:link][%:description]] \nCaptured on: %U"
:empty-lines-before 1 :empty-lines-before 1
:unnarrowed t :unnarrowed t
:immediate-finish t) :immediate-finish t)
@ -281,12 +366,42 @@ If point was already at that position, move point to beginning of line."
;;;; python-mode ;;;; python-mode
;; Set bpython as Python shell interpreter ;; set bpython as python shell interpreter
(add-hook! python-mode-hook (add-hook! python-mode-hook
(setq python-shell-interpreter "bpython")) (setq python-shell-interpreter "bpython"))
;; Set black as Python formatter ;; enable elpy
(setq-hook! 'python-mode-hook +format-with 'black) (elpy-enable)
;; set tab width; use flake8 as python-flymake-command, python-check-command
(setq python-indent-offset 4)
(add-hook 'python-mode-hook
(lambda ()
(setq-local tab-width 4)
(setq-local python-flymake-command '("flake8" "--max-doc-length=72", "--ignore=E211,E999,F401,F821,W503"))
(setq-local python-check-command "flake8 --max-doc-length=72 --ignore=E211,E999,F401,F821,W503"))
70)
;; use Pyright LSP
(add-hook 'python-mode-hook
(lambda ()
(require 'lsp-pyright)
(lsp)))
;; autoformat on save with yapf
(add-hook 'elpy-mode-hook
(lambda ()
(add-hook 'before-save-hook
'elpy-yapf-fix-code nil t)))
;; colorize compilation buffer
;; from https://sachachua.com/dotemacs/index.html#orga33bac5
(require 'ansi-color)
(defun colorize-compilation-buffer ()
(when (eq major-mode 'compilation-mode)
(let ((inhibit-read-only t))
(ansi-color-apply-on-region compilation-filter-start (point-max)))))
(add-hook 'compilation-filter-hook 'colorize-compilation-buffer)
;;;; go-mode ;;;; go-mode
@ -304,6 +419,13 @@ If point was already at that position, move point to beginning of line."
(add-hook 'go-mode-hook #'lsp-deferred) (add-hook 'go-mode-hook #'lsp-deferred)
;;;; helpful
(global-set-key (kbd "C-h f") #'helpful-callable)
(global-set-key (kbd "C-h v") #'helpful-variable)
(global-set-key (kbd "C-h k") #'helpful-key)
(global-set-key (kbd "C-h x") #'helpful-command)
(global-set-key (kbd "C-c C-d") #'helpful-at-point)
;;;; dired ;;;; dired
(after! dired (after! dired
@ -392,11 +514,10 @@ Other buffer groups by `centaur-tabs-get-group-name' wit project name."
;;;; elfeed ;;;; elfeed
(elfeed-goodies/setup) (setq elfeed-protocol-enabled-protocols '(fever))
(setq elfeed-show-entry-switch 'pop-to-buffer-same-window)
(setq elfeed-protocol-enabled-protocols '(ttrss))
(elfeed-protocol-enable) (elfeed-protocol-enable)
(setq elfeed-protocol-ttrss-maxsize 200) (setq elfeed-protocol-fever-update-unread-only t)
(setq elfeed-feeds (list (setq elfeed-feeds (list
(list "ttrss+https://hyperreal@rss.envs.net" (list "fever+https://hyperreal@rss.hyperreal.coffee"
:password (shell-command-to-string "echo -n `pass show envs.net/ttrss`")))) :api-url "https://rss.hyperreal.coffee/api/fever.php"
:password (shell-command-output-string "pass show freshrss/hyperreal"))))

View File

@ -8,27 +8,29 @@
;; To install SOME-PACKAGE from MELPA, ELPA or emacsmirror: ;; To install SOME-PACKAGE from MELPA, ELPA or emacsmirror:
;(package! some-package) ;(package! some-package)
(package! artbollocks-mode :recipe
(:host nil :repo "https://github.com/sachac/artbollocks-mode"))
(package! autothemer) (package! autothemer)
(package! catppuccin-theme) (package! catppuccin-theme)
(package! elfeed) (package! elfeed)
(package! elfeed-goodies) (package! elfeed-goodies)
(package! elfeed-protocol) (package! elfeed-protocol)
(package! elfeed-tube)
(package! elfeed-tube-mpv)
(package! elpher) (package! elpher)
(package! elpy)
(package! evil-nerd-commenter) (package! evil-nerd-commenter)
(package! fzf) (package! fzf)
(package! gemini :recipe (package! gemini :recipe
(:host nil :repo "https://git.carcosa.net/jmcbray/gemini.el")) (:host nil :repo "https://git.carcosa.net/jmcbray/gemini.el"))
(package! go-complete) (package! go-complete)
(package! helpful)
(package! importmagic) (package! importmagic)
(package! just-mode) (package! just-mode)
(package! justl) (package! justl)
(package! license-templates) (package! license-templates)
(package! nov) (package! nov)
(package! org-chef)
(package! org-roam) (package! org-roam)
(package! org-superstar) (package! org-superstar)
(package! python-docstring) (package! python-docstring)
(package! shell-pop) (package! shell-pop)
(package! systemd) (package! systemd)
(package! undo-tree)