在 emacs org 文件中将 CATEGORY 转换为 PROPERTY 的最佳方法
在 org 文件中将 CATEGORY 转换为 PROPERTY 的最佳方法是什么?
#+CATEGORY: NETWORKING
我使用
:PROPERTIES:
:CATEGORY: NETWORKING
:END:
以下 elisp 代码来执行此操作。
(let ((buf_name "home.org") (current_line 0) (current_string ""))
(set-buffer buf_name)
(goto-char (point-min))
(while (re-search-forward "#\\+CATEGORY: \\(.*$\\)" nil t)
(replace-match ":PROPERTIES:\n:CATEGORY: \\1\n:END:")))
有没有更好的方法。
编辑:- 正则表达式
"#\\+CATEGORY: \\(\\w+\\)"
已被修改为,
"#\\+CATEGORY: \\(.*$\\)"
因为我有一个“C++”类别,它不被识别为单词,只有“C++”中的“C”被识别为单词。
What is the best method to convert CATEGORY to PROPERTY in a org file.
#+CATEGORY: NETWORKING
to
:PROPERTIES:
:CATEGORY: NETWORKING
:END:
I have used the following elisp code to do this.
(let ((buf_name "home.org") (current_line 0) (current_string ""))
(set-buffer buf_name)
(goto-char (point-min))
(while (re-search-forward "#\\+CATEGORY: \\(.*$\\)" nil t)
(replace-match ":PROPERTIES:\n:CATEGORY: \\1\n:END:")))
Is there a better method.
EDIT:- the regular expression
"#\\+CATEGORY: \\(\\w+\\)"
has been modified to
"#\\+CATEGORY: \\(.*$\\)"
since i had a "C++" CATEGORY which is not recognized as a word, only the "C" in "C++" is recognized as a word.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你可以使用这个:
但这只是风格上的改变,概念上没有更好的方法。
此外:属性抽屉和类别并不等效:第二个扩展直到文件末尾,第一个仅在当前子树内。
因此,您很可能必须随后手动编辑它。
You can use this:
But it's only a stylistic change, there is no conceptually better way.
Furthermore: property drawers and category are not equivalent: The second expand until the end of the file, the first only inside the current subtree.
So you most probably have to edit it manually afterwards.
试试这个:
上面的代码获取文件类别,删除已弃用的行,然后将每个顶级标题的 CATEGORY 属性设置为旧文件类别。
编辑:编辑代码以适应乔纳森指出的情况
Try this:
The above code gets the file category, removes the deprecated line, and then sets the CATEGORY property of each top level headline to the old file category.
Edit: Edited the code to accommodate the case pointed out by Jonathan