summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Guerry <bzg@altern.org>2012-01-25 10:01:39 +0100
committerBastien Guerry <bzg@altern.org>2012-01-25 10:01:39 +0100
commit1742683e4fc81c269ed0e9346ebb163cd456a818 (patch)
tree4f8b741e561d8a67c6b4a9b5ce94257f75e8832f
parentd1e58716dd4c325eef192c12fb0068e5ff4eb8b2 (diff)
downloadorg-mode-1742683e4fc81c269ed0e9346ebb163cd456a818.tar.gz
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.
-rw-r--r--lisp/org-pcomplete.el27
1 files changed, 26 insertions, 1 deletions
diff --git a/lisp/org-pcomplete.el b/lisp/org-pcomplete.el
index 0ca8777..c475bcc 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."