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
This commit is contained in:
@@ -44,7 +44,8 @@
|
|||||||
"^\\*Help"
|
"^\\*Help"
|
||||||
"Diff"
|
"Diff"
|
||||||
"straight"
|
"straight"
|
||||||
"\\*Messages\\*")
|
"\\*Messages\\*"
|
||||||
|
"\\*Chinese-word-segmentation\\*")
|
||||||
:test 'equal)))
|
:test 'equal)))
|
||||||
|
|
||||||
;; embark,快捷指令
|
;; embark,快捷指令
|
||||||
|
|||||||
@@ -5,9 +5,6 @@
|
|||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
(use-package gptel
|
(use-package gptel
|
||||||
:hook
|
|
||||||
(gptel-mode-hook . visual-line-mode)
|
|
||||||
|
|
||||||
:config
|
:config
|
||||||
(setq gptel-log-level t)
|
(setq gptel-log-level t)
|
||||||
(setq gptel-default-mode 'org-mode)
|
(setq gptel-default-mode 'org-mode)
|
||||||
|
|||||||
@@ -108,6 +108,43 @@ Disable jinx-mode if it's enable and global-jinx-mode is disable , otherwise tog
|
|||||||
(interactive)
|
(interactive)
|
||||||
(align-regexp (region-beginning) (region-end) "\\(\\s-*\\)::" 1 1 nil))
|
(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()
|
(defun my-dired-next-line()
|
||||||
"Move to forward line in dired buffer"
|
"Move to forward line in dired buffer"
|
||||||
(interactive)
|
(interactive)
|
||||||
@@ -188,11 +225,6 @@ Disable jinx-mode if it's enable and global-jinx-mode is disable , otherwise tog
|
|||||||
(interactive)
|
(interactive)
|
||||||
(load-file (expand-file-name "~/.emacs.d/lisp/fix-theme-colors.el")))
|
(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*
|
(when *is-linux*
|
||||||
(defun reboot ()
|
(defun reboot ()
|
||||||
"Execute loginctl reboot command."
|
"Execute loginctl reboot command."
|
||||||
|
|||||||
@@ -77,6 +77,16 @@
|
|||||||
"V" 'project-vc-dir
|
"V" 'project-vc-dir
|
||||||
"a" 'gptel-agent-project)
|
"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
|
;; t for modes toggle
|
||||||
(general-def
|
(general-def
|
||||||
:prefix "C-c t"
|
:prefix "C-c t"
|
||||||
|
|||||||
@@ -49,6 +49,13 @@
|
|||||||
(setq org-agenda-skip-function-global
|
(setq org-agenda-skip-function-global
|
||||||
'(org-agenda-skip-entry-if 'todo '("COMMENT"))))
|
'(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
|
;; org-babel scheme
|
||||||
(use-package ob-scheme
|
(use-package ob-scheme
|
||||||
:demand t
|
: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
|
;; and that it has a "Blog Ideas" heading. It can even be a
|
||||||
;; symlink pointing to the actual location of all-posts.org!
|
;; symlink pointing to the actual location of all-posts.org!
|
||||||
(file+headline "~/org/hugo/this-is-my-blog/all-blog.org" "Blog Ideas")
|
(file+headline "~/org/hugo/this-is-my-blog/all-blog.org" "Blog Ideas")
|
||||||
(function org-hugo-new-subtree-post-capture-template)))))
|
(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"))))
|
|
||||||
|
|
||||||
;; 农历日历
|
;; 农历日历
|
||||||
(use-package cal-china-x
|
(use-package cal-china-x
|
||||||
|
|||||||
Reference in New Issue
Block a user