From 73692fb22588391f2ec3a147e6e943b12629ac1b Mon Sep 17 00:00:00 2001 From: trogloxene Date: Wed, 8 Apr 2026 20:13:04 +0800 Subject: [PATCH] Config: add org-ql config, fix coding system of ripgrep --- custom.el | 9 ++++----- init.el | 2 +- lisp/init-const.el | 9 +++++++-- lisp/init-kbd.el | 17 ++++++++++++++++- lisp/init-org.el | 40 +++++++++++++++++++++++++++++++++------- lisp/init-package.el | 8 +++++--- lisp/init-workspace.el | 3 +-- 7 files changed, 67 insertions(+), 21 deletions(-) diff --git a/custom.el b/custom.el index 5f2239f..a748ea5 100644 --- a/custom.el +++ b/custom.el @@ -4,12 +4,11 @@ ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. - '(org-agenda-files nil) '(package-selected-packages - '(ace-window benchmark-init cape cnfonts corfu crux drag-stuff eglot - embark-consult everything exec-path-form-shell gcmh - hungry-delete marginalia multiple-cursors orderless - restart-emacs smart-mode-line solarized-theme vertico)) + '(ace-window benchmark-init cape cnfonts corfu crux drag-stuff eglot embark-consult everything + exec-path-form-shell gcmh hungry-delete marginalia multiple-cursors orderless + restart-emacs smart-mode-line solarized-theme vertico)) + '(safe-local-variable-values '((org-use-tag-inheritance))) '(warning-suppress-log-types '((initialization)))) (custom-set-faces ;; custom-set-faces was added by Custom. diff --git a/init.el b/init.el index c276cf3..226597d 100644 --- a/init.el +++ b/init.el @@ -22,8 +22,8 @@ (require 'init-window) (require 'init-dired) (require 'init-workspace) -(require 'init-kbd) (require 'init-ui) +(require 'init-kbd) (require 'init-segmentation) ;;; init.el ends here diff --git a/lisp/init-const.el b/lisp/init-const.el index cb5c451..81bb4da 100644 --- a/lisp/init-const.el +++ b/lisp/init-const.el @@ -24,8 +24,13 @@ (setq default-process-coding-system '(utf-8 . utf-8)) ;; 为特定程序设置编码 - (add-to-list 'process-coding-system-alist '("rg" utf-8 . utf-8)) - (add-to-list 'process-coding-system-alist '("ripgrep" utf-8 . utf-8)) + (if *is-windows* + (progn + (add-to-list 'process-coding-system-alist '("rg" utf-8 . gbk)) + (add-to-list 'process-coding-system-alist '("ripgrep" utf-8 . gbk))) + (progn + (add-to-list 'process-coding-system-alist '("rg" utf-8 . utf-8)) + (add-to-list 'process-coding-system-alist '("ripgrep" utf-8 . utf-8)))) (add-to-list 'process-coding-system-alist '("grep" utf-8 . utf-8)) (add-to-list 'process-coding-system-alist '("find" utf-8 . utf-8)) (add-to-list 'process-coding-system-alist '("fd" utf-8 . utf-8)) diff --git a/lisp/init-kbd.el b/lisp/init-kbd.el index 444efce..712292d 100644 --- a/lisp/init-kbd.el +++ b/lisp/init-kbd.el @@ -305,7 +305,18 @@ Disable jinx-mode if it's enable and global-jinx-mode is disable , otherwise tog ;; heading菜单 (with-eval-after-load 'org - (define-key org-mode-map (kbd "C-c i") 'consult-org-heading)) + (define-key org-mode-map (kbd "C-c i") 'consult-org-heading)) + +;; 用consult检索org-agenda-file标题 +(global-set-key (kbd "C-c o s") 'consult-org-agenda) + +;; 用ripgrep搜索org-agenda-file +(defun my/org-agenda-rifle (dirs-to-exclude) + "Jump to org agenda files use consult-ripgrep." + (interactive) + (consult-ripgrep org-agenda-files) + +(global-set-key (kbd "C-c o g") 'my/org-agenda-rifle) ;; 存储一个链接 (global-set-key (kbd "C-c l") 'org-store-link) @@ -319,6 +330,10 @@ Disable jinx-mode if it's enable and global-jinx-mode is disable , otherwise tog '(define-key calendar-mode-map (kbd "j o") 'org-journal-open-entry-for-editing) '(define-key calendar-mode-map (kbd "") 'org-journal-open-entry-for-editing))) +;; org-ql +(global-set-key (kbd "C-c q s") 'org-ql-search) +(global-set-key (kbd "C-c q v") 'org-ql-view) + ;; 日记 (defun org-journal-open-current-journal-file-delete-other-window() "Call org-journal-open-current-journal-file and delete other window." diff --git a/lisp/init-org.el b/lisp/init-org.el index d1a1fb3..271cc6a 100644 --- a/lisp/init-org.el +++ b/lisp/init-org.el @@ -155,10 +155,9 @@ (global-set-key (kbd "C-c a") 'org-agenda) (when *is-windows* - (with-eval-after-load 'org - (setq org-agenda-files '("h:/emacs/hugo/this-is-my-blog/all-blog.org" - "h:/emacs/my-org-daily/" - "h:/emacs/my-org-note/")))) + (setq org-agenda-files '("h:/emacs/hugo/this-is-my-blog/all-blog.org" + "h:/emacs/my-org-daily/" + "h:/emacs/my-org-note/"))) (when *is-mac* (with-eval-after-load 'org (setq org-agenda-files '("~/org/my-org-daily")))) @@ -173,6 +172,25 @@ ;; org-ql (use-package org-ql) +(setq org-ql-views + '(("tags: emacs category:note" + :buffers-files org-agenda-files + :query (and (tags "emacs") (category "note")) + :sort date) + + ("tags: org" + :buffers-files org-agenda-files + :query (tags "org")) + + ("all important todos" + :buffers-files org-agenda-files + :query (and (not (done)) (todo)) + :super-groups + ((:name "priority = A" :priority "A") + (:name "priority = B" :priority "B") + (:name "started" :todo "STARTED") + (:name "someday" :todo "SOMEDAY"))))) + ;; org-super-agenda 配置 (use-package org-super-agenda :config @@ -214,6 +232,7 @@ (setq org-tag-alist '( ("scheme" . ?s) ("emacs" . ?e) + ("org" . ?o) ("linux" . ?l) ("computer-stuff" . ?c) ("philosophy" . ?p) @@ -221,6 +240,8 @@ ("gamestudies" . ?G) )) +;; (setq org-tags-exclude-from-inheritance '()) + ;; capture模板 (when *is-windows* (defvar my-org-capture-temp-title "" "Temporarily store the org-capture filename.") @@ -233,15 +254,20 @@ (format-time-string "%Y%m%d") my-org-capture-temp-title)))) "#+title: %(symbol-value 'my-org-capture-temp-title) -#+created: %U +#+date: %U #+category: %^{Category|none|plan|book|article|note|insight} -#+filetags: %^g -* %(symbol-value 'my-org-capture-temp-title) +* %(symbol-value 'my-org-capture-temp-title) %^g +%U :PROPERTIES: :END: %? + + +# Local Variables: +# org-use-tag-inheritance: nil +# End: " :jump-to-captured t)))) diff --git a/lisp/init-package.el b/lisp/init-package.el index 9137a2b..a02fbe2 100644 --- a/lisp/init-package.el +++ b/lisp/init-package.el @@ -98,10 +98,12 @@ (default-directory "~/")) (consult-fd))) - (if *is-windows* - (progn + (when *is-windows* (setq consult-locate-args (encode-coding-string "es.exe -i -p -r" 'gbk)) - (add-to-list 'process-coding-system-alist '("es" gbk . gbk)))) + (setq consult-ripgrep-args (encode-coding-string + "rg --null --line-buffered --color=never --max-columns=1000 --path-separator / --smart-case --no-heading --line-number" + 'gbk)) + (add-to-list 'process-coding-system-alist '("es" gbk . gbk))) (when *is-mac* (setopt consult-locate-args "mdfind -name"))) diff --git a/lisp/init-workspace.el b/lisp/init-workspace.el index 3fe1648..74eb375 100644 --- a/lisp/init-workspace.el +++ b/lisp/init-workspace.el @@ -18,8 +18,7 @@ (add-to-list 'consult-buffer-sources persp-consult-source)) (setq switch-to-prev-buffer-skip (lambda (win buff bury-or-kill) - (not (persp-is-current-buffer buff)))) - ) + (not (persp-is-current-buffer buff))))) (provide 'init-workspace)