From 994773ddb9b1b284ae1fab7ac2c4001a70201ce7 Mon Sep 17 00:00:00 2001 From: User Date: Sun, 12 Apr 2026 04:22:34 +0800 Subject: [PATCH] Config: start configure general and hydra --- lisp/init-kbd.el | 77 ++++++++++++++++++++++++++++++++++++++---------- lisp/init-org.el | 6 ++-- 2 files changed, 64 insertions(+), 19 deletions(-) diff --git a/lisp/init-kbd.el b/lisp/init-kbd.el index f15ed46..9190d9d 100644 --- a/lisp/init-kbd.el +++ b/lisp/init-kbd.el @@ -4,6 +4,67 @@ ;;; Code: +(use-package hydra + :defines (consult-imenu-config posframe-border-width) + :functions childframe-completion-workable-p + :hook ((emacs-lisp-mode . hydra-add-imenu) + ((after-init after-load-theme server-after-make-frame) . hydra-set-posframe)) + :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)))))) + + (defun hydra-set-posframe () + "Set display type and appearance of hydra." + ;; Display type + (if (childframe-completion-workable-p) + (setq hydra-hint-display-type 'posframe) + (setq hydra-hint-display-type 'lv)) + ;; Appearance + (setq hydra-posframe-show-params + `(:left-fringe 8 + :right-fringe 8 + :internal-border-width ,posframe-border-width + :internal-border-color ,(face-background 'posframe-border nil t) + :background-color ,(face-background 'tooltip nil t) + :foreground-color ,(face-foreground 'tooltip nil t) + :lines-truncate t + :poshandler posframe-poshandler-frame-center-near-bottom)))) + +;; multiple-cursors +(defhydra hydra-multiple-cursors () + " + ^Mark^ ^Unmark^ ^Other^ +------------------------------------------------------------------ +_p_ : prev line _P_ : previous _c_ : edit lines +_n_ : next line _N_ : next _._ : pop +_f_ : next symbol _q_ : quit +_b_ : prev symbol +_s_ : in region +_a_ : all dwim +" + ("p" mc/mark-previous-like-this) + ("n" mc/mark-next-like-this) + ("b" mc/mark-previous-like-this-symbol) + ("f" mc/mark-next-like-this-symbol) + ("P" mc/unmark-previous-like-this) + ("N" mc/unmark-next-like-this) + ("a" mc/mark-all-dwim) + ("s" mc/mark-all-in-region) + ("c" mc/edit-lines) + ("." mc/mark-pop) + ("q" nil)) + +(global-set-key (kbd "C-c c") 'hydra-multiple-cursors/body) + +(use-package general) + ;; 修改mac键位 (when *is-mac* (setq mac-command-modifier 'meta) @@ -17,10 +78,6 @@ (global-set-key (kbd "") 'open-init-file) -;; 快速打开函数与变量的定义 -(global-set-key (kbd "C-h C-f") 'find-function) -(global-set-key (kbd "C-h C-v") 'find-variable) - ;; 根据平台使用不同的重启方式 (if *is-windows* (progn @@ -33,18 +90,6 @@ (global-set-key (kbd "C-c r") 'restart-emacs)) (global-set-key (kbd "C-c r") 'restart-emacs)) -;; multiple cursors -(global-set-key (kbd "C-c c c") 'mc/edit-lines) -(global-set-key (kbd "C-c c s") 'mc/mark-all-in-region) -(global-set-key (kbd "C-<") 'mc/mark-previous-like-this) -(global-set-key (kbd "C-c c p") 'mc/unmark-previous-like-this) -(global-set-key (kbd "C->") 'mc/mark-next-like-this) -(global-set-key (kbd "C-c c n") 'mc/unmark-next-like-this) -(global-set-key (kbd "") 'mc/mark-pop) -(global-set-key (kbd "C-{") 'mc/mark-previous-like-this-symbol) -(global-set-key (kbd "C-}") 'mc/mark-next-like-this-symbol) -(global-set-key (kbd "C-c c a") 'mc/mark-all-dwim) - ;; expand region (global-set-key (kbd "C-c e") 'er/expand-region) (setq expand-region-reset-fast-key "r") diff --git a/lisp/init-org.el b/lisp/init-org.el index 321536d..2812cd4 100644 --- a/lisp/init-org.el +++ b/lisp/init-org.el @@ -38,7 +38,7 @@ org-journal-time-format "%m-%d \n<%Y-%m-%d %a %H:%M:%S>\n" org-journal-hide-entries-p t org-journal-date-format (lambda (time) - (format "* %s %s\n[%s]\n" + (format "* %s %s\n\n[%s]\n" (format-time-string "%Y-%m-%d" time) (format-time-string "%a" time) (format-time-string "%Y-%m-%d %a" time))) @@ -259,12 +259,12 @@ my-org-capture-temp-title))))) "#+title: %(symbol-value 'my-org-capture-temp-title) #+date: %U -#+category: %^{Category|none|project|book|article|note|insight} +#+category: %^{Category|none|project|book|article|note|insight|fun} * %(symbol-value 'my-org-capture-temp-title) %^g -%U :PROPERTIES: :END: +%U %?