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