From f4193046847197cdfb38b6de890257b7ec14f56d Mon Sep 17 00:00:00 2001 From: andsy10 Date: Sat, 9 May 2026 01:00:46 +0800 Subject: [PATCH] Config: install denote and some extra packages, add plocate support on linux, optimize keybindings --- lisp/init-dired.el | 5 ++++- lisp/init-exwm.el | 17 ++++++++++++++++- lisp/init-kbd-func.el | 7 +++++++ lisp/init-kbd.el | 29 +++++++++++------------------ lisp/init-org.el | 23 +++++++++++++++++++++++ lisp/init-package.el | 34 ++++++++++++++++++++-------------- lisp/init-startup.el | 3 +++ lisp/my-base16-dark-theme.el | 2 ++ lisp/my-base16-light-theme.el | 2 ++ 9 files changed, 88 insertions(+), 34 deletions(-) diff --git a/lisp/init-dired.el b/lisp/init-dired.el index 52e173c..696904c 100644 --- a/lisp/init-dired.el +++ b/lisp/init-dired.el @@ -8,6 +8,9 @@ ;; dirvish (use-package dirvish + :hook + (dired-mode-hook . denote-dired-mode) + :init (dirvish-override-dired-mode) @@ -53,7 +56,7 @@ ("s" "~/.config/guix/" "System config") ("p" "~/Pictures/" "Pictures") ("d" "~/downloads/" "Downloads") - ("v" "~/Video/" "Videos") + ("v" "~/视频/" "Videos") ("n" "~/org/my-org-note/" "Notes") ("g" "~/gptel/" "gptel sessions"))) (t nil)))) diff --git a/lisp/init-exwm.el b/lisp/init-exwm.el index cb0fc2a..fa546a9 100644 --- a/lisp/init-exwm.el +++ b/lisp/init-exwm.el @@ -14,7 +14,7 @@ (let ((display-buffer-alist '((".*" . (display-buffer-no-window . nil))))) (async-shell-command command)))) - + (defun restart-fcitx5 () "Kill and restart fcitx5, to fix random issues in exwm." (interactive) @@ -24,6 +24,21 @@ (eshell-command "fcitx5 -d")) (eshell-command "fcitx5 -d"))) + (defun reboot () + "Execute loginctl reboot command." + (interactive) + (eshell-command "loginctl reboot")) + + (defun poweroff () + "Execute loginctl poweroff command" + (interactive) + (eshell-command "loginctl poweroff")) + + (defun suspend () + "Execute loginctl suspend command" + (interactive) + (eshell-command "loginctl suspend")) + (defun my--exwm-switch-to-workspace (delta) (let ((target (mod (+ exwm-workspace-current-index delta) diff --git a/lisp/init-kbd-func.el b/lisp/init-kbd-func.el index bb6dc49..9e1128b 100644 --- a/lisp/init-kbd-func.el +++ b/lisp/init-kbd-func.el @@ -66,6 +66,13 @@ Disable jinx-mode if it's enable and global-jinx-mode is disable , otherwise tog nil 0 nil (file-name-directory (expand-file-name file))))) +(defun consult-fd-global () + "Search for all files use fd" + (interactive) + (let ((consult-fd-args "fd -H -I -i -c never --full-path") + (default-directory "~/")) + (consult-fd))) + (defun my-open-current-directory () "Open current directory in default file explorer." (interactive) diff --git a/lisp/init-kbd.el b/lisp/init-kbd.el index 851ba78..66b3113 100644 --- a/lisp/init-kbd.el +++ b/lisp/init-kbd.el @@ -128,6 +128,11 @@ "M-]" nil "C-q" 'vterm-send-next-key) +;; eat +(general-def (eat-semi-char-mode-map eat-line-mode-map eat-char-mode-map eat-eshell-semi-char-mode-map eat-eshell-char-mode-map) + "M-[" nil + "M-]" nil) + ;; embark (general-def embark-file-map "d" 'consult-directory-externally @@ -145,8 +150,8 @@ (general-def org-mode-map "C-" 'org-cycle-parent-subtree "C-c i" 'consult-outline - "C-c o l" 'org-toggle-link-display - "C-c C-k" 'kmacro-call-macro + "C-c t l" 'org-toggle-link-display + "C-c C-k" 'kmacro-call-macroe "M-{" 'org-previous-visible-heading "M-}" 'org-next-visible-heading) @@ -174,8 +179,10 @@ "a" 'org-agenda "l" 'org-store-link "k" 'comment-line - "v" 'vterm - "C-k" 'kmacro-call-macro) + ;; "v" 'vterm + "E" 'eshell + "C-k" 'kmacro-call-macro + "C-t" 'trashed) ;; global map (general-def @@ -249,20 +256,6 @@ "j o" 'org-journal-open-entry-for-editing "" 'org-journal-open-entry-for-editing) -;; hydra -(use-package hydra - :defines (consult-imenu-config) - :init - (with-eval-after-load 'consult-imenu - (setq consult-imenu-config - '((emacs-lisp-mode :toplevel "Functions" - :types ((?f "Functions" font-lock-function-name-face) - (?h "Hydras" font-lock-constant-face) - (?m "Macros" font-lock-function-name-face) - (?p "Packages" font-lock-constant-face) - (?t "Types" font-lock-type-face) - (?v "Variables" font-lock-variable-name-face))))))) - ;; multiple-cursors (defhydra hydra-multiple-cursors () " diff --git a/lisp/init-org.el b/lisp/init-org.el index de5282b..d02c474 100644 --- a/lisp/init-org.el +++ b/lisp/init-org.el @@ -74,6 +74,29 @@ 'org-babel-load-languages org-babel-load-languages)) +;; denote +(use-package denote + :config + (setq denote-directory "~/org/my-org-note/") + (setq denote-prompts '(title signature keywords)) + (setq denote-title-history nil) + (setq denote-known-keywords + '("emacs" "org" "elisp" "scheme" "programming" "philosophy" "film" "linux" "computerstuff" "game" "masterpiece"))) + +;; denote-org +(use-package denote-org) + +;; denote-explore +(use-package denote-explore) + +;; consult-notes +(use-package consult-notes + :init + (consult-notes-denote-mode) + :config + (setq consult-notes-file-dir-sources '(("Org Notes" ?n "~/org/my-org-note/" :hidden t) + ("Org Journal" ?j "~/org/my-org-daily/" :hidden t)))) + ;; org-download (use-package org-download :config diff --git a/lisp/init-package.el b/lisp/init-package.el index c6d844e..b8bb6be 100644 --- a/lisp/init-package.el +++ b/lisp/init-package.el @@ -57,13 +57,6 @@ (use-package consult :config - (defun consult-fd-global () - "Search for all files use fd" - (interactive) - (let ((consult-fd-args "fd -H -I -i -c never --full-path") - (default-directory "~/")) - (consult-fd))) - ;; everything (when *is-windows* (setq consult-locate-args (encode-coding-string "es.exe -i -p -r" 'gbk)) @@ -74,12 +67,11 @@ ;; mdfind (when *is-mac* - (setopt consult-locate-args "mdfind -name"))) + (setq consult-locate-args "mdfind -name")) -(use-package consult-notes - :config - (setq consult-notes-file-dir-sources '(("Org Notes" ?n "~/org/my-org-note/") - ("Org Journal" ?j "~/org/my-org-daily/" :hidden t)))) + ;; plocate + (when *is-linux* + (setq consult-locate-args "plocate --basename --ignore-case"))) ;; embark (use-package embark @@ -234,8 +226,8 @@ targets." (use-package consult-flycheck) ;; vterm -(unless *is-windows* - (use-package vterm)) +;; (unless *is-windows* +;; (use-package vterm)) ;; eat (use-package eat @@ -257,6 +249,20 @@ targets." ;; general (use-package general) +;; hydra +(use-package hydra + :defines (consult-imenu-config) + :init + (with-eval-after-load 'consult-imenu + (setq consult-imenu-config + '((emacs-lisp-mode :toplevel "Functions" + :types ((?f "Functions" font-lock-function-name-face) + (?h "Hydras" font-lock-constant-face) + (?m "Macros" font-lock-function-name-face) + (?p "Packages" font-lock-constant-face) + (?t "Types" font-lock-type-face) + (?v "Variables" font-lock-variable-name-face))))))) + ;; perspective (use-package perspective :bind diff --git a/lisp/init-startup.el b/lisp/init-startup.el index 3c31e13..21e6c41 100644 --- a/lisp/init-startup.el +++ b/lisp/init-startup.el @@ -94,6 +94,9 @@ (setq use-short-answers t) (fset 'yes-or-no-p 'y-or-n-p)) +;; 移动到垃圾桶 +(setq delete-by-moving-to-trash t) + (provide 'init-startup) ;;; init-startup.el ends here diff --git a/lisp/my-base16-dark-theme.el b/lisp/my-base16-dark-theme.el index 65dbf90..bfb8142 100644 --- a/lisp/my-base16-dark-theme.el +++ b/lisp/my-base16-dark-theme.el @@ -41,6 +41,8 @@ `(dashboard-heading ((,class (:foreground ,green :weight bold)))) `(dirvish-file-time ((,class (:foreground ,base01)))) `(dired-header ((,class (:foreground ,green)))) + `(consult-file ((,class (:foreground ,green)))) + `(denote-faces-keywords ((,class (:foreground ,cyan)))) `(mode-line ((,class (:foreground ,base0 :background ,base02)))) `(mode-line-inactive ((,class (:foreground ,base01 :background ,base03)))) `(display-time-date-and-time ((,class (:foreground ,base1 :bold t)))) diff --git a/lisp/my-base16-light-theme.el b/lisp/my-base16-light-theme.el index 0b3f0e9..61efa7f 100644 --- a/lisp/my-base16-light-theme.el +++ b/lisp/my-base16-light-theme.el @@ -41,6 +41,8 @@ `(dashboard-heading ((,class (:foreground ,green :weight bold)))) `(dirvish-file-time ((,class (:foreground ,base01)))) `(dired-header ((,class (:foreground ,green)))) + `(consult-file ((,class (:foreground ,green)))) + `(denote-faces-keywords ((,class (:foreground ,cyan)))) `(mode-line ((,class (:foreground ,base0 :background ,base02)))) `(mode-line-inactive ((,class (:foreground ,base01 :background ,base03)))) `(display-time-date-and-time ((,class (:foreground ,base1 :bold t))))