Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Organizing notes with tags in org-mode

Tags:

emacs

org-mode

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?

like image 389
Shitikanth Avatar asked May 24 '12 00:05

Shitikanth


People also ask

How do you use tags in Org mode?

Org mode has extensive support for tags. Every headline can contain a list of tags; they occur at the end of the headline. Tags are normal words containing letters, numbers, ' _ ', and ' @ '. Tags must be preceded and followed by a single colon, e.g., ' :work: '.

Is org mode useful?

Org mode is routinely used to build and manage complex workflows. It does this using an elegantly simple syntax that scales from basic markup to full LaTeX typesetting and from plain text notes to literate programs. Everything you need to get started is demonstrated in the example.

How do you create an org file?

To start a new document, use the following short-cut: C-x C-f, which will offer you to open a document (or buffer as it is called in Emacs), call it 1.org. This will give you a brand-new, empty document. To save the document, either press the save icon, or press C-x C-s, call it 1.org.

How do I take notes in Emacs?

When you first create a new file, a capture screen appears where you can write your note. To save the note to your system, press C-c C-c , to cancel creating a new note, press C-c C-k .


1 Answers

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))
like image 109
Jonathan Leech-Pepin Avatar answered Oct 10 '22 22:10

Jonathan Leech-Pepin