Organizing notes with tags in org-mode

别来无恙 提交于 2019-12-20 09:50:53

问题


So, I use org-mode extensively for my daily TODO requirements. I am wondering if I can also use it effectively for note keeping. What I basically want is to store notes with tags, and then want to search these notes by the tags. E.g. If I have something like this

* Heading 1
** Note 1 :tag1:tag2:
Note 1 details
** Note 2 :tag3:
Note 2 details
* Heading 2
** Note 3
** Note 4 :tag1:
Note 4 details

and then I search for tag1, I should have something like-

* Heading 1
** Note 1 :tag1:tag2:
Note 1 details
* Heading 2
** Note 4 :tag1:
Note 4 details

I would prefer being able to do this without adding the files to my agenda. (I may have several of these notes, and I would only want to search the current file at a time.)

Is there an easy (or not so easy) way to accomplish this org-mode?


回答1:


The following function should provide the result you want.

(defun zin/org-tag-match-context (&optional todo-only match)
  "Identical search to `org-match-sparse-tree', but shows the content of the matches."
  (interactive "P")
  (org-prepare-agenda-buffers (list (current-buffer)))
  (org-overview) 
  (org-remove-occur-highlights) 
  (org-scan-tags '(progn (org-show-entry) 
                         (org-show-context)) 
                 (cdr (org-make-tags-matcher match)) todo-only))



回答2:


You can use a tag search (C-c / m tag1 <ret>). Documentation here:

http://orgmode.org/manual/Tag-searches.html

This will create a sparse tree showing only the headings containing :tag1:, but it will not automatically reveal the contents of that heading as in your example.



来源:https://stackoverflow.com/questions/10729639/organizing-notes-with-tags-in-org-mode

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!