Bladeren bron

Restore completion over the most important keywords

* org-pcomplete.el (pcomplete/org-mode/file-option/x):
Resurrect.  Use `org-default-options' to initialize completion
fonctions for the most important keywords.

* org-macs.el (org-default-options): Rename and adapt from
`org-get-current-options'.

This is a partial revert of e14cf780 feature-wise.  The idea is
that it may be useful to get completion, even when it ends up with
the default value, because the user may want to adapt the default
values instead of re-typing them.
Bastien Guerry 12 jaren geleden
bovenliggende
commit
03f1cffcd5
2 gewijzigde bestanden met toevoegingen van 50 en 0 verwijderingen
  1. 30 0
      lisp/org-macs.el
  2. 20 0
      lisp/org-pcomplete.el

+ 30 - 0
lisp/org-macs.el

@@ -398,6 +398,36 @@ the value in cdr."
     (cons (list (car flat) (cadr flat))
 	  (org-make-parameter-alist (cddr flat)))))
 
+(defun org-default-options ()
+  "Return a string with default options as keyword options."
+  (format
+   "#+TITLE:     %s
+#+AUTHOR:    %s
+#+EMAIL:     %s
+#+DATE:      %s
+#+LANGUAGE:  %s
+#+EXPORT_SELECT_TAGS: %s
+#+EXPORT_EXCLUDE_TAGS: %s
+#+PRIORITIES: %c %c %c
+#+TAGS:      %s
+#+FILETAGS:  %s
+"
+   (buffer-name) (user-full-name) user-mail-address
+   (format-time-string (substring (car org-time-stamp-formats) 1 -1))
+   org-export-default-language
+   (mapconcat 'identity org-export-select-tags " ")
+   (mapconcat 'identity org-export-exclude-tags " ")
+   org-highest-priority org-lowest-priority org-default-priority
+   (or (mapconcat (lambda (x)
+		    (cond
+		     ((equal :startgroup (car x)) "{")
+		     ((equal :endgroup (car x)) "}")
+		     ((equal :newline (car x)) "")
+		     ((cdr x) (format "%s(%c)" (car x) (cdr x)))
+		     (t (car x))))
+		  (or org-tag-alist (org-get-buffer-tags)) " ") "")
+   (mapconcat 'identity org-file-tags " ")))
+
 ;;;###autoload
 (defmacro org-load-noerror-mustsuffix (file)
   "Load FILE with optional arguments NOERROR and MUSTSUFFIX.  Drop the MUSTSUFFIX argument for XEmacs, which doesn't recognize it."

+ 20 - 0
lisp/org-pcomplete.el

@@ -178,6 +178,26 @@ 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"
+	"EXPORT_SELECT_TAGS" "EXPORT_EXCLUDE_TAGS" "PRIORITIES"))
+
 (defun pcomplete/org-mode/file-option/options ()
   "Complete arguments for the #+OPTIONS file option."
   (while (pcomplete-here