1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
;;; utils.el --- Utility functions and dashboard -*- lexical-binding: t -*-
;; Copyright (C) 2024 Cytrogen
;; This file contains:
;; - Custom dashboard and startup screen
;; - File and system utilities
;; - Diagnostic and troubleshooting functions
;; - General helper functions
;;; Commentary:
;; Collection of utility functions and the custom dashboard that provides
;; a GTD-focused startup experience.
;;; Code:
;; File Utilities
;; File operation helper functions
(defun my/open-init-file ()
"Open the Emacs init.el file."
(interactive)
(find-file user-init-file))
(defun my/reload-init-file ()
"Reload the Emacs init.el file."
(interactive)
(load-file user-init-file)
(message "Init file reloaded."))
;; Custom Dashboard
;; GTD-focused startup screen
(defun my/show-dashboard ()
"Render a custom GTD dashboard."
(interactive)
(let ((buf (get-buffer-create "*Cytrogen's Home*")))
(with-current-buffer buf
(let ((inhibit-read-only t))
(erase-buffer)
;; Header
(insert "#+TITLE: Emacs 使用指南\n")
(insert "#+STARTUP: showall\n\n")
(insert "Welcome back, Cytrogen.\n\n")
;; ══════════════════════════════════════════════════════════════
;; Quick Reference - 快捷键速查
;; ══════════════════════════════════════════════════════════════
(insert "* 快捷键速查\n\n")
(insert "** 笔记与任务 (Org-mode)\n\n")
(insert "| 快捷键 | 功能 | 说明 |\n")
(insert "|-----------+--------------+--------------------------------|\n")
(insert "| =C-c c= | 快速记录 | 打开 Capture 面板,选择模板 |\n")
(insert "| =C-c a= | 日程视图 | 查看待办事项和日历 |\n")
(insert "| =C-c w= | 快速归档 | 将当前条目移动到指定位置 |\n")
(insert "| =C-c o= | 打开笔记 | 浏览并打开 Org 文件 |\n")
(insert "| =C-c C-c= | 确认 | 在 Capture 中保存条目 |\n")
(insert "| =C-c C-k= | 取消 | 在 Capture 中放弃当前编辑 |\n\n")
(insert "** 博客发布\n\n")
(insert "| 快捷键 | 功能 | 说明 |\n")
(insert "|-------------+------------+--------------------------------|\n")
(insert "| =C-c b c= | 创建月刊 | 创建新的月刊文件 |\n")
(insert "| =C-c b o= | 打开月刊 | 打开当前月刊 |\n")
(insert "| =C-c b m= | 导出月刊 | 将当前月刊导出为 Markdown |\n")
(insert "| =C-c b p= | 导出文章 | 导出 posts/ 目录下的单篇文章 |\n")
(insert "| =C-c b n= | 条目转文章 | 将笔记条目转为独立博客文章 |\n")
(insert "| =C-c b i= | 插入图片 | 插入博客图片链接 |\n\n")
(insert "** 阅读与订阅\n\n")
(insert "| 快捷键 | 功能 | 说明 |\n")
(insert "|-----------+------------+--------------------------------|\n")
(insert "| =C-c f= | RSS 阅读器 | 打开 elfeed 查看订阅 |\n")
(insert "| =C-c e= | 邮件 | 打开 mu4e 邮件客户端 |\n\n")
(insert "OPDS 浏览器: =M-x my/opds-browse= 浏览 Calibre 书库\n\n")
(insert "** 社交\n\n")
(insert "| 快捷键 | 功能 | 说明 |\n")
(insert "|-----------+------------+--------------------------------|\n")
(insert "| =C-c m= | Mastodon | 打开长毛象客户端 |\n\n")
(insert "** 系统管理\n\n")
(insert "| 快捷键 | 功能 | 说明 |\n")
(insert "|-----------+------------+--------------------------------|\n")
(insert "| =C-c i= | 编辑配置 | 打开 init.el 配置文件 |\n")
(insert "| =C-c r= | 重载配置 | 重新加载 Emacs 配置 |\n\n")
;; ══════════════════════════════════════════════════════════════
;; Workflows - 工作流程
;; ══════════════════════════════════════════════════════════════
(insert "* 工作流程\n\n")
(insert "** GTD 三步法\n\n")
(insert "#+begin_quote\n")
(insert "大脑用来思考,不是用来记事的。\n")
(insert "#+end_quote\n\n")
(insert "1. *Capture(收集)* → =C-c c=\n")
(insert " 任何想法、任务、灵感,第一时间放入 Inbox。\n\n")
(insert "2. *Process(整理)* → =C-c w=\n")
(insert " 定期清空 Inbox,将条目归档到具体项目。\n\n")
(insert "3. *Do(执行)* → =C-c a=\n")
(insert " 通过 Agenda 查看今日待办,专注当下。\n\n")
(insert "** 博客写作流程\n\n")
(insert "*** 记录灵感\n")
(insert "=C-c c= → =m= (Monthly 子菜单) → 选择分类:\n")
(insert "- =ma= 商业与社会\n")
(insert "- =mb= 心理与关系\n")
(insert "- =mc= 技术与创造\n")
(insert "- =md= 生活与文娱\n\n")
(insert "*** 发布内容\n")
(insert "- 月刊: 在月刊文件中按 =C-c b m= 导出\n")
(insert "- 单篇: 在 posts/ 文章中按 =C-c b p= 导出\n")
(insert "- 转换: 光标在条目上按 =C-c b n= 创建独立文章\n\n")
;; ══════════════════════════════════════════════════════════════
;; Useful Commands - 常用命令
;; ══════════════════════════════════════════════════════════════
(insert "* 常用命令 (M-x)\n\n")
(insert "** 博客\n")
(insert "- =my/blog-create-monthly= - 创建新月刊\n")
(insert "- =my/blog-open-current-monthly= - 打开当前月刊\n\n")
(insert "** 阅读\n")
(insert "- =my/opds-browse= - 浏览 Calibre OPDS 书库\n")
(insert "- =elfeed-update= - 更新 RSS 订阅\n\n")
(insert "** 系统\n")
(insert "- =my/show-dashboard= - 显示此帮助页面\n")
(insert "- =my/reload-org-structure= - 重载 Org 结构配置\n")
(insert "- =my/check-gpg-status= - 检查 GPG 状态\n")
(insert "- =my/fix-epa-issues= - 修复 GPG/EPA 问题\n\n")
;; Footer
(insert "-----\n")
(insert "/保持简单,保持流动。/\n")
(org-mode)
(when (fboundp 'my/org-mode-visual-setup)
(my/org-mode-visual-setup))
(org-indent-mode 1)
(visual-line-mode 1)
;; 跳过被隐藏的元数据行,将视图定位到第一行可见文本
(while (get-char-property (point) 'invisible)
(forward-line 1))))
(switch-to-buffer buf)
;; 延迟定位到第一行可见内容
(run-with-idle-timer 0.1 nil
(lambda ()
(when (and (get-buffer "*Cytrogen's Home*")
(string= (buffer-name (current-buffer)) "*Cytrogen's Home*"))
(goto-char (point-min))
(while (and (not (eobp))
(get-char-property (point) 'invisible))
(forward-line 1)))))))
;; Dashboard startup configuration
(setq inhibit-startup-screen t)
(add-hook 'emacs-startup-hook #'my/show-dashboard)
;; System Diagnostics
;; Troubleshooting and status functions
;; General Utilities
;; Miscellaneous helper functions
(provide 'utils)
;;; utils.el ends here