Browse Source

org-pcomplete.el: Allow completion over #+OPTIONS, #+TITLE, #+AUTHOR, #+EMAIL and #+DATE.

* org-pcomplete.el (pcomplete/org-mode/file-option/x): New macro.
(pcomplete/org-mode/file-option/options)
(pcomplete/org-mode/file-option/title)
(pcomplete/org-mode/file-option/author)
(pcomplete/org-mode/file-option/email)
(pcomplete/org-mode/file-option/date): Use the new macro to
offer completion over default values for #+OPTIONS, #+TITLE,
#+AUTHOR, #+EMAIL and #+DATE.
Bastien Guerry 12 years ago
parent
commit
da8215bc06
1 changed files with 32 additions and 1 deletions
  1. 32 1
      lisp/org-pcomplete.el

+ 32 - 1
lisp/org-pcomplete.el

@@ -132,7 +132,6 @@ When completing for #+STARTUP, for example, this function returns
 			   args)))
 	(cons (reverse args) (reverse begins))))))
 
-
 (defun org-pcomplete-initial ()
   "Calls the right completion function for first argument completions."
   (ignore
@@ -168,6 +167,38 @@ When completing for #+STARTUP, for example, this function returns
 		(setq opts (delete "showstars" opts)))))
 	    opts))))
 
+(defmacro pcomplete/org-mode/file-option/x (option)
+  "Complete arguments for OPTION."
+  `(while
+       (pcomplete-here
+	(pcomplete-uniqify-list
+	 (delq nil
+	       (mapcar (lambda(o)
+			 (when (string-match (concat "^[ \t]*#\\+"
+						     ,option ":[ \t]+\\(.*\\)[ \t]*$") o)
+			   (match-string 1 o)))
+		       (split-string (org-get-current-options) "\n")))))))
+
+(defun pcomplete/org-mode/file-option/options ()
+  "Complete arguments for the #+OPTIONS file option."
+  (pcomplete/org-mode/file-option/x "OPTIONS"))
+
+(defun pcomplete/org-mode/file-option/title ()
+ "Complete arguments for the #+TITLE file option."
+  (pcomplete/org-mode/file-option/x "TITLE"))
+
+(defun pcomplete/org-mode/file-option/author ()
+ "Complete arguments for the #+AUTHOR file option."
+  (pcomplete/org-mode/file-option/x "AUTHOR"))
+
+(defun pcomplete/org-mode/file-option/email ()
+ "Complete arguments for the #+EMAIL file option."
+  (pcomplete/org-mode/file-option/x "EMAIL"))
+
+(defun pcomplete/org-mode/file-option/date ()
+ "Complete arguments for the #+DATE file option."
+  (pcomplete/org-mode/file-option/x "DATE"))
+
 (defun pcomplete/org-mode/file-option/bind ()
   "Complete arguments for the #+BIND file option, which are variable names."
   (let (vars)