[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Bug? org-set-tags never uses ido
From: |
Anders Johansson |
Subject: |
Re: [O] Bug? org-set-tags never uses ido |
Date: |
Wed, 02 Apr 2014 19:37:42 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 |
A hack to get ido selection for multiple tags. It uses
ido-completing-read-multiple (available here and included below:
https://gist.github.com/mgalgs/1329188) to allow for completing one tag
at a time and ending it by typing ":".
I haven't tested it much and it might possibly break things (or most
certainly it's implemented in an ugly way). Perhaps someone more than me
will find it useful.
Cheers,
Anders
----
(defadvice org-icompleting-read
(around org-use-ido-for-tags
(prompt coll &optional pred reqm initial hist def)
activate)
"Advised to use ido for multiple completion of tags"
(setq ad-return-value
(if (string= "Tags: " prompt)
(mapconcat 'identity
(ido-completing-read-multiple
prompt
(mapcan
'copy-list org-last-tags-completion-table)
pred reqm initial hist def ":")
":")
ad-do-it)))
(defun ido-completing-read-multiple (prompt choices &optional predicate
require-match initial-input hist def sentinel)
"Read multiple items with ido-completing-read. Reading stops
when the user enters SENTINEL. By default, SENTINEL is
\"*done*\". SENTINEL is disambiguated with clashing completions
by appending _ to SENTINEL until it becomes unique. So if there
are multiple values that look like SENTINEL, the one with the
most _ at the end is the actual sentinel value. See
documentation for `ido-completing-read' for details on the
other parameters."
(let
((sentinel (if sentinel sentinel "*done*"))
(done-reading nil)
(res ()))
;; uniquify the SENTINEL value
(while (find sentinel choices)
(setq sentinel (concat sentinel "_")))
(setq choices (cons sentinel choices))
;; read some choices
(while (not done-reading)
(setq this-choice (ido-completing-read prompt choices predicate
require-match initial-input hist def))
(if (equal this-choice sentinel)
(setq done-reading t)
(setq res (cons this-choice res))))
;; return the result
res
))
----
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [O] Bug? org-set-tags never uses ido,
Anders Johansson <=