2012-05-24 63 views
13

因此,我廣泛使用組織模式來處理我的日常TODO需求。我想知道我是否也可以有效地使用它來保存筆記。我基本想要的是用標籤存儲筆記,然後想要通過標籤搜索這些筆記。例如。如果我有這樣的事情用組織筆記標記在組織筆記

* 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 

,然後我搜索標籤1,我應該有一些喜歡 -

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

我寧願能做到不添加文件到我的議事日程。 (我可能有幾個這些筆記,我只想要一次搜索當前文件。)

是否有一種簡單(或不那麼容易)的方式來完成此組織模式?

回答

8

下面的函數應該提供你想要的結果。

(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)) 
+0

太棒了!那正是我期待的! – Shitikanth

+0

我想這樣做!我該怎麼做呢?我將代碼段複製並粘貼到我的'.emacs'文件中。開始一個新的Emacs會話。打開一個* .org文件。標記標題(帶有「C-c C-q」)。然後什麼?如何檢索具有特定標籤的所有列表項目? – Chernoff

+0

請注意'org-prepare-agenda-buffers'已被重命名爲'org-agenda-prepare-buffers'。 @Chernoff如果你仍然希望這樣做,那麼你可以c&p,替換舊的函數名稱,並用'M-x zin/org-tag-match-context'來調用它 –

8

您可以使用標籤搜索(C-c/m tag1 <ret>)。文檔瀏覽:

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

這將創建一個稀疏的樹僅顯示包含:tag1:的標題,但它不會自動顯示該標題的內容,在您的示例。

+1

謝謝,這有助於很多。你有沒有想過如何去試圖擴大標題呢?我不介意做一些編程來完成工作。 – Shitikanth