breaking: Remove setup script and use chezmoi

This commit is contained in:
js0ny 2025-09-27 02:25:06 +01:00
parent 02bbb24cac
commit 0051a163c3
190 changed files with 118 additions and 3456 deletions

View file

@ -0,0 +1,35 @@
;;; init-beancount.el --- beancount support -*- lexical-binding: t -*-
(after! beancount
;; 1. 自动启用 outline-minor-mode
(add-hook! 'beancount-mode-hook #'outline-minor-mode)
;; 2. 设置大纲导航快捷键 (使用 Doom 的 map! 宏)
(map! :map beancount-mode-map
"C-c C-n" #'outline-next-visible-heading
"C-c C-p" #'outline-previous-visible-heading)
;; 3. 核心功能:跨文件账户补全 (这部分逻辑完全保留)
(defvar my-beancount-accounts-files nil "List of account files.")
(setq my-beancount-accounts-files
(directory-files "~/Documents/Finance/Beancount/config/" 'full (rx ".beancount" eos)))
(defun my-beancount--collect-accounts-from-files (oldfun &rest args)
"Collect all accounts from files specified in `my-beancount-accounts-files'."
(let ((keys (apply oldfun args))
(hash (make-hash-table :test 'equal)))
(dolist (key keys)
(puthash key nil hash))
;; collect accounts from files
(save-excursion
(dolist (f my-beancount-accounts-files)
;; `ignore-errors` is a good practice for file operations
(ignore-errors
(with-current-buffer (find-file-noselect f)
(goto-char (point-min))
(while (re-search-forward beancount-account-regexp nil t)
(puthash (match-string-no-properties 1) nil hash))))))
(hash-table-keys hash)))
(advice-add #'beancount-collect
:around #'my-beancount--collect-accounts-from-files))

View file

@ -0,0 +1,79 @@
;;; ~/.doom.d/+calendar.el -*- lexical-binding: t; -*-
;;; https://github.com/cnsunyour/.doom.d/blob/master/modules/cnsunyour/calendar/config.el
;; 日历及纪念日相关设置
;; 定义可以设置农历纪念日的函数
;; (defun cnsunyour/diary-chinese-anniversary (lunar-month lunar-day &optional year mark)
;; (if year
;; (let* ((d-date (diary-make-date lunar-month lunar-day year))
;; (a-date (calendar-absolute-from-gregorian d-date))
;; (c-date (calendar-chinese-from-absolute a-date))
;; (cycle (car c-date))
;; (yy (cadr c-date))
;; (y (+ (* 100 cycle) yy)))
;; (diary-chinese-anniversary lunar-month lunar-day y mark))
;; (diary-chinese-anniversary lunar-month lunar-day year mark)))
(setq calendar-date-style 'iso)
(setq diary-date-forms '((year "" month "" day "" " 星期[" "日一二三四五六" "]") ;; Chinese
(year "-" month "-" day) ;; ISO
(month "[-/]" day "[^-/0-9]") (year "[-/]" month "[-/]" day "[^0-9]")
(monthname " *" day "[^-0-9]") (year " *" monthname " *" day "[^0-9]")
(dayname "\\W")))
(setq calendar-mark-holidays-flag t
calendar-week-start-day 1)
(use-package! cal-china-x
:custom
(cal-china-x-important-holidays '((holiday-chinese-new-year)
(holiday-lunar 12 23 "小年(北)" 1)
(holiday-lunar 12 24 "小年(南)" 1)
(holiday-lunar 12 30 "除夕" 1)
(holiday-lunar 1 1 "春节" 0)
(holiday-lunar 1 2 "春节" 0)
(holiday-lunar 1 3 "春节" 0)
(holiday-lunar 1 4 "春节" 0)
(holiday-lunar 1 5 "春节(破五)" 0)
(holiday-lunar 1 15 "元宵节" 0)
(holiday-lunar 2 2 "龙抬头" 0)
(holiday-solar-term "清明" "清明节")
(holiday-fixed 5 1 "劳动节")
(holiday-lunar 5 5 "端午节" 0)
(holiday-lunar 7 7 "七夕节" 0)
(holiday-lunar 7 15 "中元节" 0)
(holiday-lunar 8 15 "中秋节" 0)
(holiday-fixed 10 1 "国庆节")
(holiday-fixed 10 2 "国庆节")
(holiday-fixed 10 3 "国庆节")
(holiday-lunar 9 9 "重阳节" 0)
(holiday-lunar 10 1 "寒衣节" 0)
(holiday-lunar 12 8 "腊八" 1)
(holiday-solar-term "立春" "立春")
(holiday-solar-term "立夏" "立夏")
(holiday-solar-term "立秋" "立秋")
(holiday-solar-term "立冬" "立冬")
(holiday-solar-term "春分" "春分")
(holiday-solar-term "夏至" "夏至")
(holiday-solar-term "秋分" "秋分")
(holiday-solar-term "冬至" "冬至")))
(cal-china-x-general-holidays '((holiday-fixed 1 1 "元旦")
(holiday-fixed 2 14 "情人节")
(holiday-fixed 3 8 "妇女节")
(holiday-fixed 4 1 "愚人节")
(holiday-fixed 5 4 "青年节")
(holiday-float 5 0 2 "母亲节")
(holiday-fixed 6 1 "儿童节")
(holiday-float 6 0 3 "父亲节")
(holiday-fixed 9 10 "教师节")
(holiday-float 11 4 4 "感恩节")
(holiday-fixed 12 25 "圣诞节")))
:config
(setq calendar-holidays (append cal-china-x-important-holidays
cal-china-x-general-holidays)))
;; diary
(setq diary-file "~/.local/js0ny/diary")

158
dot_config/doom/config.el Normal file
View file

@ -0,0 +1,158 @@
;;; $DOOMDIR/config.el -*- lexical-binding: t; -*-
;; Place your private configuration here! Remember, you do not need to run 'doom
;; sync' after modifying this file!
;; Some functionality uses this to identify you, e.g. GPG configuration, email
;; clients, file templates and snippets. It is optional.
;; (setq user-full-name "John Doe"
;; user-mail-address "john@doe.com")
;; Doom exposes five (optional) variables for controlling fonts in Doom:
;;
;; - `doom-font' -- the primary font to use
;; - `doom-variable-pitch-font' -- a non-monospace font (where applicable)
;; - `doom-big-font' -- used for `doom-big-font-mode'; use this for
;; presentations or streaming.
;; - `doom-symbol-font' -- for symbols
;; - `doom-serif-font' -- for the `fixed-pitch-serif' face
;;
;; See 'C-h v doom-font' for documentation and more examples of what they
;; accept. For example:
;;
;; https://emacs-china.org/t/doom-emacs/23513/13
(setq doom-font (font-spec :family "Maple Mono NF CN" :size 14)
doom-serif-font doom-font
doom-symbol-font (font-spec :family "Maple Mono NF CN")
doom-variable-pitch-font (font-spec :family "Maple Mono NF CN" :weight 'extra-bold))
;; 如果不把这玩意设置为 nil, 会默认去用 fontset-default 来展示, 配置无效
(setq use-default-font-for-symbols nil)
;; Doom 的字体加载顺序问题, 如果不设定这个 hook, 配置会被覆盖失效
;;(add-hook! 'after-setting-font-hook
;; (set-fontset-font t 'latin (font-spec :family "Iosevka Nerd Font Propo"))
;; (set-fontset-font t 'symbol (font-spec :family "Symbola"))
;; (set-fontset-font t 'mathematical (font-spec :family "Symbola"))
;; (set-fontset-font t 'emoji (font-spec :family "Symbola")))
;; (dolist (charset '(kana han cjk-misc bopomofo))
;; (set-fontset-font t charset (font-spec :family "LXGW WenKai Mono" :size 16)))
;;
;; If you or Emacs can't find your font, use 'M-x describe-font' to look them
;; up, `M-x eval-region' to execute elisp code, and 'M-x doom/reload-font' to
;; refresh your font settings. If Emacs still can't find your font, it likely
;; wasn't installed correctly. Font issues are rarely Doom issues!
;; There are two ways to load a theme. Both assume the theme is installed and
;; available. You can either set `doom-theme' or manually load a theme with the
;; `load-theme' function. This is the default:
(setq doom-theme 'catppuccin)
(setq catppuccin-flavor 'mocha)
;(catppuccin-reload)
;; This determines the style of line numbers in effect. If set to `nil', line
;; numbers are disabled. For relative line numbers, set this to `relative'.
(setq display-line-numbers t)
(setq display-line-numbers-type 'visual)
;; Whenever you reconfigure a package, make sure to wrap your config in an
;; `after!' block, otherwise Doom's defaults may override your settings. E.g.
;;
;; (after! PACKAGE
;; (setq x y))
;;
;; The exceptions to this rule:
;;
;; - Setting file/directory variables (like `org-directory')
;; - Setting variables which explicitly tell you to set them before their
;; package is loaded (see 'C-h v VARIABLE' to look up their documentation).
;; - Setting doom variables (which start with 'doom-' or '+').
;;
;; Here are some additional functions/macros that will help you configure Doom.
;;
;; - `load!' for loading external *.el files relative to this one
;; - `use-package!' for configuring packages
;; - `after!' for running code after a package has loaded
;; - `add-load-path!' for adding directories to the `load-path', relative to
;; this file. Emacs searches the `load-path' when you load packages with
;; `require' or `use-package'.
;; - `map!' for binding new keys
;;
;; To get information about any of these functions/macros, move the cursor over
;; the highlighted symbol at press 'K' (non-evil users must press 'C-c c k').
;; This will open documentation for it, including demos of how they are used.
;; Alternatively, use `C-h o' to look up a symbol (functions, variables, faces,
;; etc).
;;
;; You can also try 'gd' (or 'C-c c d') to jump to their definition and see how
;; they are implemented.
(add-to-list 'load-path (expand-file-name "lisp" doom-user-dir))
(setq doom-local-dir (expand-file-name "emacs" (getenv "XDG_DATA_HOME")))
(setq doom-data-dir (expand-file-name "etc" doom-local-dir))
(after! recentf
(setq recentf-max-saved-items 200)
(add-to-list 'recentf-exclude "\\.revive$")
(add-to-list 'recentf-exclude "\\.windows$")
(add-to-list 'recentf-exclude "\\.#.+$")
(add-to-list 'recentf-exclude "^/tmp/")
(add-to-list 'recentf-exclude "COMMIT_EDITMSG\\'")
)[1][2]
(after! wakatime-mode
(global-wakatime-mode)
(setq wakatime-cli-path "~/.local/bin/wakatime"))
;; accept completion from copilot and fallback to company
(use-package! copilot
:hook (prog-mode . copilot-mode)
:bind (:map copilot-completion-map
("<tab>" . 'copilot-accept-completion)
("TAB" . 'copilot-accept-completion)
("C-TAB" . 'copilot-accept-completion-by-word)
("C-<tab>" . 'copilot-accept-completion-by-word)))
(load! "evil.el")
(load! "treemacs.el")
(load! "org.el")
(after! evil-matchit
(global-evil-matchit-mode 1)
)
(if (eq system-type 'gnu/linux)
(use-package! rime
:custom
(rime-user-data-dir (expand-file-name "emacs-rime" (getenv "XDG_CONFIG_HOME")))
; (rime-share-data-dir "~/.local/share/fcitx5/rime")
(default-input-method "rime")
;; :config
;; (add-hook! (org-mode markdown-mode) (activate-input-method default-input-method))
))
(load! "calendar.el")
(when (file-exists-p (expand-file-name "local.el" doom-user-dir))
(load! "local.el"))
;; (load! "telega.el")
(use-package! eee
:config
(if (eq system-type 'gnu/linux)
(setq ee-terminal-command "kitty"))
)
(load! "beancount.el")

View file

@ -0,0 +1,13 @@
;;; -*- lexical-binding: t -*-
(custom-set-variables
;; custom-set-variables was added by Custom.
;; 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.
'(auth-source-save-behavior nil))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; 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.
)

View file

@ -0,0 +1,3 @@
.custom.el
local.el
themes/

15
dot_config/doom/evil.el Normal file
View file

@ -0,0 +1,15 @@
(map!
:nvm "H" 'evil-prev-buffer
:nvm "L" 'evil-next-buffer
:nvom "J" '(lambda () (interactive) (evil-next-line 5)) ; 5j
:nvom "K" '(lambda () (interactive) (evil-previous-line 5)) ; 5k
)
;; Swap ; and :
(map! :leader
";" #'execute-extended-command
":" #'pp-eval-expression
"f h" #'consult-recent-file
"b D" #'kill-some-buffers
"f c" #'doom/open-private-config
"f C" #'editorconfig-find-current-editorconfig)

206
dot_config/doom/init.el Normal file
View file

@ -0,0 +1,206 @@
;;; init.el -*- lexical-binding: t; -*-
;; This file controls what Doom modules are enabled and what order they load
;; in. Remember to run 'doom sync' after modifying it!
;; NOTE Press 'SPC h d h' (or 'C-h d h' for non-vim users) to access Doom's
;; documentation. There you'll find a link to Doom's Module Index where all
;; of our modules are listed, including what flags they support.
;; NOTE Move your cursor over a module's name (or its flags) and press 'K' (or
;; 'C-c c k' for non-vim users) to view its documentation. This works on
;; flags as well (those symbols that start with a plus).
;;
;; Alternatively, press 'gd' (or 'C-c c d') on a module to browse its
;; directory (for easy access to its source code).
(doom! :input
;;bidi ; (tfel ot) thgir etirw uoy gnipleh
;;; 关闭 chinese 以启用 best Chinese IME
;; chinese
;;japanese
;;layout ; auie,ctsrnm is the superior home row
:completion
;;company ; the ultimate code completion backend
(corfu +orderless) ; complete with cap(f), cape and a flying feather!
;;helm ; the *other* search engine for love and life
;;ido ; the other *other* search engine...
;;ivy ; a search engine for love and life
vertico ; the search engine of the future
:ui
;;deft ; notational velocity for Emacs
doom ; what makes DOOM look the way it does
doom-dashboard ; a nifty splash screen for Emacs
;;doom-quit ; DOOM quit-message prompts when you quit Emacs
;;(emoji +unicode) ; 🙂
hl-todo ; highlight TODO/FIXME/NOTE/DEPRECATED/HACK/REVIEW
indent-guides ; highlighted indent columns
ligatures ; ligatures and symbols to make your code pretty again
minimap ; show a map of the code on the side
modeline ; snazzy, Atom-inspired modeline, plus API
;;nav-flash ; blink cursor line after big motions
;;neotree ; a project drawer, like NERDTree for vim
ophints ; highlight the region an operation acts on
(popup +defaults) ; tame sudden yet inevitable temporary windows
tabs ; a tab bar for Emacs
treemacs ; a project drawer, like neotree but cooler
unicode ; extended unicode support for various languages
(vc-gutter +pretty) ; vcs diff in the fringe
vi-tilde-fringe ; fringe tildes to mark beyond EOB
;;window-select ; visually switch windows
workspaces ; tab emulation, persistence & separate workspaces
;;zen ; distraction-free coding or writing
:editor
(evil +everywhere); come to the dark side, we have cookies
file-templates ; auto-snippets for empty files
fold ; (nigh) universal code folding
(format +onsave) ; automated prettiness
;;god ; run Emacs commands without modifier keys
;;lispy ; vim for lisp, for people who don't like vim
multiple-cursors ; editing in many places at once
;;objed ; text object editing for the innocent
;;parinfer ; turn lisp into python, sort of
;;rotate-text ; cycle region at point between text candidates
snippets ; my elves. They type so I don't have to
word-wrap ; soft wrapping with language-aware indent
:emacs
dired ; making dired pretty [functional]
electric ; smarter, keyword-based electric-indent
;;eww ; the internet is gross
;;ibuffer ; interactive buffer management
undo ; persistent, smarter undo for your inevitable mistakes
vc ; version-control and Emacs, sitting in a tree
:term
eshell ; the elisp shell that works everywhere
;;shell ; simple shell REPL for Emacs
;;term ; basic terminal emulator for Emacs
;;vterm ; the best terminal emulation in Emacs
:checkers
syntax ; tasing you for every semicolon you forget
;;(spell +flyspell) ; tasing you for misspelling mispelling
grammar ; tasing grammar mistake every you make
:tools
;;ansible
;;biblio ; Writes a PhD for you (citation needed)
;;collab ; buffers with friends
;;debugger ; FIXME stepping through code, to help you add bugs
;;direnv
;;docker
editorconfig ; let someone else argue about tabs vs spaces
;;ein ; tame Jupyter notebooks with emacs
(eval +overlay) ; run code, run (also, repls)
lookup ; navigate your code and its documentation
lsp ; M-x vscode
magit ; a git porcelain for Emacs
;;make ; run make tasks from Emacs
;;pass ; password manager for nerds
;;pdf ; pdf enhancements
;;prodigy ; FIXME managing external services & code builders
;;terraform ; infrastructure as code
;;tmux ; an API for interacting with tmux
tree-sitter ; syntax and parsing, sitting in a tree...
;;upload ; map local to remote projects via ssh/ftp
:os
(:if (featurep :system 'macos) macos) ; improve compatibility with macOS
;;tty ; improve the terminal Emacs experience
:lang
;;agda ; types of types of types of types...
beancount ; mind the GAAP
(cc +lsp) ; C > C++ == 1
;;clojure ; java with a lisp
;;common-lisp ; if you've seen one lisp, you've seen them all
;;coq ; proofs-as-programs
;;crystal ; ruby at the speed of c
;;csharp ; unity, .NET, and mono shenanigans
data ; config/data formats
;;(dart +flutter) ; paint ui and not much else
;;dhall
;;elixir ; erlang done right
;;elm ; care for a cup of TEA?
emacs-lisp ; drown in parentheses
;;erlang ; an elegant language for a more civilized age
;;ess ; emacs speaks statistics
;;factor
;;faust ; dsp, but you get to keep your soul
;;fortran ; in FORTRAN, GOD is REAL (unless declared INTEGER)
;;fsharp ; ML stands for Microsoft's Language
;;fstar ; (dependent) types and (monadic) effects and Z3
;;gdscript ; the language you waited for
;;(go +lsp) ; the hipster dialect
;;(graphql +lsp) ; Give queries a REST
(haskell +lsp) ; a language that's lazier than I am
;;hy ; readability of scheme w/ speed of python
;;idris ; a language you can depend on
(json +lsp +tree-sitter) ; At least it ain't XML
;;(java +lsp) ; the poster child for carpal tunnel syndrome
;;javascript ; all(hope(abandon(ye(who(enter(here))))))
;;julia ; a better, faster MATLAB
;;kotlin ; a better, slicker Java(Script)
(latex +latexmk +cdlatex +lsp) ; writing papers in Emacs has never been so fun
;;lean ; for folks with too much to prove
;;ledger ; be audit you can be
;lua ; one-based indices? one-based indices
markdown ; writing docs for people to ignore
;;nim ; python + lisp at the speed of c
nix ; I hereby declare "nix geht mehr!"
;;ocaml ; an objective camel
(org ; organize your plain life in plain text
+pomodoro
+dragndrop
+noter
+pandoc
+pretty
)
;;php ; perl's insecure younger brother
;;plantuml ; diagrams for confusing people more
;;graphviz ; diagrams for confusing yourself even more
;;purescript ; javascript, but functional
(python +lsp +tree-sitter +pyright) ; beautiful is better than ugly
;;qt ; the 'cutest' gui framework ever
;;racket ; a DSL for DSLs
;;raku ; the artist formerly known as perl6
;;rest ; Emacs as a REST client
;;rst ; ReST in peace
;;(ruby +rails) ; 1.step {|i| p "Ruby is #{i.even? ? 'love' : 'life'}"}
;;(rust +lsp) ; Fe2O3.unwrap().unwrap().unwrap().unwrap()
;;scala ; java, but good
(scheme +guile) ; a fully conniving family of lisps
(sh +lsp +tree-sitter +fish) ; she sells {ba,z,fi}sh shells on the C xor
;;sml
;;solidity ; do you need a blockchain? No.
;;swift ; who asked for emoji variables?
;;terra ; Earth and Moon in alignment for performance.
;;web ; the tubes
(yaml +lsp +tree-sitter) ; JSON, but readable
;;zig ; C, but simpler
:email
(mu4e +org +gmail)
;;notmuch
;;(wanderlust +gmail)
:app
calendar
;;emms
;;everywhere ; *leave* Emacs!? You must be joking
;;irc ; how neckbeards socialize
(rss +org) ; emacs as an RSS reader
:config
;;literate
(default +bindings +smartparens)
:personal
telega
)
(setq custom-file (expand-file-name ".custom.el" doom-user-dir))
(load custom-file t)

View file

@ -0,0 +1,84 @@
;;; org-pomodoro-music-controller.el --- Play music during org-pomodoro breaks -*- lexical-binding: t; -*-
;;; Commentary:
;;; Add music control to org-pomodoro breaks.
;;; Code:
(require 'org-pomodoro)
;; Variables
(defcustom org-pomodoro-music-player-command
(cond
((eq system-type 'windows-nt) "clmcontrol")
((eq system-type 'darwin) "nowplaying-cli")
((eq system-type 'gnu/linux) "playerctl")
(t "playerctl"))
"Command to control the music player."
:type 'string
:group 'org-pomodoro)
(defcustom org-pomodoro-music-player-args nil
"Arguments to pass to the music player command."
:type '(repeat string)
:group 'org-pomodoro)
(defun org-pomodoro-music-get-status ()
"Get thestatus of the music player."
(with-temp-buffer
(let ((args (append org-pomodoro-music-player-args '("status"))))
(apply #'call-process org-pomodoro-music-player-command nil t nil args)
(string-trim (buffer-string)))))
(defun org-pomodoro-music-is-playing-p ()
"Check if the music player is playing."
(let ((status (org-pomodoro-music-get-status)))
(string= status "Playing")))
(defun org-pomodoro-music-pause ()
"Stop the music player."
(let ((args (append org-pomodoro-music-player-args '("pause"))))
(apply #'call-process org-pomodoro-music-player-command nil nil nil args)))
(defun org-pomodoro-music-play ()
"Start the music player."
(let ((args (append org-pomodoro-music-player-args '("play"))))
(apply #'call-process org-pomodoro-music-player-command nil nil nil args)))
;; Defining Hooks
(defun org-pomodoro-music-break-started-hook ()
"When a break start, pause the music player."
(setq org-pomodoro-music-was-playing (org-pomodoro-music-is-playing-p))
(when org-pomodoro-music-was-playing
(org-pomodoro-music-pause)
(message "休息开始,音乐已暂停")))
;; (defun org-pomodoro-music-break-finished-hook ()
;; "When a break finishes, resume the music player."
;; (when (and org-pomodoro-music-was-playing
;; (not (org-pomodoro-music-is-playing-p)))
;; (org-pomodoro-music-play)
;; (message "休息结束,音乐已恢复播放"))
;; (setq org-pomodoro-music-was-playing nil))
(defun org-pomodoro-music-started-hook ()
"When a pomodoro start, play the music player."
(unless (org-pomodoro-music-is-playing-p)
(org-pomodoro-music-play)
(message "番茄开始,音乐已开始播放"))
)
;; Adding hooks
;; (add-hook 'org-pomodoro-break-started-hook #'org-pomodoro-music-break-started-hook)
;; (add-hook 'org-pomodoro-break-finished-hook #'org-pomodoro-music-break-finished-hook)
;; (add-hook 'org-pomodoro-long-break-started-hook #'org-pomodoro-music-break-started-hook)
;; (add-hook 'org-pomodoro-long-break-finished-hook #'org-pomodoro-music-break-finished-hook)
(add-hook 'org-pomodoro-started-hook #'org-pomodoro-music-started-hook)
(provide 'org-pomodoro-music-controller)
;;; org-pomodoro-music-controller.el ends here

View file

@ -0,0 +1,57 @@
;;; org-pomodoro-telegram-notifier.el --- 为 org-pomodoro 添加发送 Telegram 通知的功能。 -*- lexical-binding: t; -*-
;;; Commentary:
;;; Provide a way to send Telegram notifications when org-pomodoro breaks end.
;;; Code:
(require 'org-pomodoro)
(require 'request)
(defcustom org-pomodoro-telegram-bot-token ""
"Your Telegram bot token."
:type 'string
:group 'org-pomodoro)
(defcustom org-pomodoro-telegram-chat-id ""
"Your Telegram chat ID."
:type 'string
:group 'org-pomodoro)
(defcustom org-pomodoro-telegram-break-end-message "休息时间结束"
"The message to send when a break ends."
:type 'string
:group 'org-pomodoro)
(defun org-pomodoro-send-telegram-message (message)
"Send a message to the Telegram chat.
MESSAGE is the message to send."
(interactive)
(when (and (not (string-empty-p org-pomodoro-telegram-bot-token))
(not (string-empty-p org-pomodoro-telegram-chat-id)))
(request
(format "https://api.telegram.org/bot%s/sendMessage" org-pomodoro-telegram-bot-token)
:type "POST"
:data `(("chat_id" . ,org-pomodoro-telegram-chat-id)
("text" . ,"⏳<b>[Emacs]</b> <code>org-pomodoro</code>: 休息时间结束")
("parse_mode" . "HTML"))
:parser 'json-read
:success (cl-function
(lambda (&key data &allow-other-keys)
(message "成功发送 Telegram 通知")))
:error (cl-function
(lambda (&key error-thrown &allow-other-keys)
(message "发送 Telegram 通知失败: %S" error-thrown))))
)
)
(defun org-pomodoro-telegram-break-finished-hook ()
"Send a Telegram message when a break ends."
(org-pomodoro-send-telegram-message org-pomodoro-telegram-break-end-message))
(add-hook 'org-pomodoro-break-finished-hook #'org-pomodoro-telegram-break-finished-hook)
(add-hook 'org-pomodoro-long-break-finished-hook #'org-pomodoro-telegram-break-finished-hook)
(provide 'org-pomodoro-telegram-notifier)
;;; org-pomodoro-telegram-notifier.el ends here

228
dot_config/doom/org.el Normal file
View file

@ -0,0 +1,228 @@
;; If use `org' and don't want your org files in the default location below,
;; change `org-directory'. It must be set before org loads!
(setq org-directory "~/OrgFiles/")
;; (setq org-roam-directory "~/OrgFiles/roam/")
;;; org general
(after! org
;; For CJK users
;; Insert zero width space around the emphasis symbols, this might be useful for
;; languages that does not rely on space
(defun my/insert-emphasis-with-zws (char)
(interactive "c")
(insert ?\u200B char)
(save-excursion (insert char ?\u200B)))
;; Directory
(setq org-archive-location "~/OrgFiles/.archive/%s_archive::")
(setq org-default-notes-file "~/OrgFiles/tasks/inbox.org")
;; Initial Visibility
(setq org-startup-folded "show2levels")
;; Log into drawer
(setq org-log-into-drawer "LOGBOOK")
;;
(setq org-todo-keywords '((sequence "TODO(t)" "NEXT(n)" "WAIT(w@/!)" "|" "DONE(d@/!)" "CANCELLED(c@)")
))
(setq org-todo-keyword-faces
'(("TODO" . (:foreground "red" :weight bold :background "yellow"))
("NEXT" . (:foreground "blue" :weight bold :background "lightgray"))
("WAIT" . (:foreground "orange" :weight bold))
("DONE" . (:foreground "grey" :weight bold :italic t))
("CANCELLED" . (:foreground "grey" :weight bold))
))
;; Keymaps
(map! :map org-mode-map
:desc "Bold with ZWS" "C-c b" (lambda () (interactive) (my/insert-emphasis-with-zws ?*))
:desc "Italic with ZWS" "C-c i" (lambda () (interactive) (my/insert-emphasis-with-zws ?/))
:desc "Underline with ZWS" "C-c u" (lambda () (interactive) (my/insert-emphasis-with-zws ?_))
:desc "Code with ZWS" "C-c c" (lambda () (interactive) (my/insert-emphasis-with-zws ?~))
:nvom "M-n" 'org-metadown
:nvom "M-e" 'org-metaup)
(setq org-capture-templates
'(("t" "Task" entry (file+headline "~/OrgFiles/tasks/inbox.org" "Tasks")
"* TODO %?\n %U\n %a\n %i"
:empty-lines 1)
("n" "Note" entry (file+headline "~/OrgFiles/tasks/inbox.org" "Notes"))
))
;; 处理 Zotero 链接
(org-link-set-parameters
"zotero"
:follow (lambda (path) (browse-url (concat "zotero://" path)))
:export (lambda (path desc format)
(cond
((eq format 'html) (format "<a href=\"zotero://%s\">%s</a>" path (or desc path)))
((eq format 'latex) (format "\\href{zotero://%s}{%s}" path (or desc path)))
(t path))))
;; 处理 Obsidian 链接
(org-link-set-parameters
"obsidian"
:follow (lambda (path) (browse-url (concat "obsidian://" path)))
:export (lambda (path desc format)
(cond
((eq format 'html) (format "<a href=\"obsidian://%s\">%s</a>" path (or desc path)))
((eq format 'latex) (format "\\href{obsidian://%s}{%s}" path (or desc path)))
(t path))))
)
(after! evil-org
(map! :map evil-org-mode-map
:n "L" 'evil-org-insert-line
:n "I" 'evil-next-buffer
)
)
;;; org-agenda
(after! org-agenda
;; (setq org-agenda-files (directory-files-recursively "~/OrgFiles/tasks/" "\\.org$"))
(setq org-agenda-files (list (concat org-directory "tasks/")))
)
(map! :after org-agenda
:map evil-org-agenda-mode-map
:m "n" #'org-agenda-next-line
:m "e" #'org-agenda-previous-line
:m "gn" #'org-agenda-next-item
:m "ge" #'org-agenda-previous-item
:m "N" #'org-agenda-priority-up
:m "E" #'org-agenda-priority-down
:m "i" #'evil-forward-char
:m "," #'org-agenda-priority
:m "x" #'org-agenda-todo
:m "t" #'org-agenda-set-tags
:m "w" #'org-save-all-org-buffers
;; d: date reschedule
:m "ds" #'org-agenda-schedule
:m "dd" #'org-agenda-deadline
:m "$" #'org-agenda-archive
:m "!" #'org-agenda-toggle-deadlines
;; c: clock
:m "cp" #'org-pomodoro
:m "vd" #'org-agenda-day-view
:m "vw" #'org-agenda-week-view
:m "vm" #'org-agenda-month-view
:m "vy" #'org-agenda-year-view
:m "v." #'org-agenda-reset-view
:leader :desc "Org Agenda" "A" #'org-agenda)
(setq org-agenda-prefix-format '((agenda . " %i %-12:c%?-12t% s")
(todo . " %i %-12:c %e")
(tags . " %i %-12:c %e ")
(search . " %i %-12:c %e ")))
;; https://github.com/AbstProcDo/Master-Emacs-From-Scratch-with-Solid-Procedures/blob/master/06.Emacs-as-Agenda-by-Org.org
;;Sunrise and Sunset
;;日出而作, 日落而息
(defun js0ny/diary-sunrise ()
(let ((dss (diary-sunrise-sunset)))
(with-temp-buffer
(insert dss)
(goto-char (point-min))
(while (re-search-forward " ([^)]*)" nil t)
(replace-match "" nil nil))
(goto-char (point-min))
(search-forward ",")
(buffer-substring (point-min) (match-beginning 0)))))
(defun js0ny/diary-sunset ()
(let ((dss (diary-sunrise-sunset))
start end)
(with-temp-buffer
(insert dss)
(goto-char (point-min))
(while (re-search-forward " ([^)]*)" nil t)
(replace-match "" nil nil))
(goto-char (point-min))
(search-forward ", ")
(setq start (match-end 0))
(search-forward " at")
(setq end (match-beginning 0))
(goto-char start)
(capitalize-word 1)
(buffer-substring start end))))
(after! (org-agenda cal-china-x)
(setq org-agenda-format-date 'org-agenda-format-date-aligned)
(defun org-agenda-format-date-aligned (date)
"Format a DATE string for display in the daily/weekly agenda, or timeline.
This function makes sure that dates are aligned for easy reading."
(require 'cal-iso)
(let* ((dayname (aref cal-china-x-days
(calendar-day-of-week date)))
(day (cadr date))
(month (car date))
(year (nth 2 date))
(cn-date (calendar-chinese-from-absolute (calendar-absolute-from-gregorian date)))
(cn-month (cl-caddr cn-date))
(cn-day (cl-cadddr cn-date))
(cn-month-string (concat (aref cal-china-x-month-name
(1- (floor cn-month)))
(if (integerp cn-month)
""
"(闰月)")))
(cn-day-string (aref cal-china-x-day-name
(1- cn-day))))
(format "%04d-%02d-%02d 周%s %s%s" year month
day dayname cn-month-string cn-day-string))))
(setq org-agenda-time-grid (quote ((daily today require-timed)
(300 600 900 1200 1500 1800 2100 2400)
"......"
"-----------------------------------------------------"
)))
;; org-agenda-clockreport
(setq org-agenda-clockreport-parameter-plist '(:link t :maxlevel 3 :fileskip0 t :compact t :narrow 80))
;;; org-clock
;; org-pomodoro
(after! org-pomodoro
(setq org-pomodoro-format "Pomo~%s")
(setq org-pomodoro-short-break-format "摸~%s")
(setq org-pomodoro-long-break-format "猛摸~%s")
)
;;; org-babel
(if (not (eq system-type 'gnu/linux))
(setq org-babel-C-compiler "clang"))
;;; org-export
;; icalendar
(setq org-icalendar-use-scheduled '(event-if-todo event-if-not-todo))
(setq org-icalendar-use-deadline '(event-if-todo event-if-not-todo))
(setq org-icalendar-combined-agenda-file "~/Dropbox/org.ics")
(use-package! org-pomodoro-music-controller
:after org-pomodoro
:config
(customize-set-variable 'org-pomodoro-music-player-args '("--player=cider"))
)
(use-package! org-pomodoro-telegram-notifier
:after org-pomodoro
)

View file

@ -0,0 +1,68 @@
;; -*- no-byte-compile: t; -*-
;;; $DOOMDIR/packages.el
;; To install a package with Doom you must declare them here and run 'doom sync'
;; on the command line, then restart Emacs for the changes to take effect -- or
;; To install SOME-PACKAGE from MELPA, ELPA or emacsmirror:
;; (package! some-package)
;; To install a package directly from a remote git repo, you must specify a
;; `:recipe'. You'll find documentation on what `:recipe' accepts here:
;; https://github.com/radian-software/straight.el#the-recipe-format
;; (package! another-package
;; :recipe (:host github :repo "username/repo"))
;; If the package you are trying to install does not contain a PACKAGENAME.el
;; file, or is located in a subdirectory of the repo, you'll need to specify
;; `:files' in the `:recipe':
;; (package! this-package
;; :recipe (:host github :repo "username/repo"
;; :files ("some-file.el" "src/lisp/*.el")))
;; If you'd like to disable a package included with Doom, you can do so here
;; with the `:disable' property:
;; (package! builtin-package :disable t)
;; You can override the recipe of a built in package without having to specify
;; all the properties for `:recipe'. These will inherit the rest of its recipe
;; from Doom or MELPA/ELPA/Emacsmirror:
;; (package! builtin-package :recipe (:nonrecursive t))
;; (package! builtin-package-2 :recipe (:repo "myfork/package"))
;; Specify a `:branch' to install a package from a particular branch or tag.
;; This is required for some packages whose default branch isn't 'master' (which
;; our package manager can't deal with; see radian-software/straight.el#279)
;; (package! builtin-package :recipe (:branch "develop"))
;; Use `:pin' to specify a particular commit to install.
;; (package! builtin-package :pin "1a2b3c4d5e")
;; Doom's packages are pinned to a specific commit and updated from release to
;; release. The `unpin!' macro allows you to unpin single packages...
;; (unpin! pinned-package)
;; ...or multiple packages
;; (unpin! pinned-package another-pinned-package)
;; ...Or *all* packages (NOT RECOMMENDED; will likely break things)
;; (unpin! t)
(package! wakatime-mode)
(package! copilot
:recipe (:host github :repo "copilot-emacs/copilot.el" :files ("*.el")))
(package! evil-matchit)
(package! rime)
(package! ox-typst)
(package! cal-china-x)
(package! telega :recipe (:files (:defaults "contrib/*.el" "etc" "server" "Makefile")))
(package! org-super-agenda)
(package! catppuccin-theme)
(package! eee
:recipe (:host github :repo "eval-exec/eee.el"
:files (:defaults "*.el" "*.sh")))

View file

@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# name: align-math
# key: ali
# expand-env: ((yas-indent-line 'fixed))
# --
\\begin{align*}
$1
\\end{align*}

View file

@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# name: display-math
# key: dm
# expand-env: ((yas-indent-line 'fixed))
# --
\\[
$1
\\]

View file

@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# name: inline-math
# key: mk
# expand-env: ((yas-indent-line 'fixed))
# --
\\( $1 \\)

View file

@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# name: Limit
# key: lim
# condition: (org-inside-LaTeX-fragment-p)
# --
\\lim_{$1 \to $2} $0

View file

@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# name: Summation
# key: sum
# condition: (org-inside-LaTeX-fragment-p)
# --
\\sum_{$1}^{$2} $0

View file

@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: unnumbered
# key: unnumbered
# --
:PROPERTIES:
:UNNUMBERED: t
:END:

72
dot_config/doom/telega.el Normal file
View file

@ -0,0 +1,72 @@
;; -*- lexical-binding: t; -*-
;; telegram client for emacs
(use-package! telega
:init
(setq telega-server-libs-prefix "/usr")
(setq telega-directory (expand-file-name "~/.local/share/telega"))
;; (prefix-key global-map (kbd "C-c t") telega-prefix-map)
(unless (display-graphic-p) (setq telega-use-images nil))
(when (modulep! :editor evil)
(cl-pushnew 'telega +evil-collection-disabled-list :test #'equal)
(setq evil-collection-mode-list (remove 'telega evil-collection-mode-list))
(set-evil-initial-state! '(telega-root-mode telega-chat-mode) 'emacs))
:hook
(telega-load . telega-mode-line-mode)
(telega-load . global-telega-url-shorten-mode)
(telega-load . global-telega-mnz-mode)
(telega-load . telega-autoplay-mode)
(telega-load . telega-transient-mode)
(telega-load . telega-adblock-mode)
(telega-chat-mode . (lambda ()
(setq-local visual-fill-column-extra-text-width
'(0 . 2))))
:config
(add-hook 'telega-msg-ignore-predicates
(telega-match-gen-predicate 'msg '(sender is-blocked)))
(setq telega-chat-show-deleted-messages-for '(me-is-owner OR-ADMIN)
;; telega-use-tracking-for '(or mention (and unread unmuted))
telega-open-file-function 'org-open-file
;; telega-open-message-as-file '(video video-note)
telega-translate-to-language-by-default "zh"
telega-avatar-workaround-gaps-for `(return t)
telega-mode-line-string-format (remove
'(:eval (telega-mode-line-icon))
telega-mode-line-string-format))
(map! (:prefix "C-c"
:desc "Telega all chats"
"c" #'telega-chat-with
:desc "Telega important chats"
"v" #'telega-switch-important-chat
:desc "Telega next important chat"
"SPC" (cmd! (let ((current-prefix-arg '(4)))
(call-interactively #'telega-switch-important-chat))))
(:map telega-chat-mode-map
(:prefix ("C-t" . "Telega chat topic")
:desc "Telega filter by chat topic"
"C-t" #'telega-chatbuf-filter-by-topic
:desc "Telega clear chat topic"
"C-c" #'telega-chatbuf-thread-cancel)))
; (load! "+telega-auto-input-method")
(set-popup-rule! (regexp-quote telega-root-buffer-name)
:slot 10 :vslot 10 :side 'right :size 90 :ttl nil :quit 'current :modeline t)
(set-popup-rule! "^◀[^◀\[]*[\[({<].+[\])}>]"
:slot 10 :vslot 10 :side 'right :size 90 :ttl 10 :quit 'current :modeline t)
(set-popup-rule! (regexp-quote "*Telega User*")
:slot 20 :vslot 10 :side 'right :height .5 :ttl 10 :quit t :modeline nil :select t)
(set-popup-rule! (regexp-quote "*Telegram Chat Info*")
:slot 20 :vslot 10 :side 'right :height .5 :ttl 10 :quit t :modeline nil :select t))
;; (load! "+telega-addition")
(use-package! telega-dired-dwim
:after telega dired)
(use-package! telega-bridge-bot
:after telega)

View file

@ -0,0 +1,24 @@
(after! treemacs
(map! :map evil-treemacs-state-map
"n" #'treemacs-next-line
"e" #'treemacs-previous-line
"N" #'treemacs-next-neighbour
"E" #'treemacs-previous-neighbour
"H" #'treemacs-toggle-show-dotfiles
"I" #'treemacs-hide-gitignored-files-mode
"i" #'treemacs-RET-action
"a" #'treemacs-create-file
"A" #'treemacs-create-dir
"c" #'treemacs-copy-file
"x" #'treemacs-move-file
"d" #'treemacs-delete-file
"r" #'treemacs-rename-file
"q" #'treemacs-quit
"y" #'treemacs-copy-relative-path-at-point
"Y" #'treemacs-copy-absolute-path-at-point
"m" #'treemacs-mark-or-unmark-path-at-point
)
)
(map! :leader
:desc "Toggle Treemacs" "f t" #'+treemacs/toggle)