This commit is contained in:
Zelong Kuang
2026-02-22 23:29:18 +11:00
parent 32501941a1
commit c32094700d
6 changed files with 52 additions and 46 deletions

View File

@@ -71,7 +71,6 @@
(setq ring-bell-function 'ignore) (setq ring-bell-function 'ignore)
(setq undo-limit 80000000 (setq undo-limit 80000000
auto-save-default t
password-cache-expiry nil) password-cache-expiry nil)
(setq-default delete-by-moving-to-trash t (setq-default delete-by-moving-to-trash t
@@ -129,7 +128,7 @@
(lambda (button) (lambda (button)
(helpful-variable (button-get button 'apropos-symbol)))))))) (helpful-variable (button-get button 'apropos-symbol))))))))
(setq auto-save-file-name-transforms ;; (setq auto-save-file-name-transforms
`((".*" ,(concat user-emacs-directory "auto-save/") t))) ;; `((".*" ,(concat user-emacs-directory "auto-save/") t)))
(provide 'init-better-default) (provide 'init-better-default)

View File

@@ -1,39 +1,37 @@
;; -*- lexical-binding: t -*- ;; -*- lexical-binding: t -*-
;; (use-package smartparens ;; (use-package smartparens
;; :demand t ;; :hook (elpaca-after-init . smartparens-global-mode)
;; :hook (prog-mode text-mode markdown-mode) ;; ;; :hook (elpaca-after-init . smartparens-global-strict-mode)
;; :init (sp-use-paredit-bindings)
;; :config ;; :config
;; (require 'smartparens-config)) ;; ;; Autopair quotes more conservatively; if I'm next to a word/before another
;; ;; quote, I don't want to open a new pair or it would unbalance them.
;; (let ((unless-list '(sp-point-before-word-p
;; sp-point-after-word-p
;; sp-point-before-same-p)))
;; (sp-pair "'" nil :unless unless-list)
;; (sp-pair "\"" nil :unless unless-list))
;; (dolist (brace '("(" "{" "["))
;; (sp-pair brace nil
;; :post-handlers '(("||\n[i]" "RET") ("| " "SPC"))
;; ;; Don't autopair opening braces if before a word character or
;; ;; other opening brace. The rationale: it interferes with manual
;; ;; balancing of braces, and is odd form to have s-exps with no
;; ;; whitespace in between, e.g. ()()(). Insert whitespace if
;; ;; genuinely want to start a new form in the middle of a word.
;; :unless '(sp-point-before-word-p sp-point-before-same-p)))
;; (sp-local-pair sp-lisp-modes "(" ")" :unless '(:rem sp-point-before-same-p))
;; ;; Don't do square-bracket space-expansion where it doesn't make sense to
;; (sp-local-pair '(emacs-lisp-mode org-mode markdown-mode markdown-ts-mode gfm-mode)
;; "[" nil :post-handlers '(:rem ("| " "SPC")))
;; )
(use-package smartparens (use-package electric-pair
:hook (elpaca-after-init . smartparens-global-mode) :ensure nil
;; :hook (elpaca-after-init . smartparens-global-strict-mode) :hook elpaca-after-init)
:init (sp-use-paredit-bindings)
:config
;; Autopair quotes more conservatively; if I'm next to a word/before another
;; quote, I don't want to open a new pair or it would unbalance them.
(let ((unless-list '(sp-point-before-word-p
sp-point-after-word-p
sp-point-before-same-p)))
(sp-pair "'" nil :unless unless-list)
(sp-pair "\"" nil :unless unless-list))
(dolist (brace '("(" "{" "["))
(sp-pair brace nil
:post-handlers '(("||\n[i]" "RET") ("| " "SPC"))
;; Don't autopair opening braces if before a word character or
;; other opening brace. The rationale: it interferes with manual
;; balancing of braces, and is odd form to have s-exps with no
;; whitespace in between, e.g. ()()(). Insert whitespace if
;; genuinely want to start a new form in the middle of a word.
:unless '(sp-point-before-word-p sp-point-before-same-p)))
(sp-local-pair sp-lisp-modes "(" ")" :unless '(:rem sp-point-before-same-p))
;; Don't do square-bracket space-expansion where it doesn't make sense to
(sp-local-pair '(emacs-lisp-mode org-mode markdown-mode markdown-ts-mode gfm-mode)
"[" nil :post-handlers '(:rem ("| " "SPC")))
)
;; Hungry deletion ;; Hungry deletion
(use-package hungry-delete (use-package hungry-delete
@@ -58,6 +56,7 @@
:test 'equal)) :test 'equal))
(setq yas-triggers-in-field t) (setq yas-triggers-in-field t)
(setq yas-key-syntaxes '("w" "w_" "w_." "^ " yas-try-key-from-whitespace))
;; Function that tries to autoexpand YaSnippets ;; Function that tries to autoexpand YaSnippets
;; The double quoting is NOT a typo! ;; The double quoting is NOT a typo!

View File

@@ -183,6 +183,10 @@ the element after the #+HEADER: tag."
("BUG" error bold) ("BUG" error bold)
("XXX" font-lock-constant-face bold)))) ("XXX" font-lock-constant-face bold))))
(add-hook 'org-mode-hook
(lambda ()
(yas-activate-extra-mode 'LaTeX-mode)))
(use-package org-latex-preview (use-package org-latex-preview
:ensure nil :ensure nil
:hook (org-mode . org-latex-preview-mode) :hook (org-mode . org-latex-preview-mode)
@@ -283,17 +287,7 @@ the element after the #+HEADER: tag."
("C-M-y" . org-download-clipboard)) ("C-M-y" . org-download-clipboard))
:config :config
(setq-default org-download-heading-lvl 1) (setq-default org-download-heading-lvl 1)
(defconst org-download-root-directory "./attachments/") (defconst org-download-image-dir "./attachments/")
(defun set-org-download-directory ()
(create-directory-if-not-exists org-download-root-directory)
(make-local-variable 'org-download--dir)
(setq org-download-image-dir (concat org-download-root-directory (buffer-name)))
(setq org-download-heading-lvl nil)
(setq org-attach-directory org-download-image-dir)
(message "set-org-download-directory")
)
(add-hook 'org-mode-hook #'set-org-download-directory)
(setq-default org-download-method 'directory)) (setq-default org-download-method 'directory))
(use-package valign (use-package valign

View File

@@ -37,7 +37,7 @@
;; sessions ;; sessions
(tabspaces-session t) (tabspaces-session t)
;; (tabspaces-session-auto-restore t) ;; (tabspaces-session-auto-restore t)
(tabspaces-keymap-prefix "C-c TAB") (tabspaces-keymap-prefix "C-c o")
(tab-bar-new-tab-choice "default") (tab-bar-new-tab-choice "default")
(with-eval-after-load 'consult (with-eval-after-load 'consult

7
snippets/latex-mode/^{} Normal file
View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: ^{}
# key: kj
# condition: (and (texmathp) 'auto)
# group: math
# --
^{$0}

7
snippets/latex-mode/_{} Normal file
View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: _{}
# key: jo
# condition: (and (texmathp) 'auto)
# group: math
# --
_{$0}