mirror of
https://github.com/js0ny/dotfiles.git
synced 2025-12-21 00:33:00 +00:00
feat(emacs): LLM, LaTeX
This commit is contained in:
parent
9b19b8b834
commit
cb81828291
8 changed files with 161 additions and 47 deletions
13
tools/emacs.d/lisp/init-ai.el
Normal file
13
tools/emacs.d/lisp/init-ai.el
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
(use-package copilot
|
||||||
|
:vc (:url "https://github.com/copilot-emacs/copilot.el"
|
||||||
|
:rev :newest
|
||||||
|
:branch "main")
|
||||||
|
:hook (prog-mode . copilot-mode)
|
||||||
|
:config
|
||||||
|
(define-key copilot-completion-map (kbd "<tab>") 'copilot-accept-completion)
|
||||||
|
(define-key copilot-completion-map (kbd "TAB") 'copilot-accept-completion))
|
||||||
|
|
||||||
|
|
||||||
|
(provide 'init-ai)
|
||||||
|
|
||||||
|
;;; init-ai.el ends here
|
||||||
|
|
@ -1,12 +1,23 @@
|
||||||
;;; init-appearance.el
|
;;; init-appearance.el
|
||||||
|
|
||||||
(when (display-graphic-p)
|
;; Always set frame font
|
||||||
(add-to-list 'default-frame-alist '(font . "Maple Mono NF CN")))
|
;; If don't set this, `emacs --daemon' will not set the font
|
||||||
|
;; for new graphical frames.
|
||||||
|
(add-to-list 'default-frame-alist '(font . "Maple Mono NF CN"))
|
||||||
|
|
||||||
;; Set CJK Display Font
|
;; Set CJK Display Font
|
||||||
(dolist (charset '(kana han cjk-misc bopomofo))
|
(dolist (charset '(kana han cjk-misc bopomofo))
|
||||||
(set-fontset-font t charset (font-spec :family "Maple Mono NF CN")))
|
(set-fontset-font t charset (font-spec :family "Maple Mono NF CN")))
|
||||||
|
|
||||||
|
|
||||||
|
;; Variable Pitch Font
|
||||||
|
;; Used in `variable-pitch-mode'
|
||||||
|
(set-face-attribute 'variable-pitch nil
|
||||||
|
:family "LXGW WenKai Screen"
|
||||||
|
:height 140
|
||||||
|
:weight 'regular)
|
||||||
|
|
||||||
|
|
||||||
;; Icon Support
|
;; Icon Support
|
||||||
;; Once installed, Manually install the fonts required:
|
;; Once installed, Manually install the fonts required:
|
||||||
;; M-x all-the-icons-install-fonts
|
;; M-x all-the-icons-install-fonts
|
||||||
|
|
@ -87,6 +98,13 @@
|
||||||
|
|
||||||
(global-tab-line-mode) ; bufferline
|
(global-tab-line-mode) ; bufferline
|
||||||
|
|
||||||
|
(use-package highlight-indent-guides
|
||||||
|
:hook ((prog-mode yaml-mode org-mode) . highlight-indent-guides-mode)
|
||||||
|
:init
|
||||||
|
(setq highlight-indent-guides-method 'column)
|
||||||
|
(setq highlight-indent-guides-responsive 'top)
|
||||||
|
(setq highlight-indent-guides-auto-character-face-perc 5))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(provide 'init-appearance)
|
(provide 'init-appearance)
|
||||||
|
|
|
||||||
12
tools/emacs.d/lisp/init-beancount.el
Normal file
12
tools/emacs.d/lisp/init-beancount.el
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
;; (straight-use-package
|
||||||
|
;; '(beancount
|
||||||
|
;; :host github
|
||||||
|
;; :repo "beancount/beancount-mode"
|
||||||
|
;; :files ("*.el")))
|
||||||
|
|
||||||
|
(use-package beancount
|
||||||
|
:mode (("\\.beancount\\'" . beancount-mode)
|
||||||
|
("\\.bean\\'" . beancount-mode)))
|
||||||
|
|
||||||
|
|
||||||
|
(provide 'init-beancount)
|
||||||
|
|
@ -40,6 +40,11 @@
|
||||||
:config
|
:config
|
||||||
(setq treemacs-persist-file (expand-file-name "treemacs-persist" user-emacs-data)))
|
(setq treemacs-persist-file (expand-file-name "treemacs-persist" user-emacs-data)))
|
||||||
|
|
||||||
|
|
||||||
|
(use-package treemacs-nerd-icons
|
||||||
|
:config
|
||||||
|
(treemacs-load-theme "nerd-icons"))
|
||||||
|
|
||||||
(use-package treemacs-evil
|
(use-package treemacs-evil
|
||||||
:after (treemacs evil)
|
:after (treemacs evil)
|
||||||
:ensure t
|
:ensure t
|
||||||
|
|
|
||||||
|
|
@ -16,16 +16,34 @@
|
||||||
;; set condition!
|
;; set condition!
|
||||||
:cond #'texmathp ; expand only while in math
|
:cond #'texmathp ; expand only while in math
|
||||||
"nabl" "\\nabla"
|
"nabl" "\\nabla"
|
||||||
|
"lg" "\\lg"
|
||||||
|
"hat" "\\hat"
|
||||||
|
;; "iint" "\\iint"
|
||||||
|
;; "int" "\\int"
|
||||||
|
"cdot" "\\cdot"
|
||||||
|
"dif" "\\mathrm{d}"
|
||||||
|
"pm" "\\pm"
|
||||||
|
"mp" "\\mp"
|
||||||
|
"sq" "\\sqrt"
|
||||||
|
;; bind to functions!
|
||||||
|
"mk" (lambda () (interactive)
|
||||||
|
(yas-expand-snippet "\\( $1 \\)$0"))
|
||||||
"ppart" (lambda () (interactive)
|
"ppart" (lambda () (interactive)
|
||||||
(yas-expand-snippet "\\frac{\\partial $2}{\\partial $1} $0"))
|
(yas-expand-snippet "\\frac{\\partial $2}{\\partial $1} $0"))
|
||||||
;; bind to functions!
|
"rm" (lambda () (interactive)
|
||||||
|
(yas-expand-snippet "\\mathrm{$1} $0"))
|
||||||
|
"sb" (lambda () (interactive)
|
||||||
|
(yas-expand-snippet "_{$1} $0"))
|
||||||
"Sum" (lambda () (interactive)
|
"Sum" (lambda () (interactive)
|
||||||
(yas-expand-snippet "\\sum_{$1}^{$2} $0"))
|
(yas-expand-snippet "\\sum_{$1}^{$2} $0"))
|
||||||
"Span" (lambda () (interactive)
|
"Span" (lambda () (interactive)
|
||||||
(yas-expand-snippet "\\Span($1)$0"))
|
(yas-expand-snippet "\\Span($1)$0"))
|
||||||
;; add accent snippets
|
;; add accent snippets
|
||||||
:cond #'laas-object-on-left-condition
|
:cond #'laas-object-on-left-condition
|
||||||
"qq" (lambda () (interactive) (laas-wrap-previous-object "sqrt")))
|
"qq" (lambda () (interactive) (laas-wrap-previous-object "sqrt"))
|
||||||
|
:cond #'(lambda () (and (not (texmathp))
|
||||||
|
(looking-back "^" nil)))
|
||||||
|
"dm" '(yas "\\[\n$1\n\\]$0"))
|
||||||
)
|
)
|
||||||
|
|
||||||
(provide 'init-latex)
|
(provide 'init-latex)
|
||||||
|
|
|
||||||
|
|
@ -33,17 +33,26 @@
|
||||||
(org-src-preserve-indentation t) ; Prevent from auto-indent
|
(org-src-preserve-indentation t) ; Prevent from auto-indent
|
||||||
(org-startup-folded 'showall)
|
(org-startup-folded 'showall)
|
||||||
:config
|
:config
|
||||||
|
(require 'org-habit)
|
||||||
(with-eval-after-load 'org
|
(with-eval-after-load 'org
|
||||||
(define-key org-mode-map (kbd "C-j") 'org-return-indent)
|
(define-key org-mode-map (kbd "C-j") 'org-return-indent)
|
||||||
(evil-define-key 'normal org-mode-map (kbd "TAB") 'org-cycle))
|
(evil-define-key 'normal org-mode-map (kbd "TAB") 'org-cycle))
|
||||||
(evil-define-key 'normal org-mode-map (kbd "SPC a") 'org-agenda-list) ; TODO: Here Simulates the leader
|
(evil-define-key 'normal org-mode-map (kbd "SPC a") 'org-agenda-list) ; TODO: Here Simulates the leader
|
||||||
(setq org-emphasis-alist
|
;; (setq org-emphasis-alist
|
||||||
'(("*" (bold :foreground "cyan" ))
|
;; '(("*" (bold :foreground "cyan" ))
|
||||||
("/" (italic :foreground "green"))
|
;; ("/" (italic :foreground "green"))
|
||||||
("_" underline)
|
;; ("_" underline)
|
||||||
("=" (org-verbatim verbatim :background "maroon" :foreground "white"))
|
;; ("=" (org-verbatim verbatim :background "maroon" :foreground "white"))
|
||||||
("~" (org-code verbatim :background "maroon" :foreground "white"))
|
;; ("~" (org-code verbatim :background "maroon" :foreground "white"))
|
||||||
("+" (:strike-through t))))
|
;; ("+" (:strike-through t))))
|
||||||
|
(custom-set-faces
|
||||||
|
'(org-bold ((t (:weight bold :foreground unspecified))))
|
||||||
|
'(org-italic ((t (:slant italic :foreground unspecified))))
|
||||||
|
'(org-underline ((t (:underline t :foreground unspecified))))
|
||||||
|
'(org-code ((t (:inherit fixed-pitch :background unspecified :foreground unspecified))))
|
||||||
|
'(org-verbatim ((t (:inherit fixed-pitch :background unspecified :foreground unspecified))))
|
||||||
|
'(org-strike-through ((t (:strike-through t :foreground unspecified)))))
|
||||||
|
|
||||||
|
|
||||||
(dolist (face '((org-level-1 . 1.6)
|
(dolist (face '((org-level-1 . 1.6)
|
||||||
(org-level-2 . 1.4)
|
(org-level-2 . 1.4)
|
||||||
|
|
@ -56,7 +65,6 @@
|
||||||
(set-face-attribute (car face) nil :height (cdr face))))
|
(set-face-attribute (car face) nil :height (cdr face))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;; Org Styling
|
;; Org Styling
|
||||||
|
|
||||||
;; Set Org Styles
|
;; Set Org Styles
|
||||||
|
|
@ -125,7 +133,22 @@
|
||||||
(global-set-key (kbd "C-c i") (lambda () (interactive) (js0ny/insert-emphasis-with-zws ?/)))
|
(global-set-key (kbd "C-c i") (lambda () (interactive) (js0ny/insert-emphasis-with-zws ?/)))
|
||||||
|
|
||||||
;; Pomodoro for org clock
|
;; Pomodoro for org clock
|
||||||
(use-package org-pomodoro)
|
(use-package org-pomodoro
|
||||||
|
:straight t
|
||||||
|
:bind (:map org-mode-map
|
||||||
|
("C-c p" . org-pomodoro)))
|
||||||
|
|
||||||
|
|
||||||
|
(defun js0ny/org-pomodoro-resume-last-task ()
|
||||||
|
"Clock in to the last task and start Pomodoro on it."
|
||||||
|
(interactive)
|
||||||
|
(let ((marker (car org-clock-history)))
|
||||||
|
(if marker
|
||||||
|
(progn
|
||||||
|
(org-with-point-at marker
|
||||||
|
(org-clock-in))
|
||||||
|
(org-pomodoro))
|
||||||
|
(message "No previous clock task found."))))
|
||||||
|
|
||||||
(use-package org-modern
|
(use-package org-modern
|
||||||
:ensure t
|
:ensure t
|
||||||
|
|
@ -207,6 +230,8 @@
|
||||||
'(
|
'(
|
||||||
(python . t) ; No need to declare C/C++/emacs-lisp since is integrated
|
(python . t) ; No need to declare C/C++/emacs-lisp since is integrated
|
||||||
(shell . t)
|
(shell . t)
|
||||||
|
(dot . t)
|
||||||
|
(ditaa . t)
|
||||||
))
|
))
|
||||||
;; Don't ask me again when running source block
|
;; Don't ask me again when running source block
|
||||||
;; Use clang as default C/C++ Compiler on macOS and Windows
|
;; Use clang as default C/C++ Compiler on macOS and Windows
|
||||||
|
|
@ -224,50 +249,67 @@
|
||||||
|
|
||||||
;; icalendar
|
;; icalendar
|
||||||
|
|
||||||
|
(defun my/org-icalendar-filter-out-habits (entry backend info)
|
||||||
|
"Filter out Org entries that are marked as habits when exporting to iCalendar."
|
||||||
|
(when (and (eq backend 'icalendar)
|
||||||
|
(string-match ":STYLE:.*habit" (or entry "")))
|
||||||
|
nil))
|
||||||
|
|
||||||
|
(add-hook 'org-export-filter-entry-functions #'my/org-icalendar-filter-out-habits)
|
||||||
|
|
||||||
|
|
||||||
(setq org-icalendar-use-scheduled '(event-if-todo event-if-not-todo))
|
(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-use-deadline '(event-if-todo event-if-not-todo))
|
||||||
(setq org-icalendar-combined-agenda-file "~/Dropbox/org.ics")
|
(setq org-icalendar-combined-agenda-file "~/Dropbox/org.ics")
|
||||||
|
|
||||||
|
|
||||||
;; Integrate Emacs Timer with System Notifications
|
;; ;; Integrate Emacs Timer with System Notifications
|
||||||
;; 定义通知函数
|
;; ;; 定义通知函数
|
||||||
(defun js0ny/org-clock-notification (title message &optional icon)
|
;; (defun js0ny/org-clock-notification (title message &optional icon)
|
||||||
"发送一个系统通知"
|
;; "发送一个系统通知"
|
||||||
(alert message
|
;; (alert message
|
||||||
:title title
|
;; :title title
|
||||||
:icon icon
|
;; :icon icon
|
||||||
:category 'org-clock))
|
;; :category 'org-clock))
|
||||||
|
|
||||||
;; 添加定时器检查函数
|
;; ;; 添加定时器检查函数
|
||||||
(defun js0ny/org-clock-check-timer ()
|
;; (defun js0ny/org-clock-check-timer ()
|
||||||
"检查当前正在运行的 clock 是否到期"
|
;; "检查当前正在运行的 clock 是否到期"
|
||||||
(when (org-clocking-p)
|
;; (when (org-clocking-p)
|
||||||
(let* ((clocked-time (org-clock-get-clocked-time))
|
;; (let* ((clocked-time (org-clock-get-clocked-time))
|
||||||
(effort (org-duration-to-minutes
|
;; (effort (org-duration-to-minutes
|
||||||
(or (org-entry-get (org-clock-is-active) "Effort")
|
;; (or (org-entry-get (org-clock-is-active) "Effort")
|
||||||
"0")))
|
;; "0")))
|
||||||
(remaining (- effort clocked-time)))
|
;; (remaining (- effort clocked-time)))
|
||||||
(when (and (> effort 0) (<= remaining 0))
|
;; (when (and (> effort 0) (<= remaining 0))
|
||||||
(js0ny/org-clock-notification
|
;; (js0ny/org-clock-notification
|
||||||
"Org Clock 提醒"
|
;; "Org Clock 提醒"
|
||||||
(format "任务 '%s' 的预计时间已到!"
|
;; (format "任务 '%s' 的预计时间已到!"
|
||||||
(org-clock-get-clock-string)))))))
|
;; (org-clock-get-clock-string)))))))
|
||||||
|
|
||||||
;; 设置定时器,每分钟检查一次
|
;; ;; 设置定时器,每分钟检查一次
|
||||||
(run-with-timer 0 60 #'js0ny/org-clock-check-timer)
|
;; (run-with-timer 0 60 #'js0ny/org-clock-check-timer)
|
||||||
|
|
||||||
;; 在 org-clock-in-hook 中添加检查
|
;; 在 org-clock-in-hook 中添加检查
|
||||||
(add-hook 'org-clock-in-hook
|
;; (add-hook 'org-clock-in-hook
|
||||||
(lambda ()
|
;; (lambda ()
|
||||||
(let ((effort (org-entry-get (point) "Effort")))
|
;; (let ((effort (org-entry-get (point) "Effort")))
|
||||||
(when effort
|
;; (when effort
|
||||||
(js0ny/org-clock-notification
|
;; (js0ny/org-clock-notification
|
||||||
"开始计时"
|
;; "开始计时"
|
||||||
(format "开始计时任务: %s\n预计用时: %s"
|
;; (format "开始计时任务: %s\n预计用时: %s"
|
||||||
(org-get-heading t t t t)
|
;; (org-get-heading t t t t)
|
||||||
effort))))))
|
;; effort))))))
|
||||||
(use-package org-node
|
(use-package org-node
|
||||||
:after org
|
:after org
|
||||||
:config (org-node-cache-mode))
|
:config (org-node-cache-mode))
|
||||||
|
|
||||||
|
|
||||||
|
;; ;; 执行最后一行,重新生成解析表达式
|
||||||
|
;; (with-eval-after-load 'org
|
||||||
|
;; ;; 添加常见全角标点
|
||||||
|
;; (setf (nth 1 org-emphasis-regexp-components)
|
||||||
|
;; " \t\r\n,.:!?:;。,!?、」』)〉》」』〕〗】})]")
|
||||||
|
;; (org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components))
|
||||||
|
|
||||||
(provide 'init-org)
|
(provide 'init-org)
|
||||||
|
|
|
||||||
5
tools/emacs.d/lisp/init-scratch.el
Normal file
5
tools/emacs.d/lisp/init-scratch.el
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
|
||||||
|
(setq initial-major-mode 'org-mode)
|
||||||
|
|
||||||
|
|
||||||
|
(provide 'init-scratch)
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
;; TODO
|
;; TODO
|
||||||
(use-package flyspell)
|
(use-package flyspell)
|
||||||
|
|
||||||
(use-package olivetti)
|
(use-package olivetti
|
||||||
|
:hook (olivetti-mode . org-mode))
|
||||||
|
|
||||||
(provide 'init-writer)
|
(provide 'init-writer)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue