Once more, a whole bunch of mostly bug fixes

This commit is contained in:
Alexander Rosenberg 2024-10-16 21:32:23 -07:00
parent 48d546c561
commit 68aa9afd18
Signed by: Zander671
GPG Key ID: 5FD0394ADBD72730

153
init.el
View File

@ -366,7 +366,17 @@ directory. Otherwise, run `find-file' on that file."
(when status (kkp--terminal-teardown (kkp--selected-terminal)))
(funcall oldfun arg pred))
(when (and status (not (kkp--terminal-has-active-kkp-p)))
(kkp--terminal-setup)))))
;; this does async stuff that will make kitty send characters after
;; Emacs exists. We prevent that by not re-enabling if this frame (or
;; Emacs) is about to die
(let ((will-die-p))
(mapbacktrace
(lambda (_evald func _args _flags)
(when (or (eq func 'save-buffers-kill-emacs)
(eq func 'server-save-buffers-kill-terminal))
(setq will-die-p t))))
(unless will-die-p
(kkp-enable-in-terminal)))))))
(advice-add #'save-some-buffers :around
#'my/-kkp-fix-save-some-buffers))
@ -449,30 +459,28 @@ directory. Otherwise, run `find-file' on that file."
lisp-interaction-mode))
(evil-cleverparens-mode 1)
(electric-pair-local-mode 1)))
(defun my/inside-bound-p (beg end bounds)
"Return non-nil if BEG and END are inside BOUNDS.
BOUNDS should be either nil, in which case this will return nil, or a cons cell
of the form (bound-start . bound-end)"
(when bounds
(cl-destructuring-bind (bs . be) bounds
(and (>= beg bs) (<= beg be)
(>= end bs) (<= end be)))))
(defun my/-fix-evil-cp-delete (oldfun beg end type register yank-handler)
"Make `evil-cp-delete' fall back to `evil-delete' if we are inside a
string."
(if (my/inside-bound-p beg end (bounds-of-thing-at-point 'string))
(funcall 'evil-delete beg end type register yank-handler)
(funcall oldfun beg end type register yank-handler)))
(defun my/-fix-evil-cp-delete-char-or-splice
(oldfun beg end type register yank-handler)
"Make `evil-cp-delete' fall back to `evil-delete' if we are inside a
string."
(if (my/inside-bound-p beg end (bounds-of-thing-at-point 'string))
(funcall 'evil-delete-char beg end type register)
(funcall oldfun beg end type register yank-handler)))
(advice-add 'evil-cp-delete)
(advice-add 'evil-cp-delete-char-or-splice :around
'my/-fix-evil-cp-delete-char-or-splice))
(cl-defun my/range-inside-thing-p (thing beg end &optional no-edge)
"Return non-nil if BEG and END fall inside the bounds of THING.
With NO-EDGE, return nil if beg or end fall on the edge of the range."
(save-excursion
;; this fixes that fact that `thing-at-point-bounds-of-string-at-point'
;; errors if called at the end of the buffer
(condition-case _
(let ((sb (progn (goto-char beg) (bounds-of-thing-at-point thing)))
(eb (progn (goto-char end) (bounds-of-thing-at-point thing))))
(and sb eb (equal sb eb)
(or (not no-edge)
(and (/= beg (car sb))
(< beg (cdr sb))
(/= end (car sb))
(< end (cdr sb))))))
;; if the error happens, we aren't in as string
(wrong-type-argument nil))))
(defun my/-evil-cp-region-ok-p-no-string (oldfun beg end)
(or (my/range-inside-thing-p 'string beg end t)
(funcall oldfun beg end)))
(advice-add 'sp-region-ok-p :around 'my/-evil-cp-region-ok-p-no-string)
(advice-add 'evil-cp--balanced-block-p :around 'my/-evil-cp-region-ok-p-no-string))
;; make lisp editing nicer
(use-package aggressive-indent
@ -736,8 +744,8 @@ visual states."
;; Only run this if we are not in `TeX-mode'
(unless (bound-and-true-p TeX-mode-p)
(setq-local completion-at-point-functions
(nconc completion-at-point-functions '(cape-dict
cape-dabbrev))
(append completion-at-point-functions (list 'cape-dict
'cape-dabbrev))
corfu-auto nil))))
;; xref
@ -783,7 +791,8 @@ to `posframe-show' if the display is graphical."
(use-package flymake
:bind (:map flymake-mode-map
("C-c e" . my/flymake-show-diagnostic-at-point)
("C-c C-e" . consult-flymake))
("C-c C-e" . consult-flymake)
("C-x c e" . consult-flymake))
;; :hook (emacs-lisp-mode . flymake-mode)
:init
(defun my/flymake-show-diagnostic-at-point ()
@ -831,8 +840,10 @@ to `posframe-show' if the display is graphical."
:defer nil
:bind (:map flycheck-mode-map
("C-c C-e" . consult-flycheck)
("C-x c e" . consult-flycheck)
:map emacs-lisp-mode-map
("C-c C-e" . consult-flycheck)))
("C-c C-e" . consult-flycheck)
("C-x c e" . consult-flycheck)))
;; eldoc
(use-package eldoc
@ -1177,7 +1188,8 @@ otherwise, call `bibtex-find-text'."
(use-package auctex
:hook ((LaTeX-mode . turn-on-reftex)
(LaTeX-mode . LaTeX-math-mode)
(LaTeX-mode . my/-setup-LaTeX-mode))
(LaTeX-mode . my/-setup-LaTeX-mode)
(LaTeX-mode . flycheck-mode))
:bind (:map TeX-mode-map
("C-c ?" . latex-help))
:init
@ -1202,6 +1214,27 @@ otherwise, call `bibtex-find-text'."
(setq TeX-auto-save t
TeX-parse-self t
reftex-plug-into-AUCTeX t)
(evil-define-operator my/evil-LaTeX-fill (beg end)
"Like `evil-fill', but using auctex."
;; The code here came straight from `evil-fill'
:move-point nil
:type line
(save-excursion
(ignore-errors (LaTeX-fill-region beg end))))
(evil-define-operator my/evil-LaTeX-fill-and-move (beg end)
"Like `evil-fill-and-move', but using auctex."
;; The code here came straight from `evil-fill-and-move'
:move-point nil
:type line
(let ((marker (make-marker)))
(move-marker marker (1- end))
(ignore-errors
(LaTeX-fill-region beg end)
(goto-char marker)
(evil-first-non-blank))))
(evil-define-key 'normal TeX-mode-map
"gq" 'my/evil-LaTeX-fill-and-move
"gw" 'my/evil-LaTeX-fill)
(setq-default TeX-master nil)
(require 'tex)
(TeX-global-PDF-mode 1))
@ -1834,7 +1867,12 @@ The name is compared with the field name using TESTFN (defaults to `equal')."
(setq-local completion-cycle-threshold nil))
(advice-add 'mu4e--compose-setup-completion :after
'my/-mu4e-fix-cycle-threshold)
(setq message-kill-buffer-on-exit t
(defvar my/mu4e-interesting-mail-query
(concat "flag:unread AND NOT flag:trashed AND NOT "
"maildir:/protonmail/Trash AND NOT maildir:/protonmail/Spam")
"Flag for mail which will appear as \"unread\" and will be notified.")
(setq mail-user-agent 'mu4e-user-agent
message-kill-buffer-on-exit t
message-send-mail-function 'sendmail-send-it
mu4e-change-filenames-when-moving t
mu4e-context-policy 'pick-first
@ -1845,39 +1883,46 @@ The name is compared with the field name using TESTFN (defaults to `equal')."
mu4e-completing-read-function #'completing-read-default
mu4e-compose-context-policy 'ask-if-none
mu4e-contexts
`(,(make-mu4e-context
:name "Personal"
:enter-func (lambda () (mu4e-message "Entered personal context"))
:match-func (lambda (msg)
(when msg
(string-match-p "^/protonmail/"
(mu4e-message-field msg
:maildir))))
:vars `((user-mail-address . ,(my/get-private 'mu4e-email))
(user-full-name . ,(my/get-private 'mu4e-name))
(message-signature . nil)
(mu4e-refile-folder . "/protonmail/Archive")
(mu4e-sent-folder . "/protonmail/Sent")
(mu4e-drafts-folder . "/protonmail/Drafts")
(mu4e-trash-folder . "/protonmail/Trash")
(mu4e-bookmarks . ((:name "Inbox"
:query "maildir:/protonmail/Inbox"
:key ?i)
(:name "Unread"
:query "flag:unread AND NOT flag:trashed AND NOT maildir:/protonmail/Spam"
:key ?u))))))))
(list (make-mu4e-context
:name "Personal"
:match-func (lambda (msg)
(when msg
(string-match-p "^/protonmail/"
(mu4e-message-field msg
:maildir))))
:vars `((user-mail-address . ,(my/get-private 'mu4e-email))
(user-full-name . ,(my/get-private 'mu4e-name))
(message-signature . nil)
(mu4e-refile-folder . "/protonmail/Archive")
(mu4e-sent-folder . "/protonmail/Sent")
(mu4e-drafts-folder . "/protonmail/Drafts")
(mu4e-trash-folder . "/protonmail/Trash")
(mu4e-bookmarks
. ((:name "Inbox"
:query "maildir:/protonmail/Inbox"
:key ?i)
(:name "Unread"
:query ,my/mu4e-interesting-mail-query
:key ?u))))))))
(use-package mu4e-alert
:after mu4e
:hook (after-init . mu4e-alert-enable-notifications)
:init
(setq mu4e-alert-set-window-urgency nil
mu4e-alert-interesting-mail-query
"flag:unread AND NOT flag:trashed AND NOT maildir:/protonmail/Spam")
mu4e-alert-interesting-mail-query my/mu4e-interesting-mail-query)
:config
(mu4e-alert-set-default-style 'libnotify))
(mu4e t)
(mu4e-context-switch nil "Personal")
;; org-msg
(use-package org-msg
:init
(setq org-msg-default-alternatives '((new . (text html))
(reply-to-html . (text html))
(reply-to-text . (text)))
org-msg-convert-citation t))
;; elfeed
(use-package elfeed
:bind (("C-c d" . elfeed))