commit 6bc888611d4c6c19aaf6f46e0f18a608fc5f8778
parent 0dcb43a186d6a3cd5fe11b829954be4bad2e587a
Author: andsy10 <andsy1016@gmail.com>
Date: Fri, 28 Aug 2026 02:20:40 +0800
Cleanup up Emacs configuration
Diffstat:
10 files changed, 57 insertions(+), 61 deletions(-)
diff --git a/lisp/init-base.el b/lisp/init-base.el
@@ -129,7 +129,6 @@
(name . "^\\*\\[D\\] FILE backlinks for")))
("Scripts" (or
(mode . shell-script-mode)
- (mode . shell-mode)
(mode . sh-mode)
(mode . bat-mode)))
("Config" (or
@@ -163,6 +162,7 @@
(name . "\\*sly-compilation\\*")
(name . "^\\*img-cache\\*")))
("Shell" (or
+ (mode . shell-mode)
(mode . eshell-mode)
(mode . ghostel-mode)
(mode . vterm-mode)))
@@ -201,7 +201,7 @@
(mode . help-mode)
(mode . helpful-mode)
(mode . man-mode)
- (mode . info-mode)))
+ (mode . Info-mode))) ;`Info' must be capitalized
("Grep" (or
(mode . grep-mode)
(mode . rg-mode)
@@ -228,12 +228,14 @@
(mode . syncthing-mode))))))
(add-hook 'ibuffer-hook
- (lambda () (ibuffer-switch-to-saved-filter-groups "Main")
+ (lambda ()
+ (ibuffer-switch-to-saved-filter-groups "Main")
(unless (eq ibuffer-sorting-mode 'alphabetic)
(ibuffer-do-sort-by-alphabetic))))
(setq ibuffer-show-empty-filter-groups nil
- ibuffer-use-other-window t))
+ ibuffer-use-other-window t
+ ibuffer-human-readable-size t))
(use-package simple
:straight nil
@@ -283,11 +285,10 @@
(defun my-speedbar ()
"Run `speedbar-get-focus' if current buffer is not speedbar, otherwise run `speedbar'"
(interactive)
- (if (not (boundp 'speedbar-buffer))
+ (if (or (not (boundp 'speedbar-buffer))
+ (eq (current-buffer) speedbar-buffer))
(speedbar)
- (if (eq (current-buffer) speedbar-buffer)
- (speedbar)
- (speedbar-get-focus))))
+ (speedbar-get-focus)))
:config
(defun my-speedbar-line-expanded-p ()
diff --git a/lisp/init-completion.el b/lisp/init-completion.el
@@ -121,6 +121,8 @@ value of the selected COLOR."
:init
(setq prefix-help-command 'embark-prefix-help-command)
:config
+
+ ;; from centaur emacs
(defun my-embark-preview ()
"Previews candidate in vertico buffer, unless it's a consult command."
(interactive)
diff --git a/lisp/init-edit.el b/lisp/init-edit.el
@@ -76,7 +76,9 @@
:commands
(er/mark-symbol er/mark-word)
:config
- (setq expand-region-smart-cursor t))
+ (setq expand-region-smart-cursor t)
+ (setq expand-region-reset-fast-key "r")
+ (setq expand-region-contract-fast-key "c"))
;; Chinese support for avy
(use-package ace-pinyin
diff --git a/lisp/init-gptel.el b/lisp/init-gptel.el
@@ -115,10 +115,7 @@ explanations, no quotes, no punctuation, no file extension."
(use-package gptel-agent
:after gptel
- :demand t
- :config
- (add-to-list 'gptel-agent-dirs "~/.emacs.d/lisp/" t)
- (gptel-agent-update))
+ :demand t)
(use-package gptel-magit
:straight
@@ -148,7 +145,7 @@ explanations, no quotes, no punctuation, no file extension."
;; pi
(use-package pi-coding-agent
- :config
+ :init
(defun my-pi-coding-agent ()
"Run `pi-coding-agent' in project root."
(interactive)
diff --git a/lisp/init-kbd-func.el b/lisp/init-kbd-func.el
@@ -1,4 +1,4 @@
-;;; init-kbd-func.el --- functions for keybindings -*- lexical-binding: t -*-
+;;; init-kbd-func.el --- functions -*- lexical-binding: t -*-
;;; Commentary:
@@ -45,19 +45,17 @@ With a prefix ARG create a new *scratch* buffer."
(interactive)
(message (format-time-string "%Y-%m-%d %H:%M UTC" nil t)))
-(defun my-display-init-time ()
- (interactive)
- (message "Emacs loaded in %s." (emacs-init-time)))
-
(defun my-straight-packages-count ()
"Count how many straight.el package are currently installed."
(interactive)
- (message (format "%s packages installed" (hash-table-count straight--profile-cache))))
+ (if (called-interactively-p 'interactive)
+ (message (format "%s packages installed" (hash-table-count straight--profile-cache)))
+ (hash-table-count straight--profile-cache)))
-(defun my-insert-straight-packages-as-org-list ()
- "Insert straight.el packages as org-mode list."
+(defun my-insert-straight-packages ()
+ "Insert straight.el packages."
(interactive)
- (dolist (item (hash-table-keys straight--profile-cache))
+ (dolist (item (sort (hash-table-keys straight--profile-cache)))
(insert (format "- %s\n" item))))
(defun org-cycle-parent-subtree()
@@ -84,14 +82,12 @@ With a prefix ARG create a new *scratch* buffer."
(consult-grep my-blog-directory))
(defun my-org-table-align-all ()
- "Ajust all table in current buffer."
+ "Adjust all table in current buffer."
(interactive)
- (save-excursion
- (goto-char (point-min))
- (org-table-map-tables 'org-table-align t)))
+ (org-table-map-tables 'org-table-align t))
(defun org-align-description-list ()
- "Ajust all `::' in active region. "
+ "Adjust all `::' in active region. "
(interactive)
(align-regexp (region-beginning) (region-end) "\\(\\s-*\\)::" 1 1 nil))
diff --git a/lisp/init-kbd.el b/lisp/init-kbd.el
@@ -428,9 +428,5 @@
"M-S-SPC" #'xdg-launcher-run-app))
(t nil))
-;; expand region
-(setq expand-region-reset-fast-key "r")
-(setq expand-region-contract-fast-key "c")
-
(provide 'init-kbd)
;;; init-kbd.el ends here
diff --git a/lisp/init-org.el b/lisp/init-org.el
@@ -54,9 +54,12 @@
(0 (prog1 () (add-text-properties (match-beginning 1) (match-end 1) '(invisible t)))))))
(font-lock-add-keywords 'org-mode org-hide-space-keywords 'append)
- (add-to-list 'org-src-lang-modes '("yaml" . yaml-ts))
- (add-to-list 'org-src-lang-modes '("json" . json-ts))
- (add-to-list 'org-src-lang-modes '("toml" . toml-ts))
+ (mapc
+ (lambda (kv)
+ (setf (alist-get (car kv) org-src-lang-modes nil nil #'equal) (cdr kv)))
+ '(("yaml" . yaml-ts)
+ ("json" . json-ts)
+ ("toml" . toml-ts)))
;; show inline images
(setq org-startup-with-inline-images 'inlineimages)
@@ -68,7 +71,7 @@
(setq org-log-done t
org-log-into-drawer t)
- ;; dont set bookmark
+ ;; don't set bookmark
(setq org-bookmark-names-plist nil)
;; todo keywords
@@ -99,12 +102,13 @@
(after-init . denote-rename-buffer-mode)
(dired-mode . denote-dired-mode)
:init
- (defun my-denote-find-file ()
+ (defun my-denote-find-file (&optional arg)
"Find file use denote-file-prompt."
- (interactive)
- (let* ((denote-excluded-files-regexp "=journal\\|=archive")
- (file (denote-file-prompt)))
- (find-file file)))
+ (interactive "P")
+ (if arg
+ (find-file (denote-file-prompt))
+ (let ((denote-excluded-files-regexp "=journal\\|=archive"))
+ (find-file (denote-file-prompt)))))
(defun my-denote-open-metanote ()
"Open denote metanote in org directory"
@@ -263,7 +267,7 @@
(:name "priority = C" :priority "C")
(:name "other priority" :priority< "C")
(:name "someday" :todo "SOMEDAY")
- (:name "I dont know yet" :todo "IDKY")
+ (:name "I don't know yet" :todo "IDKY")
(:name "game" :todo "GAME"))))))))))
;; capture
@@ -302,7 +306,7 @@
cursor-type 'hbar
olivetti-body-width 100)
(blink-cursor-mode -1)
- (cnfonts-increase-fontsize 3)
+ (cnfonts-increase-fontsize 5)
(hl-line-mode 'toggle)
(read-only-mode 1)
(jinx-mode -1)
@@ -314,7 +318,7 @@
(when (and (eq major-mode 'org-mode) (memq 'org-tree-slide-mode local-minor-modes))
(org-mode-restart)
(blink-cursor-mode 1)
- (cnfonts-decrease-fontsize 3)
+ (cnfonts-decrease-fontsize 5)
(hl-line-mode 1)
(read-only-mode -1)
(jinx-mode 1)
diff --git a/lisp/init-package.el b/lisp/init-package.el
@@ -13,9 +13,6 @@
:hook
(after-init . global-anzu-mode))
-;; writable grep
-(use-package wgrep)
-
;; ripgrep
(use-package rg)
@@ -136,7 +133,8 @@ Like normal Emacs `C-k'. Kill to end of line and put content in kill-ring."
(dolist (buf buffers)
(persp-set-buffer buf))))
- (setq persp-switch-to-buffer-behavior 'switch)
+ (setq persp-switch-to-buffer-behavior 'switch
+ persp-sort 'oldest)
(with-eval-after-load 'consult
(consult-customize consult-source-buffer :hidden t :default nil)
(add-to-list 'consult-buffer-sources persp-consult-source))
diff --git a/lisp/init-prog.el b/lisp/init-prog.el
@@ -1,6 +1,7 @@
;;; init-prog.el --- programming -*- lexical-binding: t -*-
;;; Commentary:
+;; I don't realy do any programming.
;;; Code:
diff --git a/lisp/init-terminal.el b/lisp/init-terminal.el
@@ -48,7 +48,7 @@
(add-to-list 'exec-path (expand-file-name "~/.guix-home/profile/bin/"))
(setenv "PATH" (concat (expand-file-name "~/.guix-home/profile/bin/") ":" (getenv "PATH")))))
-(delete-selection-mode)
+(delete-selection-mode 1)
(setq initial-scratch-message
"")
@@ -115,20 +115,23 @@
(after-init . global-auto-revert-mode))
(use-package icomplete
- :init
- (fido-mode)
+ :hook
+ (after-init . fido-mode)
:config
(keymap-unset minibuffer-local-completion-map "TAB")
(keymap-set minibuffer-local-completion-map "TAB" 'icomplete-force-complete))
;; display file size in mode line
-(size-indication-mode t)
+(size-indication-mode 1)
;; display column number in mode line
-(column-number-mode t)
+(column-number-mode 1)
;; highlight current line
-(global-hl-line-mode t)
+(global-hl-line-mode 1)
+
+;; mouse support
+(xterm-mouse-mode 1)
;; theme
(if (>= (display-color-cells) 16777216)
@@ -141,7 +144,7 @@
(defvar my-cyan "#01928d")
(defvar my-blue "#2570cd")
(defvar my-green "#3a9c36")
- (defvar magenta "#d33682")
+ (defvar my-magenta "#d33682")
(defvar my-yellow "#a87c04")
(defvar my-orange "#c24713")
(defvar my-red "#ce2825")
@@ -162,7 +165,7 @@
`(font-lock-type-face ((t (:foreground ,my-yellow))))
`(font-lock-function-name-face ((t (:foreground ,my-blue))))
`(hl-line ((t (:background ,my-base02 :extend t))))
- `(show-paren-match ((t (:foreground ,magenta :weight bold))))
+ `(show-paren-match ((t (:foreground ,my-magenta :weight bold))))
`(show-paren-mismatch ((t (:foreground ,my-base03 :background ,my-red))))
`(icomplete-first-match ((t (:foreground ,my-yellow :weight bold))))
`(completions-common-part ((t (:foreground ,my-blue))))
@@ -174,7 +177,7 @@
`(dired-header ((t (:foreground ,my-green))))
`(dired-directory ((t (:foreground ,my-blue))))
`(dired-ignored ((t (:foreground ,my-base01))))
- `(isearch ((t (:background ,magenta :foreground ,my-base03))))
+ `(isearch ((t (:background ,my-magenta :foreground ,my-base03))))
`(lazy-highlight ((t (:background ,my-yellow :foreground ,my-base03))))
`(isearch-fail ((t (:foreground ,my-red))))
`(org-block ((t (:inherit default))))
@@ -200,10 +203,6 @@
(interactive)
(find-file "~/.emacs.d/init.el"))
-(defun my-display-init-time ()
- (interactive)
- (message "Emacs loaded in %s." (emacs-init-time)))
-
(defun my-scratch-buffer (&optional arg)
"Switch to the *scratch* buffer.
With a prefix ARG create a new *scratch* buffer."