Allow using ido-completion all around Org.

If you set the variable `org-completion-use-ido' to t, and if you have
ido-mode turned on, most instanced of completion in Org-mode will use
ido-complete.

Thanks to Samuel Wales and Eric Schulte for patches to this effect.
This commit is contained in:
Carsten Dominik 2008-11-17 07:52:07 +01:00
parent c210ba6d90
commit f926b09e0d
8 changed files with 70 additions and 29 deletions

View File

@ -1,8 +1,35 @@
2008-11-17 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-sort-entries-or-items, org-completing-read)
(org-refile-get-location, org-olpath-completing-read, org-todo)
(org-show-todo-tree, org-sparse-tree, org-make-tags-matcher)
(org-set-tags, org-change-tag-in-region, org-fast-tag-selection)
(org-set-property, org-delete-property)
(org-delete-property-globally): Use `org-ido-completing-read'.
* org-remember.el (org-remember-apply-template): Use
`org-ido-completing-read'.
* org-publish.el (org-publish): Use `org-ido-completing-read'.
* org-colview.el (org-columns-edit-value, org-columns-new)
(org-insert-columns-dblock): Use `org-ido-completing-read'.
* org-colview-xemacs.el (org-columns-edit-value)
(org-columns-new, org-insert-columns-dblock): Use
`org-ido-completing-read'.
* org-attach.el (org-attach-delete-one, org-attach-open): Use
`org-ido-completing-read'.
* org-agenda.el (org-todo-list, org-agenda-filter-by-tag): Use
`org-ido-completing-read'.
* org.el (org-time-today): New function.
(org-matcher-time): Use `org-time-today'. Add special treatment
for "<tomorrow>" and "<yesterday>".
(org-ido-completing-read): New function.
(org-completion-use-ido): New option.
* org-exp.el (org-export-format-source-code): Fix bug in require
htmlize code.

View File

@ -2736,7 +2736,7 @@ for a keyword. A numeric prefix directly selects the Nth keyword in
rtn rtnall files file pos)
(when (equal arg '(4))
(setq org-select-this-todo-keyword
(completing-read "Keyword (or KWD1|K2D2|...): "
(org-ido-completing-read "Keyword (or KWD1|K2D2|...): "
(mapcar 'list kwds) nil nil)))
(and (equal 0 arg) (setq org-select-this-todo-keyword nil))
(org-set-local 'org-last-arg arg)
@ -4271,7 +4271,7 @@ to switch to narrowing."
(org-set-local 'org-global-tags-completion-table
(org-global-tags-completion-table)))
(let ((completion-ignore-case t))
(setq tag (completing-read
(setq tag (org-ido-completing-read
"Tag: " org-global-tags-completion-table))))
(cond
((equal char ?/) (org-agenda-filter-by-tag-show-all))

View File

@ -245,7 +245,7 @@ The attachment is created as an Emacs buffer."
(let* ((attach-dir (org-attach-dir t))
(files (org-attach-file-list attach-dir))
(file (or file
(completing-read
(org-ido-completing-read
"Delete attachment: "
(mapcar (lambda (f)
(list (file-name-nondirectory f)))
@ -320,7 +320,7 @@ If IN-EMACS is non-nil, force opening in Emacs."
(files (org-attach-file-list attach-dir))
(file (if (= (length files) 1)
(car files)
(completing-read "Open attachment: "
(org-ido-completing-read "Open attachment: "
(mapcar 'list files) nil t))))
(org-open-file (expand-file-name file attach-dir) in-emacs)))

View File

@ -622,7 +622,7 @@ Where possible, use the standard interface for changing this line."
(t
(setq allowed (org-property-get-allowed-values pom key 'table))
(if allowed
(setq nval (completing-read "Value: " allowed nil t))
(setq nval (org-ido-completing-read "Value: " allowed nil t))
(setq nval (read-string "Edit: " value)))
(setq nval (org-trim nval))
(when (not (equal nval value))
@ -873,7 +873,7 @@ around it."
(let ((n (org-columns-current-column))
(editp (and prop (assoc prop org-columns-current-fmt-compiled)))
cell)
(setq prop (completing-read
(setq prop (org-ido-completing-read
"Property: " (mapcar 'list (org-buffer-property-keys t nil t))
nil nil prop))
(setq title (read-string (concat "Column title [" prop "]: ") (or title prop)))
@ -881,7 +881,7 @@ around it."
(if (string-match "\\S-" width)
(setq width (string-to-number width))
(setq width nil))
(setq fmt (completing-read "Summary [none]: "
(setq fmt (org-ido-completing-read "Summary [none]: "
'(("none") ("add_numbers") ("currency") ("add_times") ("checkbox") ("checkbox-n-of-m") ("checkbox-percent"))
nil t))
(if (string-match "\\S-" fmt)
@ -1372,7 +1372,7 @@ and tailing newline characters."
(interactive)
(when (featurep 'xemacs) (org-columns-quit))
(let ((defaults '(:name "columnview" :hlines 1))
(id (completing-read
(id (org-ido-completing-read
"Capture columns (local, global, entry with :ID: property) [local]: "
(append '(("global") ("local"))
(mapcar 'list (org-property-values "ID"))))))

View File

@ -425,7 +425,7 @@ Where possible, use the standard interface for changing this line."
(t
(setq allowed (org-property-get-allowed-values pom key 'table))
(if allowed
(setq nval (completing-read "Value: " allowed nil t))
(setq nval (org-ido-completing-read "Value: " allowed nil t))
(setq nval (read-string "Edit: " value)))
(setq nval (org-trim nval))
(when (not (equal nval value))
@ -675,7 +675,7 @@ around it."
(interactive)
(let ((editp (and prop (assoc prop org-columns-current-fmt-compiled)))
cell)
(setq prop (completing-read
(setq prop (org-ido-completing-read
"Property: " (mapcar 'list (org-buffer-property-keys t nil t))
nil nil prop))
(setq title (read-string (concat "Column title [" prop "]: ") (or title prop)))
@ -683,7 +683,7 @@ around it."
(if (string-match "\\S-" width)
(setq width (string-to-number width))
(setq width nil))
(setq fmt (completing-read "Summary [none]: "
(setq fmt (org-ido-completing-read "Summary [none]: "
'(("none") ("add_numbers") ("currency") ("add_times") ("checkbox") ("checkbox-n-of-m") ("checkbox-percent"))
nil t))
(if (string-match "\\S-" fmt)
@ -1151,7 +1151,7 @@ and tailing newline characters."
"Create a dynamic block capturing a column view table."
(interactive)
(let ((defaults '(:name "columnview" :hlines 1))
(id (completing-read
(id (org-ido-completing-read
"Capture columns (local, global, entry with :ID: property) [local]: "
(append '(("global") ("local"))
(mapcar 'list (org-property-values "ID"))))))

View File

@ -703,7 +703,7 @@ Default for INDEX-FILENAME is 'index.org'."
(if force nil org-publish-use-timestamps-flag)))
(org-publish-projects
(list (or project
(assoc (completing-read
(assoc (org-ido-completing-read
"Publish project: "
org-publish-project-alist nil t)
org-publish-project-alist)))))))

View File

@ -474,7 +474,7 @@ to be run from that hook to function properly."
(org-global-tags-completion-table
(if (equal char "G") (org-agenda-files) (and file (list file)))))
(org-add-colon-after-tag-completion t)
(ins (completing-read
(ins (org-ido-completing-read
(if prompt (concat prompt ": ") "Tags: ")
'org-tags-completion-function nil nil nil
'org-tags-history)))

View File

@ -2335,6 +2335,11 @@ Use customize to modify this, or restart Emacs after changing it."
:tag "Org Completion"
:group 'org)
(defcustom org-completion-use-ido nil
"Non-ni means, use ido completion wherever possible."
:group 'org
:type 'boolean)
(defcustom org-completion-fallback-command 'hippie-expand
"The expansion command called by \\[org-complete] in normal context.
Normal means, no org-mode-specific context."
@ -5392,13 +5397,13 @@ WITH-CASE, the sorting considers case as well."
(and (= (downcase sorting-type) ?f)
(setq getkey-func
(completing-read "Sort using function: "
(org-ido-completing-read "Sort using function: "
obarray 'fboundp t nil nil))
(setq getkey-func (intern getkey-func)))
(and (= (downcase sorting-type) ?r)
(setq property
(completing-read "Property: "
(org-ido-completing-read "Property: "
(mapcar 'list (org-buffer-property-keys t))
nil t))))
@ -6560,6 +6565,15 @@ used as the link location instead of reading one interactively."
(let ((minibuffer-local-completion-map
(copy-keymap minibuffer-local-completion-map)))
(org-defkey minibuffer-local-completion-map " " 'self-insert-command)
(apply 'org-ido-completing-read args)))
(defun org-ido-completing-read (&rest args)
"Completing-read using `ido-mode' speedups if available"
(if (and org-completion-use-ido
(fboundp 'ido-completing-read)
(boundp 'ido-mode) ido-mode
(listp (second args)))
(apply 'ido-completing-read (concat "i:" (car args)) (cdr args))
(apply 'completing-read args)))
(defun org-extract-attributes (s)
@ -7484,7 +7498,7 @@ operation has put the subtree."
(let* ((cbuf (current-buffer))
(cfunc (if org-refile-use-outline-path
'org-olpath-completing-read
'completing-read))
'org-ido-completing-read))
(extra (if org-refile-use-outline-path "/" ""))
(filename (buffer-file-name (buffer-base-buffer cbuf)))
(fname (and filename (file-truename filename)))
@ -7504,7 +7518,7 @@ operation has put the subtree."
"Read an outline path like a file name."
(let ((thetable collection))
(apply
'completing-read prompt
'org-ido-completing-read prompt
(lambda (string predicate &optional flag)
(let (rtn r s f (l (length string)))
(cond
@ -7988,7 +8002,7 @@ For calling through lisp, arg is also interpreted in the following way:
(or (not org-use-fast-todo-selection)
(not org-todo-key-trigger)))
;; Read a state with completion
(completing-read "State: " (mapcar (lambda(x) (list x))
(org-ido-completing-read "State: " (mapcar (lambda(x) (list x))
org-todo-keywords-1)
nil t))
((eq arg 'right)
@ -8398,7 +8412,7 @@ of `org-todo-keywords-1'."
(kwd-re
(cond ((null arg) org-not-done-regexp)
((equal arg '(4))
(let ((kwd (completing-read "Keyword (or KWD1|KWD2|...): "
(let ((kwd (org-ido-completing-read "Keyword (or KWD1|KWD2|...): "
(mapcar 'list org-todo-keywords-1))))
(concat "\\("
(mapconcat 'identity (org-split-string kwd "|") "\\|")
@ -8710,9 +8724,9 @@ d Show deadlines due within `org-deadline-warning-days'."
((equal ans ?T)
(call-interactively 'org-tags-sparse-tree))
((member ans '(?p ?P))
(setq kwd (completing-read "Property: "
(setq kwd (org-ido-completing-read "Property: "
(mapcar 'list (org-buffer-property-keys))))
(setq value (completing-read "Value: "
(setq value (org-ido-completing-read "Value: "
(mapcar 'list (org-property-values kwd))))
(unless (string-match "\\`{.*}\\'" value)
(setq value (concat "\"" value "\"")))
@ -9108,7 +9122,7 @@ also TODO lines."
;; Get a new match request, with completion
(let ((org-last-tags-completion-table
(org-global-tags-completion-table)))
(setq match (completing-read
(setq match (org-ido-completing-read
"Match: " 'org-tags-completion-function nil nil nil
'org-tags-history))))
@ -9426,7 +9440,7 @@ With prefix ARG, realign all tags in headings in the current buffer."
(let ((org-add-colon-after-tag-completion t))
(org-trim
(org-without-partial-completion
(completing-read "Tags: " 'org-tags-completion-function
(org-ido-completing-read "Tags: " 'org-tags-completion-function
nil nil current 'org-tags-history)))))))
(while (string-match "[-+&]+" tags)
;; No boolean logic, just a list
@ -9469,7 +9483,7 @@ This works in the agenda, and also in an org-mode buffer."
(if (org-mode-p)
(org-get-buffer-tags)
(org-global-tags-completion-table))))
(completing-read
(org-ido-completing-read
"Tag: " 'org-tags-completion-function nil nil nil
'org-tags-history))
(progn
@ -9680,7 +9694,7 @@ Returns the new tags string, or nil to not change the current settings."
(if exit-after-next (setq exit-after-next 'now)))
((= c ?\t)
(condition-case nil
(setq tg (completing-read
(setq tg (org-ido-completing-read
"Tag: "
(or buffer-tags
(with-current-buffer buf
@ -10316,7 +10330,7 @@ in the current file."
(interactive
(let* ((completion-ignore-case t)
(keys (org-buffer-property-keys nil t t))
(prop0 (completing-read "Property: " (mapcar 'list keys)))
(prop0 (org-ido-completing-read "Property: " (mapcar 'list keys)))
(prop (if (member prop0 keys)
prop0
(or (cdr (assoc (downcase prop0)
@ -10341,7 +10355,7 @@ in the current file."
"In the current entry, delete PROPERTY."
(interactive
(let* ((completion-ignore-case t)
(prop (completing-read
(prop (org-ido-completing-read
"Property: " (org-entry-properties nil 'standard))))
(list prop)))
(message "Property %s %s" property
@ -10353,7 +10367,7 @@ in the current file."
"Remove PROPERTY globally, from all entries."
(interactive
(let* ((completion-ignore-case t)
(prop (completing-read
(prop (org-ido-completing-read
"Globally remove property: "
(mapcar 'list (org-buffer-property-keys)))))
(list prop)))