鍚堝苟鏈湴浠撳簱鍜岃繙绋嬩粨搴
This commit is contained in:
@@ -125,6 +125,7 @@
|
||||
(global-set-key (kbd "C-c f l") 'consult-locate) ;; consult-locate
|
||||
(global-set-key (kbd "C-c f g") 'consult-ripgrep) ;; consult-ripgrep
|
||||
(global-set-key (kbd "C-c y") 'consult-yank-from-kill-ring) ;; 从kill ring中粘贴
|
||||
(global-set-key (kbd "C-x r b") 'consult-bookmark) ;; 书签菜单,embark中有更多操作
|
||||
|
||||
;; hungry-delete
|
||||
(global-set-key (kbd "C-c DEL") 'hungry-delete-backward) ;; 向后删除到第一个非空字符
|
||||
@@ -165,5 +166,13 @@
|
||||
(consult-directory-externally default-directory))
|
||||
|
||||
(global-set-key (kbd "C-c f d") 'my-open-current-directory)
|
||||
|
||||
|
||||
;; org-mode
|
||||
(defun org-cycle-current-subtree()
|
||||
"Cycle current org-mode subtree."
|
||||
(interactive)
|
||||
(org-back-to-heading)
|
||||
(org-cycle))
|
||||
(global-set-key (kbd "C-<tab>") 'org-cycle-current-subtree)
|
||||
|
||||
(provide 'init-kbd)
|
||||
|
||||
@@ -47,4 +47,84 @@
|
||||
;; ...other commands here
|
||||
))
|
||||
|
||||
;; hugo
|
||||
(with-eval-after-load 'org-capture
|
||||
(defun org-hugo-new-subtree-post-capture-template ()
|
||||
"Returns `org-capture' template string for new Hugo post.
|
||||
See `org-capture-templates' for more information."
|
||||
(let* ((title (read-from-minibuffer "Post Title: ")) ;Prompt to enter the post title
|
||||
(fname (org-hugo-slug title)))
|
||||
(mapconcat #'identity
|
||||
`(
|
||||
,(concat "* TODO " title)
|
||||
":PROPERTIES:"
|
||||
,(concat ":EXPORT_FILE_NAME: " fname)
|
||||
":END:"
|
||||
"\n\n") ;Place the cursor here finally
|
||||
"\n")))
|
||||
|
||||
(add-to-list 'org-capture-templates
|
||||
'("h" ;`org-capture' binding + h
|
||||
"Hugo post"
|
||||
entry
|
||||
;; It is assumed that below file is present in `org-directory'
|
||||
;; 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 "d:/emacs/hugo/this-is-my-blog/all-blog.org" "Blog Ideas")
|
||||
(function org-hugo-new-subtree-post-capture-template))))
|
||||
|
||||
;; 快速部署
|
||||
(defun my-blog-publish ()
|
||||
"publish blog , git add/commit/push , generate commit message"
|
||||
(interactive)
|
||||
(let* ((blog-dir "d:/emacs/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)))))
|
||||
|
||||
(global-set-key (kbd "C-c o p") 'my-blog-publish)
|
||||
|
||||
;; 预览博客
|
||||
(defun my-blog-preview ()
|
||||
(interactive)
|
||||
(save-buffer)
|
||||
(let ((default-directory "d:/emacs/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")))
|
||||
|
||||
(global-set-key (kbd "C-c o v") 'my-blog-preview)
|
||||
|
||||
;; org tempo
|
||||
;; (require 'org-tempo)
|
||||
|
||||
;; 批量调整表格
|
||||
(defun org-table-align-all ()
|
||||
"Ajust all org table in current buffer."
|
||||
(interactive)
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(org-table-map-tables 'org-table-align t)))
|
||||
|
||||
(provide 'init-org)
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
(use-package savehist
|
||||
:hook (after-init . savehist-mode)
|
||||
:init (setq enable-recursive-minibuffers t
|
||||
history-length 1000
|
||||
history-length 50
|
||||
savehist-additional-variables '(mark-ring
|
||||
global-mark-ring
|
||||
search-ring
|
||||
@@ -88,4 +88,7 @@
|
||||
(use-package saveplace
|
||||
:hook (after-init . save-place-mode))
|
||||
|
||||
;; 安装ox-hugo
|
||||
(use-package ox-hugo)
|
||||
|
||||
(provide 'init-package)
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
;; 开启rencent file mode
|
||||
(recentf-mode)
|
||||
(setq recentf-max-saved-items 20) ;; 最大保存数量
|
||||
(setq recentf-max-saved-items 30) ;; 最大保存数量
|
||||
|
||||
;; 启用select delete
|
||||
(delete-selection-mode)
|
||||
|
||||
Reference in New Issue
Block a user