Tassilo Horn <
tsd...@gmail.com> writes:
> Thierry Volpiatto <
thierry....@gmail.com> writes:
>
> Hi Thierry,
>
>>> For example I want to attach some file to an email message I'm
>>> writing with Gnus.
>>
>> 1) M-x helm-find-files => navigate to your file and C-c C-a
>
> This gives
>
> Debugger entered--Lisp error: (void-function gnus-dired-attach)
>
> (require 'gnus-dired) fixes that. IMO `helm-ff-run-gnus-attach-files'
> should do that instead of requiring the user to have that done
> beforehand.
Right, thanks I will fix this (I have '(require 'gnus-dired)' since ages
in my init file so I never notice this)
> Anyway, that works now. :-)
>
>> 2) with helm-mode enabled, C-c C-a from your mail buffer.
>
> I tried it and it does work but most of the time I prefer the less
> obtrusive standard buffer/file/command promts.
Ok, me too.
>>> I get the standard file selection prompt
>>
>> I assume you got this prompt from 2)
>
> No, helm-mode is not activated.
>
>>> but then I decide that helm's locate source would do the job better.
>>> How can I activate that now?
>>
>> C-x C-f C-x-C-f => search you file with locate and then C-x C-f C-c C-a.
>
> Ah, so with repeated C-x C-f and helm-mode activated I can cycle through
> the helm backends.
>
>> Probably you should use 1) directly in such cases.
>
> Yes, of course. But let's assume there is some command that wants to
> read a file name from the minibuffer which you didn't already cover with
> an action in helm. :-)
C-x C-f => navigate => C-c i
This is also completing the filename already entered in minibuffer or
anywhere else.
>> Not sure to understand where you start helm-for-files and what you
>> want to do exactly.
>
> What I'm looking for is a way to switch to the helm version of selecting
> a file/buffer/whatever when there's already a "normal" prompt for
> reading that in.
So yes, use C-x C-f + C-c i.
> (1) That can either mean an actual switch, e.g., like in ido where `C-x
> C-f'/`C-x b' while an active ido prompt falls back to the standard
> prompts and completion.
>
> (2) It may also mean having a helm action which quits helm and inserts
> the currently selected item wherever I invoked helm from.
>
> I think (1) is pretty hairy to implement but (2) should be easy. I
> think I just need to bind some key to a command which does (2). I've
> tried
>
> --8<---------------cut here---------------start------------->8---
> (defun th/helm-insert-selection ()
> (interactive)
> (when-let ((item (helm-get-selection)))
> (helm-quit-and-execute-action (lambda (&rest _ignore)
> (insert item)))))
>
> (define-key helm-map (kbd "M-SPC") #'th/helm-insert-selection)
> --8<---------------cut here---------------end--------------->8---
>
> and basically that does the trick. I'd welcome if you could tell me if
> that's the intended way.
No, just use C-x C-f as said above.
You can also insert from any helm command with C-c C-i and it is
persistent, it works in minibuffer too (It is not a completion command,
it is just inserting at point).
It works also with marked candidates (i.e you can mark many candidates
and hit C-c C-i to insert them in current-buffer)