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 (defvar-local my/-trusted-content-segment-cache nil
"Cache variable used in my/-trusted-content-segment. "Cache variable used in my/-trusted-content-segment.
This is a single element list with that element being the file's trusted status.") 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 () (defun my/temp-trust-buffer ()
"Set the current buffers local value of `trusted-content' to \\=:all." "Set the current buffers local value of `trusted-content' to \\=:all."
(interactive) (interactive)
@@ -107,7 +109,8 @@ This is a single element list with that element being the file's trusted status.
(revert-buffer-quick)))) (revert-buffer-quick))))
(put 'trusted-content 'permanent-local t) (put 'trusted-content 'permanent-local t)
(defun my/-trusted-content-segment () (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)) (not buffer-read-only))
(cond (cond
((and (local-variable-p 'trusted-content) ((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 ;; Increase responsiveness
(setq gc-cons-threshold 80000000 (setq gc-cons-threshold 80000000
inhibit-compacting-font-caches t 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) (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 ;; Terminal mouse support
(xterm-mouse-mode 1) (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 ;; Enable all disabled stuff
(setq disabled-command-function nil) (setq disabled-command-function nil)
;; Make window balancing better
(setq window-combination-resize t)
;; Stop some annoying stuff ;; Stop some annoying stuff
(setq extended-command-suggest-shorter nil (setq extended-command-suggest-shorter nil
suggest-key-bindings nil) suggest-key-bindings nil)
@@ -295,7 +314,11 @@ Interactively, force the recompile if called with a prefix."
(treesit-install-language-grammar (car lang)) (treesit-install-language-grammar (car lang))
(setq did-build t))) (setq did-build t)))
(unless did-build (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 (use-package auth-source
:ensure nil :ensure nil
@@ -995,6 +1018,16 @@ visual states."
:config :config
(avy-setup-default)) (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' ;; better `replace-regexp'
(use-package visual-regexp (use-package visual-regexp
:bind (("C-c q" . vr/replace) :bind (("C-c q" . vr/replace)
@@ -1004,6 +1037,24 @@ visual states."
(cl-pushnew "Replace" val :test 'equal) (cl-pushnew "Replace" val :test 'equal)
(setopt minibuffer-regexp-prompts val))) (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 ;; ace-window
(use-package ace-window (use-package ace-window
:diminish ace-window-mode :diminish ace-window-mode
@@ -1015,6 +1066,18 @@ visual states."
;; savehist ;; savehist
(use-package savehist (use-package savehist
:config :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)) (savehist-mode 1))
;; vertico ;; vertico