all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Bug? org-set-tags never uses ido
@ 2013-10-31 16:39 Anders Johansson
  2013-11-01  1:33 ` Eric Abrahamsen
  2014-03-05  0:20 ` Samuel Wales
  0 siblings, 2 replies; 8+ messages in thread
From: Anders Johansson @ 2013-10-31 16:39 UTC (permalink / raw)
  To: emacs-orgmode

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))))))

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Bug? org-set-tags never uses ido
  2013-10-31 16:39 Bug? org-set-tags never uses ido Anders Johansson
@ 2013-11-01  1:33 ` Eric Abrahamsen
  2014-03-04 22:22   ` Anders Johansson
  2014-03-05  0:20 ` Samuel Wales
  1 sibling, 1 reply; 8+ messages in thread
From: Eric Abrahamsen @ 2013-11-01  1:33 UTC (permalink / raw)
  To: emacs-orgmode

Anders Johansson <mejlaandersj@gmail.com> 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Bug? org-set-tags never uses ido
  2013-11-01  1:33 ` Eric Abrahamsen
@ 2014-03-04 22:22   ` Anders Johansson
  0 siblings, 0 replies; 8+ messages in thread
From: Anders Johansson @ 2014-03-04 22:22 UTC (permalink / raw)
  To: Eric Abrahamsen, emacs-orgmode

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 <mejlaandersj@gmail.com> 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
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Bug? org-set-tags never uses ido
  2013-10-31 16:39 Bug? org-set-tags never uses ido Anders Johansson
  2013-11-01  1:33 ` Eric Abrahamsen
@ 2014-03-05  0:20 ` Samuel Wales
  2014-03-05  0:31   ` Anders Johansson
  1 sibling, 1 reply; 8+ messages in thread
From: Samuel Wales @ 2014-03-05  0:20 UTC (permalink / raw)
  To: Anders Johansson; +Cc: emacs-orgmode

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Bug? org-set-tags never uses ido
  2014-03-05  0:20 ` Samuel Wales
@ 2014-03-05  0:31   ` Anders Johansson
  2014-03-05  0:47     ` Samuel Wales
  0 siblings, 1 reply; 8+ messages in thread
From: Anders Johansson @ 2014-03-05  0:31 UTC (permalink / raw)
  To: Samuel Wales; +Cc: emacs-orgmode

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Bug? org-set-tags never uses ido
  2014-03-05  0:31   ` Anders Johansson
@ 2014-03-05  0:47     ` Samuel Wales
  2014-03-05  1:49       ` Eric Abrahamsen
  2014-04-02 17:37       ` Anders Johansson
  0 siblings, 2 replies; 8+ messages in thread
From: Samuel Wales @ 2014-03-05  0:47 UTC (permalink / raw)
  To: Anders Johansson; +Cc: emacs-orgmode

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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Bug? org-set-tags never uses ido
  2014-03-05  0:47     ` Samuel Wales
@ 2014-03-05  1:49       ` Eric Abrahamsen
  2014-04-02 17:37       ` Anders Johansson
  1 sibling, 0 replies; 8+ messages in thread
From: Eric Abrahamsen @ 2014-03-05  1:49 UTC (permalink / raw)
  To: emacs-orgmode

Samuel Wales <samologist@gmail.com> 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...

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Bug? org-set-tags never uses ido
  2014-03-05  0:47     ` Samuel Wales
  2014-03-05  1:49       ` Eric Abrahamsen
@ 2014-04-02 17:37       ` Anders Johansson
  1 sibling, 0 replies; 8+ messages in thread
From: Anders Johansson @ 2014-04-02 17:37 UTC (permalink / raw)
  To: emacs-orgmode

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
     ))
----

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-04-02 17:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-31 16:39 Bug? org-set-tags never uses ido Anders Johansson
2013-11-01  1:33 ` Eric Abrahamsen
2014-03-04 22:22   ` Anders Johansson
2014-03-05  0:20 ` Samuel Wales
2014-03-05  0:31   ` Anders Johansson
2014-03-05  0:47     ` Samuel Wales
2014-03-05  1:49       ` Eric Abrahamsen
2014-04-02 17:37       ` Anders Johansson

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.