From 1742683e4fc81c269ed0e9346ebb163cd456a818 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Wed, 25 Jan 2012 10:01:39 +0100 Subject: [PATCH] Let pcomplete handle drawers. * org-pcomplete.el (pcomplete/org-mode/drawer): New function to complete drawer at point. (org-thing-at-point): Use it. Thanks to Nick Dokos for a request in this area. --- lisp/org-pcomplete.el | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/lisp/org-pcomplete.el b/lisp/org-pcomplete.el index 0ca877787..c475bcc4f 100644 --- a/lisp/org-pcomplete.el +++ b/lisp/org-pcomplete.el @@ -84,8 +84,16 @@ The return value is a string naming the thing at point." (equal (char-after (point-at-bol)) ?*)) (cons "tag" nil)) ((and (equal (char-before beg1) ?:) - (not (equal (char-after (point-at-bol)) ?*))) + (not (equal (char-after (point-at-bol)) ?*)) + (save-excursion + (move-beginning-of-line 1) + (skip-chars-backward "[ \t\n]") + (or (looking-back org-drawer-regexp) + (looking-back org-property-re)))) (cons "prop" nil)) + ((and (equal (char-before beg1) ?:) + (not (equal (char-after (point-at-bol)) ?*))) + (cons "drawer" nil)) (t nil)))) (defun org-command-at-point () @@ -239,6 +247,23 @@ This needs more work, to handle headings with lots of spaces in them." lst)) (substring pcomplete-stub 1))) +(defun pcomplete/org-mode/drawer () + "Complete a drawer name." + (let ((spc (save-excursion + (move-beginning-of-line 1) + (looking-at "^\\([ \t]*\\):") + (match-string 1))) + (cpllist (mapcar (lambda (x) (concat x ": ")) org-drawers))) + (pcomplete-here cpllist + (substring pcomplete-stub 1) + (unless (or (not (delete + nil + (mapcar (lambda(x) + (string-match (substring pcomplete-stub 1) x)) + cpllist))) + (looking-at "[ \t]*\n.*:END:")) + (save-excursion (insert "\n" spc ":END:")))))) + (defun pcomplete/org-mode/block-option/src () "Complete the arguments of a begin_src block. Complete a language in the first field, the header arguments and switches." -- 2.11.4.GIT