|
@@ -108,11 +108,11 @@ When completing for #+STARTUP, for example, this function returns
|
|
|
(let ((thing (org-thing-at-point)))
|
|
|
(cond
|
|
|
((string= "file-option" (car thing))
|
|
|
- (concat (car thing) "/" (downcase (cdr thing))))
|
|
|
+ (concat (car thing)
|
|
|
+ (and (cdr thing) (concat "/" (downcase (cdr thing))))))
|
|
|
((string= "block-option" (car thing))
|
|
|
(concat (car thing) "/" (downcase (cdr thing))))
|
|
|
- (t
|
|
|
- (car thing)))))
|
|
|
+ (t (car thing)))))
|
|
|
|
|
|
(defun org-parse-arguments ()
|
|
|
"Parse whitespace separated arguments in the current region."
|
|
@@ -147,23 +147,73 @@ When completing for #+STARTUP, for example, this function returns
|
|
|
"Complete against all valid file options."
|
|
|
(pcomplete-here
|
|
|
(org-pcomplete-case-double
|
|
|
- (mapcar (lambda (x)
|
|
|
- (if (= ?: (aref x (1- (length x))))
|
|
|
- (concat x " ")
|
|
|
- x))
|
|
|
- (append org-options-keywords
|
|
|
- org-element-affiliated-keywords
|
|
|
- (let (block-names)
|
|
|
- (mapc (lambda (block-name)
|
|
|
- (let ((name (car block-name)))
|
|
|
- (push (concat "END_" name) block-names)
|
|
|
- (push (concat "BEGIN_" name) block-names)))
|
|
|
- org-element-block-name-alist)
|
|
|
- block-names)
|
|
|
- (mapcar (lambda (keyword) (concat keyword ":"))
|
|
|
- (org-get-export-keywords)))))
|
|
|
+ (append (mapcar (lambda (keyword) (concat keyword " "))
|
|
|
+ org-options-keywords)
|
|
|
+ (mapcar (lambda (keyword) (concat keyword ": "))
|
|
|
+ org-element-affiliated-keywords)
|
|
|
+ (let (block-names)
|
|
|
+ (mapc (lambda (block-name)
|
|
|
+ (let ((name (car block-name)))
|
|
|
+ (push (format "END_%s: " name) block-names)
|
|
|
+ (push (format "BEGIN_%s: " name) block-names)))
|
|
|
+ org-element-block-name-alist)
|
|
|
+ block-names)
|
|
|
+ (mapcar (lambda (keyword) (concat keyword ": "))
|
|
|
+ (org-get-export-keywords))))
|
|
|
(substring pcomplete-stub 2)))
|
|
|
|
|
|
+(defun pcomplete/org-mode/file-option/author ()
|
|
|
+ "Complete arguments for the #+AUTHOR file option."
|
|
|
+ (pcomplete-here (list user-full-name)))
|
|
|
+
|
|
|
+(defvar org-time-stamp-formats)
|
|
|
+(defun pcomplete/org-mode/file-option/date ()
|
|
|
+ "Complete arguments for the #+DATE file option."
|
|
|
+ (pcomplete-here (list (format-time-string (car org-time-stamp-formats)))))
|
|
|
+
|
|
|
+(defun pcomplete/org-mode/file-option/email ()
|
|
|
+ "Complete arguments for the #+EMAIL file option."
|
|
|
+ (pcomplete-here (list user-mail-address)))
|
|
|
+
|
|
|
+(defvar org-export-exclude-tags)
|
|
|
+(defun pcomplete/org-mode/file-option/exclude_tags ()
|
|
|
+ "Complete arguments for the #+EXCLUDE_TAGS file option."
|
|
|
+ (require 'ox)
|
|
|
+ (pcomplete-here
|
|
|
+ (and org-export-exclude-tags
|
|
|
+ (list (mapconcat 'identity org-export-exclude-tags " ")))))
|
|
|
+
|
|
|
+(defvar org-file-tags)
|
|
|
+(defun pcomplete/org-mode/file-option/filetags ()
|
|
|
+ "Complete arguments for the #+FILETAGS file option."
|
|
|
+ (pcomplete-here (and org-file-tags (mapconcat 'identity org-file-tags " "))))
|
|
|
+
|
|
|
+(defvar org-export-default-language)
|
|
|
+(defun pcomplete/org-mode/file-option/language ()
|
|
|
+ "Complete arguments for the #+LANGUAGE file option."
|
|
|
+ (require 'ox)
|
|
|
+ (pcomplete-here
|
|
|
+ (pcomplete-uniqify-list
|
|
|
+ (list org-export-default-language "en"))))
|
|
|
+
|
|
|
+(defvar org-default-priority)
|
|
|
+(defvar org-highest-priority)
|
|
|
+(defvar org-lowest-priority)
|
|
|
+(defun pcomplete/org-mode/file-option/priorities ()
|
|
|
+ "Complete arguments for the #+PRIORITIES file option."
|
|
|
+ (pcomplete-here (list (format "%c %c %c"
|
|
|
+ org-highest-priority
|
|
|
+ org-lowest-priority
|
|
|
+ org-default-priority))))
|
|
|
+
|
|
|
+(defvar org-export-select-tags)
|
|
|
+(defun pcomplete/org-mode/file-option/select_tags ()
|
|
|
+ "Complete arguments for the #+SELECT_TAGS file option."
|
|
|
+ (require 'ox)
|
|
|
+ (pcomplete-here
|
|
|
+ (and org-export-select-tags
|
|
|
+ (list (mapconcat 'identity org-export-select-tags " ")))))
|
|
|
+
|
|
|
(defvar org-startup-options)
|
|
|
(defun pcomplete/org-mode/file-option/startup ()
|
|
|
"Complete arguments for the #+STARTUP file option."
|
|
@@ -178,25 +228,28 @@ 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-default-options) "\n")))))))
|
|
|
-
|
|
|
-(mapc (lambda (o)
|
|
|
- (eval `(defun
|
|
|
- ,(intern (concat "pcomplete/org-mode/file-option/" (downcase o))) ()
|
|
|
- ,(format "Complete #+%s option." o)
|
|
|
- (pcomplete/org-mode/file-option/x ,o))))
|
|
|
- '("TITLE" "AUTHOR" "EMAIL" "DATE" "LANGUAGE" "TAGS" "FILETAGS"
|
|
|
- "SELECT_TAGS" "EXCLUDE_TAGS" "PRIORITIES"))
|
|
|
+(defvar org-tag-alist)
|
|
|
+(defun pcomplete/org-mode/file-option/tags ()
|
|
|
+ "Complete arguments for the #+TAGS file option."
|
|
|
+ (pcomplete-here
|
|
|
+ (list
|
|
|
+ (mapconcat (lambda (x)
|
|
|
+ (cond
|
|
|
+ ((eq :startgroup (car x)) "{")
|
|
|
+ ((eq :endgroup (car x)) "}")
|
|
|
+ ((eq :newline (car x)) "\\n")
|
|
|
+ ((cdr x) (format "%s(%c)" (car x) (cdr x)))
|
|
|
+ (t (car x))))
|
|
|
+ org-tag-alist " "))))
|
|
|
+
|
|
|
+(defun pcomplete/org-mode/file-option/title ()
|
|
|
+ "Complete arguments for the #+TITLE file option."
|
|
|
+ (pcomplete-here
|
|
|
+ (let ((visited-file (buffer-file-name (buffer-base-buffer))))
|
|
|
+ (list (or (and visited-file
|
|
|
+ (file-name-sans-extension
|
|
|
+ (file-name-nondirectory visited-file)))
|
|
|
+ (buffer-name (buffer-base-buffer)))))))
|
|
|
|
|
|
(defun pcomplete/org-mode/file-option/options ()
|
|
|
"Complete arguments for the #+OPTIONS file option."
|