General
使用journal.org来预览所有的journals,放在Journals文件夹。使用org-roam-capture
来生成每天的journal文件,以2024-01-01.org的文件格式命名。
使用org-roam-capture
来生成笔记文件,org-roam-node-find
或org-roam-node-insert
来生成新笔记。
使用org-roam-ui来预览pkm,提供tag检索,反链显示。

org-mode和org-roam部分语法格式是不通用的。
org-roam的node-insert生成的链接格式是[[id:xxxx][node]]
,而org-mode的链接格式为[[file:path/to/file][file]]
。org-roam正是通过id来链接各个文件。这是需要权衡的。
Ref:Hyperlinks (The Org Manual)
Tags
标签方面,org-mode提供#+FILETAGS: :Peter:Boss:Secret:
这样的文件标签,以及
#+TAGS: [ Control : Context Task ]
#+TAGS: [ Persp : Vision Goal AOF Project ]
这样的组标签,可以根据分类选择具体标签。
以及i love Emacs and org-mode. :org:emacs:
这样的行内标签。单个标签为:tag:
Ref:标签层次结构(组织手册) --- Tag Hierarchy (The Org Manual)
但在org-roam里有一个提醒:
Tags for top-level (file) nodes are pulled from the variable
org-file-tags
, which is set by the#+filetags
keyword, as well as other tags the file may have inherited. Tags for headline level nodes are regular Org tags. 顶级(文件)节点的标签是从变量org-file-tags
中提取的,该变量由#+filetags
关键字以及文件可能继承的其他标签设置。标题级别节点的标签是常规组织标签。Note that the
#+filetags
keyword results in tags being inherited by headers within the file. This makes it impossible for selective tag inheritance: i.e. either tag inheritance is turned off, or all headline nodes will inherit the tags from the file node. This is a design compromise of Org-roam. 请注意,#+filetags
关键字会导致标记被文件内的标头继承。这使得选择性标签继承变得不可能:即要么关闭标签继承,要么所有标题节点将从文件节点继承标签。这是 Org-roam 的设计妥协。
为了避免冲突,我关闭了标签继承。
To limit tag inheritance to specific tags, or to turn it off entirely, use the variables
org-use-tag-inheritance
andorg-tags-exclude-from-inheritance
.要将标签继承限制为特定标签,或完全关闭它,请使用变量
org-use-tag-inheritance
和org-tags-exclude-from-inheritance
。
设置好了 org-agenda 的目录之后,:tags:
的方式可以直接点击这个tag使用org-agenda的视图来列举所有的tags,限制是这个tag要在heading里,为了和Markdown的兼容,部分不在heading里的tag,我还是使用#tags
的方式来标注。这样在全局搜索的时候,就可以搜索到所有的tags
了。
;; 自定义agenda的目录,可以全局搜索所所有tags, 包括 #+FILETAGS 和 :tags:
(defun my-tags-view ()
"Show all headlines for org files matching a TAGS criterion."
(interactive)
(let* ((org-agenda-files '("~/Vandee/pkm"))
(org-tags-match-list-sublevels nil))
(call-interactively 'org-tags-view)))
Journals
使用journal.org来预览所有的journals,放在Journals文件夹。使用org-roam的capture来生成每天的journal文件,以2024-01-01.org的文件格式命名。并实现在journal.org文件里,点击链接跳转到当日日志。
最开始是不打算用org-agenda的,因为没有太多TODO要去管理。用#TODO
来标注TODO搜索也并不麻烦。但是考虑到时间久了,agenda也可以通过标注时间戳来回顾非TODO项,还是启用了。和org-roam配合,可以很清晰的回顾一个星期内重要的笔记。以后需要清除掉这些时间戳也很方便,一个正则搞定。
之前考虑到和其他笔记软件通用的问题,journal全部以单独的文件按照年份生成,现在改为集中在一个journal.org
文件里。要不然以后org-agenda每次要扫描几年的journal文档会很头疼,现在改为每年一个单独的20xx-journal.org
文件。
原来的journal模板和org-capture模板也更新了:
(after! org
(org-link-set-parameters "zotero" :follow
(lambda (zpath)
(browse-url
;; we get the "zotero:"-less url, so we put it back.
(format "zotero:%s" zpath))))
(setq org-agenda-files '("~/Vandee/pkm/org/Journal.org"))
;; (setq org-agenda-include-diary t)
;; (setq org-agenda-diary-file "~/Vandee/pkm/org/Journal.org")
(setq org-directory "~/Vandee/pkm/org/")
(global-set-key (kbd "C-c c") 'org-capture)
;;(setq org-default-notes-file "~/Vandee/pkm/inbox.org")
(setq org-capture-templates nil)
;; (add-to-list 'org-capture-templates
;; '("j" "Journal" entry (file+datetree "~/Vandee/pkm/Journals/Journal.org")
;; "* [[file:%<%Y>/%<%Y-%m-%d>.org][%<%Y-%m-%d>]] - %^{heading} %^g\n %?\n"))
(add-to-list 'org-capture-templates
'("j" "Journal" entry (file+datetree "~/Vandee/pkm/org/Journal.org")
"* TODOs\n* Inbox\n- %?"))
(add-to-list 'org-capture-templates
'("i" "Inbox" entry (file+datetree "~/Vandee/pkm/Inbox.org")
"* %U - %^{heading} %^g\n %?\n"))
(defun my-org-goto-last-todo-headline ()
"Move point to the last headline in file matching \"* Notes\"."
(end-of-buffer)
(re-search-backward "\\* TODOs"))
(add-to-list 'org-capture-templates
'("t" "Task" entry (file+function "~/Vandee/pkm/org/Journal.org"
my-org-goto-last-todo-headline)
"* TODO %i%? \n%T"))
;; (add-to-list 'org-capture-templates
;; '("t" "Task" entry (file+datetree "~/Vandee/pkm/Task.org")
;; "* TODO %^{任务名}\n%T\n%a\n"))
(add-to-list 'org-capture-templates '("c" "Collections"))
(add-to-list 'org-capture-templates
'("cw" "Web Collections" item
(file+headline "~/Vandee/pkm/org/websites.org" "实用")
"%?"))
(add-to-list 'org-capture-templates
'("ct" "Tool Collections" item
(file+headline "~/Vandee/pkm/org/tools.org" "实用")
"%?"))
(defun my-tags-view ()
"Show all headlines for org files matching a TAGS criterion."
(interactive)
(let* ((org-agenda-files '("~/Vandee/pkm"))
(org-tags-match-list-sublevels nil))
(call-interactively 'org-tags-view)))
)
templates old
-
org-capture
(add-to-list 'org-capture-templates '("j" "Journal" entry (file+datetree "~/Vandee/pkm/Journals/journal.org") "* [[file:%<%Y-%m-%d>.org][%<%Y-%m-%d>]] - %^{heading} %^g\n %?\n"))
-
org-roam
:custom (org-roam-dailies-capture-templates '(("d" "default" plain "* %<%Y-%m-%d>\n** TODO\n- \n** Inbox\n- %?" :if-new (file+head "%<%Y-%m-%d>.org" "#+title: ${title}\n"))))
Org-capture
结合了org-agenda之后,现在的capture分为这几个部分,Journal、web、tool、clip。用来快速记录。



配置见Journals部分。
Org-roam
templates
:custom
(org-roam-dailies-capture-templates
'(("d" "default" plain "* %<%Y-%m-%d>\n** TODO\n- \n** Inbox\n- %?"
:if-new (file+head "%<%Y-%m-%d>.org" "#+title: ${title}\n"))))
(org-roam-directory "~/Vandee/pkm/roam/")
(org-roam-capture-templates
`(("d" "default" plain "%?"
:if-new (file+head "${slug}.org"
"${title}\n#+UID: %<%Y%m%d%H%M%S>\n#+filetags: \n#+type: \n#+date: %<%Y-%m-%d>\n")
:unnarrowed t))
)
Org exporting
单独导出,Org-mode里就可以,也可以使用这些工具 。批量导出,由于每个人的排版和格式习惯不同,还是自己用自己熟悉的语言,写几个正则,搞个脚本。
;; 替换markdown的链接和标题格式到org-mode的格式,当前buffer。
(defun my-markdown-to-org ()
(interactive)
(save-excursion
(goto-char (point-min))
(while (re-search-forward "^# \\(.*\\)" nil t)
(replace-match "* \\1"))
(goto-char (point-min))
(while (re-search-forward "^## \\(.*\\)" nil t)
(replace-match "** \\1"))
(goto-char (point-min))
(while (re-search-forward "^### \\(.*\\)" nil t)
(replace-match "*** \\1"))
(goto-char (point-min))
(while (re-search-forward "^#### \\(.*\\)" nil t)
(replace-match "**** \\1"))
(goto-char (point-min))
(while (re-search-forward "^##### \\(.*\\)" nil t)
(replace-match "***** \\1"))
(goto-char (point-min))
(while (re-search-forward "^###### \\(.*\\)" nil t)
(replace-match "****** \\1"))
(goto-char (point-min))
(while (re-search-forward "\\[\\(.*?\\)\\](\\(.*?\\))" nil t)
(replace-match "[[\\2][\\1]]"))))
-
Markdown to org-mode:
Pandoc转换md到org会有小问题,批量转换还是悠着点。
一个改善 Markdown to Org 转换的 Pandoc Filter 脚本 - Org-mode - Emacs China
How to migrate Markdown files to Emacs org mode format - Emacs Stack Exchange
Ref:Exporting (The Org Manual)、工具 | Org mode
Org with Zotero
书和论文的PDF文件,我现在全部放在Zotero。快速复制单个笔记到org-mode也挺简单:
通过下载这个文件到 zotero 资料目录下的 translators 文件下,将其命名为 Zotero Select Item.js
,重启 Zotero 后在编辑→ 首选项中配置便捷复制的 Item Format 为 Zotero Select Item:
这样就可以自定义复制粘贴过去的格式了。
{
"translatorID":"76a79119-3a32-453a-a0a9-c92640e3c93b",
"translatorType":2,
"label":"Zotero Select Item",
"creator":"Scott Campbell, Avram Lyon",
"target":"html",
"minVersion":"2.0",
"maxVersion":"",
"priority":200,
"inRepository":false,
"lastUpdated":"2012-07-17 22:27:00"
}
function doExport() {
var item;
while(item = Zotero.nextItem()) {
Zotero.write("zotero://select/items/");
var library_id = item.libraryID ? item.libraryID : 0;
Zotero.write(library_id+"_"+item.key);
}
}
然后在Emacs的配置文件里加上:
(org-link-set-parameters "zotero" :follow
(lambda (zpath)
(browse-url
;; we get the "zotero:"-less url, so we put it back.
(format "zotero:%s" zpath))))
Ref:
- https://hsingko.pages.dev/post/2022/07/04/zotero-and-orgmode/
- https://www.mkbehr.com/posts/a-research-workflow-with-zotero-and-org-mode/
Org-mode美化
我觉得原生的就挺好看,可读性也还好。
;; 设置标题大小
(after! org
(custom-set-faces!
'(outline-1 :weight extra-bold :height 1.25)
'(outline-2 :weight bold :height 1.15)
'(outline-3 :weight bold :height 1.12)
'(outline-4 :weight semi-bold :height 1.09)
'(outline-5 :weight semi-bold :height 1.06)
'(outline-6 :weight semi-bold :height 1.03)
'(outline-8 :weight semi-bold)
'(outline-9 :weight semi-bold))
(custom-set-faces!
'(org-document-title :height 1.2)))
;;字体,设置正文大小
(setq doom-font (font-spec :family "霞鹜文楷等宽" :weight 'regular :size 14))
;; 设置行内make up,直接显示*粗体*,/斜体/,=高亮=,~代码~
(setq org-hide-emphasis-markers t)
;; 盘古,中英文混合排版美化
;;https://github.com/coldnew/pangu-spacing
(use-package pangu-spacing)
(add-hook 'org-mode-hook
'(lambda ()
(set (make-local-variable 'pangu-spacing-real-insert-separtor) t)))
Org-protocol
求助: 在网页剪藏时用org-capture模板生成独立文件名 - Org-mode - Emacs China
用org-mode做网页书签的可以进来看一下 - Org-mode - Emacs China
什么样才是正确的org-protocol姿势 - Org-mode - Emacs China
Org-roam User Manual-org-protocol
denote
https://github.com/protesilaos/denote
提供类似org-roam的双链,快速插入等功能
ekg
https://emacs-china.org/t/ekg-flomo/27505/12
提供一个类似obsidian里dataview的查询汇总功能