Add some small tweaks

This commit is contained in:
2026-04-12 01:16:28 -07:00
parent 177ea4784f
commit 3b73d0d4ba

69
init.el
View File

@@ -93,6 +93,8 @@
(defvar-local my/-trusted-content-segment-cache nil
"Cache variable used in my/-trusted-content-segment.
This is a single element list with that element being the file's trusted status.")
(defvar-local my/inhibit-trusted-content-segment nil
"When non-nil, don't display the trusted content segment.")
(defun my/temp-trust-buffer ()
"Set the current buffers local value of `trusted-content' to \\=:all."
(interactive)
@@ -107,7 +109,8 @@ This is a single element list with that element being the file's trusted status.
(revert-buffer-quick))))
(put 'trusted-content 'permanent-local t)
(defun my/-trusted-content-segment ()
(when (and (derived-mode-p 'prog-mode)
(when (and (not my/inhibit-trusted-content-segment)
(derived-mode-p 'prog-mode)
(not buffer-read-only))
(cond
((and (local-variable-p 'trusted-content)
@@ -144,9 +147,22 @@ This is a single element list with that element being the file's trusted status.
;; Increase responsiveness
(setq gc-cons-threshold 80000000
inhibit-compacting-font-caches t
read-process-output-max (* 1024 1024)) ;; 1mb
read-process-output-max (* 4 1024 1024)) ;; 4mb
(global-so-long-mode 1)
;; Disable bidi text scanning (supposedly increases performance)
(setq-default bidi-display-reordering t
bidi-paragraph-direction 'left-to-right)
(setq bidi-inhibit-bpa t)
;; Make emacs wait until typing is done to fontify (also increases
;; performance)
(setq redisplay-skip-fontification-on-input t)
;; Some kill ring settings
(setq save-interprogram-paste-before-kill t
kill-do-not-save-duplicates t)
;; Terminal mouse support
(xterm-mouse-mode 1)
@@ -157,6 +173,9 @@ This is a single element list with that element being the file's trusted status.
;; Enable all disabled stuff
(setq disabled-command-function nil)
;; Make window balancing better
(setq window-combination-resize t)
;; Stop some annoying stuff
(setq extended-command-suggest-shorter nil
suggest-key-bindings nil)
@@ -295,7 +314,11 @@ Interactively, force the recompile if called with a prefix."
(treesit-install-language-grammar (car lang))
(setq did-build t)))
(unless did-build
(message "All defined parsers installed!")))))
(message "All defined parsers installed!"))))
;; Auto-magically make script files executable
(add-hook 'after-save-hook
#'executable-make-buffer-file-executable-if-script-p))
(use-package auth-source
:ensure nil
@@ -995,6 +1018,16 @@ visual states."
:config
(avy-setup-default))
;; re-builder
(use-package re-builder
:hook (reb-lisp-mode . my/-setup-reb-lisp-mode)
:init
(defun my/-setup-reb-lisp-mode ()
(adjust-parens-mode -1)
(setq-local my/inhibit-trusted-content-segment t))
:custom
(reb-re-syntax . 'string))
;; better `replace-regexp'
(use-package visual-regexp
:bind (("C-c q" . vr/replace)
@@ -1004,6 +1037,24 @@ visual states."
(cl-pushnew "Replace" val :test 'equal)
(setopt minibuffer-regexp-prompts val)))
;; save-place
(use-package saveplace
:init
(save-place-mode 1)
:config
;; From Doom, apparently
(defun my/-recenter-save-place-after-find-file ()
(when buffer-file-name
(ignore-errors
(recenter))))
(add-hook 'save-place-after-find-file-hook
#'my/-recenter-save-place-after-find-file))
;; winner (restore window configs)
(use-package winner
:init
(winner-mode 1))
;; ace-window
(use-package ace-window
:diminish ace-window-mode
@@ -1015,6 +1066,18 @@ visual states."
;; savehist
(use-package savehist
:config
;; Inspired by doom emacs
;; Source:
;; https://emacsredux.com/blog/2026/04/07/stealing-from-the-best-emacs-configs/
(dolist (var '(kill-ring regexp-search-ring search-ring))
(add-to-list 'savehist-additional-variables var))
(defun my/-savehist-clean-kill-ring ()
"Clean text properties and non-text data from the kill ring."
(setq kill-ring (mapcan (lambda (elt)
(when (stringp elt)
(list (substring-no-properties elt))))
kill-ring)))
(add-hook 'savehist-save-hook #'my/-savehist-clean-kill-ring)
(savehist-mode 1))
;; vertico