emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] How do I create a drawer?


From: Olaf Dietsche
Subject: Re: [O] How do I create a drawer?
Date: Wed, 25 Jan 2012 09:29:53 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

Nick Dokos <address@hidden> writes:

> The only way I found so far to create a drawer is to actually type the
> damn thing in (I'm talking about my own drawers, not the special
> drawers that org knows something about). I didn't find any utility
> functions to insert drawers (except for :PROPERTIES:), and somewhat to
> my surprise, completion does not seem to work for drawer names: I
> expected typing a colon and M-TAB would allow me to use drawer names for
> completion, but it seems to only care about property keys, even if I'm
> not in the context of a :PROPERTIES: drawer. Am I missing something?

For a quick hack, you might try this one:

diff --git a/lisp/org.el b/lisp/org.el
index 7163e8f..129e08c 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -14397,6 +14397,11 @@ formats in the current buffer."
 (defun org-insert-property-drawer ()
   "Insert a property drawer into the current entry."
   (interactive)
+  (org-insert-drawer "PROPERTIES"))
+
+(defun org-insert-drawer (drawer)
+  "Insert a drawer into the current entry."
+  (interactive "sDrawer: ")
   (org-back-to-heading t)
   (looking-at org-outline-regexp)
   (let ((indent (if org-adapt-indentation
@@ -14422,7 +14427,7 @@ formats in the current buffer."
     (org-skip-over-state-notes)
     (skip-chars-backward " \t\n\r")
     (if (eq (char-before) ?*) (forward-char 1))
-    (let ((inhibit-read-only t)) (insert "\n:PROPERTIES:\n:END:"))
+    (let ((inhibit-read-only t)) (insert "\n:" drawer ":\n:END:"))
     (beginning-of-line 0)
     (org-indent-to-column indent)
     (beginning-of-line 2)

With M-x org-insert-drawer RET drawer-name RET inserts your own
drawer. It doesn't support completion though.

Regards, Olaf



reply via email to

[Prev in Thread] Current Thread [Next in Thread]