Re: [O] Bug? org-set-tags never uses ido

2014-04-02 Thread Anders Johansson
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
))




Re: [O] Bug? org-set-tags never uses ido

2014-03-04 Thread Eric Abrahamsen
Samuel Wales  writes:

> with my settings, i do c-c c-c tab [select] tab and it sets the first
> one correctly.  but if i do tab after that, it doesn't allow
> completion.  so i guess you're right.
>
> i can do shortcuts which work at the same time and i can do ret c-c
> c-c tab to set more.
>
> ido-hacks is the best of all the ido everywhere thingies i know of, btw.

I think this is what completing-read-multiple is supposed to do: allow
insertion of multiple completion candidates from the list, separated by
the value of crm-separator (a comma by default, but it could be let to
":"). If I recall correctly there's a bug in earlier versions of crm,
and the fix might not be present until later versions of emacs, but take
a look...




Re: [O] Bug? org-set-tags never uses ido

2014-03-04 Thread Samuel Wales
with my settings, i do c-c c-c tab [select] tab and it sets the first
one correctly.  but if i do tab after that, it doesn't allow
completion.  so i guess you're right.

i can do shortcuts which work at the same time and i can do ret c-c
c-c tab to set more.

ido-hacks is the best of all the ido everywhere thingies i know of, btw.



Re: [O] Bug? org-set-tags never uses ido

2014-03-04 Thread Anders Johansson

2014-03-05 01:20, Samuel Wales wrote:

There are several packages that allow ido to work everywhere.  The one
I use, ido-hacks, works fine for tags out of the box.


A quick look at ido-hacks.el here: 
https://github.com/scottjad/ido-hacks/blob/master/ido-hacks.el suggests 
that this doesn't really solve the problem of being able to select 
multiple tags separated by colon at the same time with ido.


I haven't tried it but the docstring for the advice of completing-read says:

"Advice `completing-read' to always use `ido-read-internal',
unless `this-command' has a (ido ignore) property or the
inherit-input-method argument is non-nil or the collection
argument is a function (which ido can't handle)."

which seems to suggest that passing 'org-tags-completion-function as the 
second argument (collection) to the advised completing-read wouldn't use 
ido in this case either


Cheers,
Anders Johansson




Re: [O] Bug? org-set-tags never uses ido

2014-03-04 Thread Samuel Wales
There are several packages that allow ido to work everywhere.  The one
I use, ido-hacks, works fine for tags out of the box.



Re: [O] Bug? org-set-tags never uses ido

2014-03-04 Thread Anders Johansson
Looking at this again I realize that the reason for this behavior is 
that we want completion of possibly several tags. This is what the 
"org-tags-completion-function" does when supplied as the second argument 
of "completing-read". As "ido-completing-read" and 
"org-iswitchb-completing-read" doesn't support this, they are not used.


I don't know if there would be a way of getting both ido and multiple 
input. As it is now though, it's pretty meaningless to have that call to 
org-icompleting-read there as it never gets activated. It could as well be:


(completing-read "Tags: "
'org-tags-completion-function
nil nil current 'org-tags-history)


Cheers,
Anders Johansson


2013-11-01 02:33, Eric Abrahamsen skrev:

Anders Johansson  writes:


Greetings,
I want to use ido everywhere and wanted to know why this doesn't seem
to work for setting org-mode tags (it never has for me).

Using edebug to step through the call to org-icompleting-read which
org-set-tags does I can see that it never gets to using ido since the
last condition below is false:
org.el:10147-10150 (package repository version 20131028):
(if (and org-completion-use-ido
 (fboundp 'ido-completing-read)
 (boundp 'ido-mode) ido-mode
 (listp (second args)))

This is not strange, since org-icompleting-read is called like this in
org-set-tags:

org.el:14519-14521
(org-icompleting-read "Tags: "
  'org-tags-completion-function
  nil nil current 'org-tags-history))

Hmm, shouldn't that 'org-tags-completion-function be replaced with
org-last-tags-completion-table? A quick test shows that works, and from
glancing at the code it seems like org-last-tags-completion-table should
hold the proper assortment of tags...

E


ido apparently needs a list of possible completions, not a single symbol.

I don't understand much more of this really.
Is it a bug? Have I misunderstood something?

Greetings,
Anders Johansson







Re: [O] Bug? org-set-tags never uses ido

2013-10-31 Thread Eric Abrahamsen
Anders Johansson  writes:

> Greetings,
> I want to use ido everywhere and wanted to know why this doesn't seem
> to work for setting org-mode tags (it never has for me).
>
> Using edebug to step through the call to org-icompleting-read which
> org-set-tags does I can see that it never gets to using ido since the
> last condition below is false:
> org.el:10147-10150 (package repository version 20131028):
>(if (and org-completion-use-ido
> (fboundp 'ido-completing-read)
> (boundp 'ido-mode) ido-mode
> (listp (second args)))
>
> This is not strange, since org-icompleting-read is called like this in
> org-set-tags:
>
> org.el:14519-14521
>(org-icompleting-read "Tags: "
>  'org-tags-completion-function
>  nil nil current 'org-tags-history))

Hmm, shouldn't that 'org-tags-completion-function be replaced with
org-last-tags-completion-table? A quick test shows that works, and from
glancing at the code it seems like org-last-tags-completion-table should
hold the proper assortment of tags...

E

>
> ido apparently needs a list of possible completions, not a single symbol.
>
> I don't understand much more of this really.
> Is it a bug? Have I misunderstood something?
>
> Greetings,
> Anders Johansson