From 83c0f153f3d2012a84ff39af9f7fa667313fc267 Mon Sep 17 00:00:00 2001 From: User Date: Tue, 9 Jun 2026 04:20:24 +0800 Subject: [PATCH] feat: Add notes helpers, magit keybindings, and phscroll - Move `my-blog-publish`, `my-blog-preview`, and `my-note-push` from init-org.el to init-kbd-func.el for better organization - Add magit keybindings under C-x g prefix - Add phscroll package for better org table line wrapping - Remove visual-line-mode hook from gptel - Add Chinese word segmentation buffer to consult ignore list --- lisp/init-completion.el | 3 ++- lisp/init-gptel.el | 3 --- lisp/init-kbd-func.el | 42 +++++++++++++++++++++++++++++----- lisp/init-kbd.el | 10 +++++++++ lisp/init-org.el | 50 +++++++---------------------------------- 5 files changed, 57 insertions(+), 51 deletions(-) diff --git a/lisp/init-completion.el b/lisp/init-completion.el index 8a8b272..e5a9161 100644 --- a/lisp/init-completion.el +++ b/lisp/init-completion.el @@ -44,7 +44,8 @@ "^\\*Help" "Diff" "straight" - "\\*Messages\\*") + "\\*Messages\\*" + "\\*Chinese-word-segmentation\\*") :test 'equal))) ;; embark,快捷指令 diff --git a/lisp/init-gptel.el b/lisp/init-gptel.el index 1c75f27..f9c5f1a 100644 --- a/lisp/init-gptel.el +++ b/lisp/init-gptel.el @@ -5,9 +5,6 @@ ;;; Code: (use-package gptel - :hook - (gptel-mode-hook . visual-line-mode) - :config (setq gptel-log-level t) (setq gptel-default-mode 'org-mode) diff --git a/lisp/init-kbd-func.el b/lisp/init-kbd-func.el index c0bf41a..1e340fc 100644 --- a/lisp/init-kbd-func.el +++ b/lisp/init-kbd-func.el @@ -108,6 +108,43 @@ Disable jinx-mode if it's enable and global-jinx-mode is disable , otherwise tog (interactive) (align-regexp (region-beginning) (region-end) "\\(\\s-*\\)::" 1 1 nil)) +(defun my-blog-publish (&optional directory) + "Publish blog , git add/commit/push , generate commit message." + (interactive) + (let* ((blog-dir (or directory + (if *is-windows* + "h:/emacs/hugo/this-is-my-blog/" + "~/org/hugo/this-is-my-blog/"))) + (timestamp (format-time-string "%Y-%m-%d %H:%M:%S")) + (default-directory blog-dir)) + (save-buffer) + (message "Adding files...") + (eshell-command "git add .") + (message "Committing: %s" timestamp) + (eshell-command (format "git commit -m \"Update: %s\"" timestamp)) + (message "Pushing to remote...") + (let ((exit-code (eshell-command "git push"))) + (if (eq exit-code t) + (message "Push may have failed or nothing to push, check *Messages* buffer for details") + (message "Push successfully %s" timestamp))))) + +(defun my-blog-preview () + "Save and preview blog." + (interactive) + (save-buffer) + (let ((default-directory (if *is-windows* + "h:/emacs/hugo/this-is-my-blog/" + "~/org/hugo/this-is-my-blog/"))) + (start-process "hugo-server" "*hugo-server*" + "hugo" "server" "-D" "--bind" "0.0.0.0" "--port" "1313") + (sleep-for 2) + (browse-url "http://localhost:1313"))) + +(defun my-note-push () + "Git add/commit/push notes in `~/org/my-org-note/', generate commit message." + (interactive) + (my-blog-publish "~/org/my-org-note/")) + (defun my-dired-next-line() "Move to forward line in dired buffer" (interactive) @@ -188,11 +225,6 @@ Disable jinx-mode if it's enable and global-jinx-mode is disable , otherwise tog (interactive) (load-file (expand-file-name "~/.emacs.d/lisp/fix-theme-colors.el"))) -(defun my-note-push () - "Git add/commit/push notes in `~/org/my-org-note/', generate commit message." - (interactive) - (my-blog-publish "~/org/my-org-note/")) - (when *is-linux* (defun reboot () "Execute loginctl reboot command." diff --git a/lisp/init-kbd.el b/lisp/init-kbd.el index c0888f0..7e15525 100644 --- a/lisp/init-kbd.el +++ b/lisp/init-kbd.el @@ -77,6 +77,16 @@ "V" 'project-vc-dir "a" 'gptel-agent-project) +;; g for magit +(general-unbind "C-x g") +(general-def + :prefix "C-x g" + "s" 'magit-status + "c" 'magit-clone + "d" 'magit-diff + "b" 'magit-branch + "B" 'magit-blame) + ;; t for modes toggle (general-def :prefix "C-c t" diff --git a/lisp/init-org.el b/lisp/init-org.el index 557ad9e..7ffca67 100644 --- a/lisp/init-org.el +++ b/lisp/init-org.el @@ -49,6 +49,13 @@ (setq org-agenda-skip-function-global '(org-agenda-skip-entry-if 'todo '("COMMENT")))) +;; phscroll,优化表格换行 +(use-package phscroll + :hook + (org-mode . org-phscroll-activate) + :init + (setq org-startup-truncated nil)) + ;; org-babel scheme (use-package ob-scheme :demand t @@ -240,48 +247,7 @@ See `org-capture-templates' for more information." ;; and that it has a "Blog Ideas" heading. It can even be a ;; symlink pointing to the actual location of all-posts.org! (file+headline "~/org/hugo/this-is-my-blog/all-blog.org" "Blog Ideas") - (function org-hugo-new-subtree-post-capture-template))))) - - ;; 快速部署 - (defun my-blog-publish (&optional directory) - "Publish blog , git add/commit/push , generate commit message." - (interactive) - (let* ((blog-dir (or directory - (if *is-windows* - "h:/emacs/hugo/this-is-my-blog/" - "~/org/hugo/this-is-my-blog/"))) - (timestamp (format-time-string "%Y-%m-%d %H:%M:%S")) - (default-directory blog-dir)) - ;; save buffer - (save-buffer) - ;; git add - (message "Adding files...") - (eshell-command "git add .") - ;; git commit with timestamp - (message "Committing: %s" timestamp) - (eshell-command (format "git commit -m \"Update: %s\"" timestamp)) - ;; git push - (message "Pushing to remote...") - (let ((exit-code (eshell-command "git push"))) - (if (eq exit-code t) - (message "Push may have failed or nothing to push, check *Messages* buffer for details") - (message "Push successfully %s" timestamp))))) - - ;; 预览博客 - (defun my-blog-preview () - "Save and preview blog." - (interactive) - (save-buffer) - (let ((default-directory (if *is-windows* - "h:/emacs/hugo/this-is-my-blog/" - "~/org/hugo/this-is-my-blog/"))) - ;; 启动 Hugo server - (start-process "hugo-server" "*hugo-server*" - "hugo" "server" "-D" "--bind" "0.0.0.0" "--port" "1313") - ;; 等待服务器启动 - (sleep-for 2) - ;; 自动打开浏览器 - (browse-url "http://localhost:1313")))) + (function org-hugo-new-subtree-post-capture-template)))))) ;; 农历日历 (use-package cal-china-x