Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toggle-input-method is not working in helm-find-files #797

Closed
ineu opened this issue Jan 4, 2015 · 17 comments
Closed

toggle-input-method is not working in helm-find-files #797

ineu opened this issue Jan 4, 2015 · 17 comments

Comments

@ineu
Copy link

ineu commented Jan 4, 2015

Hello.
Just noticed that toggle-input-method is not working in helm-find-files. You can type only latin characters, pressing C-\ does nothing.
Meanwhile it does work in all helm-mini, helm-ls-git-ls, helm-resume.
Furthermore, helm-find-files doesn't inherit input method from current buffer, it always resets to english.
This basically means that I cannot visit directories or open files with non-latin names (cyrillic in my case) in any other way than with dired.
Reproduced in clean emacs -q with

(add-to-list 'load-path "/home/ineu/.emacs.d/elpa/helm-20150102.2126")
(require 'helm-config)

EDIT: It's more tricky. Seems like it works, but in very weird way. Switching to russian input method and typing some arbitrary strings in helm-find-files inputs mostly latin characters, but sometimes few cyrillic characters appear, and then latin again.

@thierryvolpiatto
Copy link
Member

Related to #785 .

@ineu
Copy link
Author

ineu commented Jan 4, 2015

Yes, in inheritance part. But this is just a tiny inconvenience. The real problem is with

It's more tricky. Seems like it works, but in very weird way. Switching to russian input method and typing some arbitrary strings in helm-find-files inputs mostly latin characters, but sometimes few cyrillic characters appear, and then latin again.

@thierryvolpiatto
Copy link
Member

This is really tricky to fix.
Actually with current-input-method set in helm-buffer to the
current-buffer's value, it works in some places but not others places.

With this code, we can set current-input-method in helm-buffer:

(add-hook 'helm-before-initialize-hook (lambda ()
(helm-set-local-variable
'current-input-method
current-input-method)))

Now in a simple source like this:

(helm :sources (helm-build-sync-source "test"
:candidates '("а" "аб" "абц" "абцд" "аѕертз"))
:buffer "helm test")

We can input "cyrillic-ukrainian" chars in minibuffer to match some
candidates; It is working.

However it doesn't work (or partially) with others sources.
I still don't understand why for the moment and don't know yet how to
debug this.
Help welcome on this.

Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997

@thierryvolpiatto
Copy link
Member

Ok the problem comes from the updating of keymap, it seems it overhide self-insert-command.

So from scratch buffer, following code allow entering local chars in minibuffer:

(helm :sources (helm-build-sync-source "test"
                 :candidates (lambda () (directory-files default-directory t))
                 ;:keymap (current-local-map)
                 )
      :buffer "*helm test*")

But as soon :keymap is commented out characters from default-input-method are used.

@michael-heerdegen
Copy link
Contributor

I guess this is due to how helm--maybe-update-keymap is implemented (using set-transient-map, set-temporary-overlay-map).

@thierryvolpiatto
Copy link
Member

Michael Heerdegen notifications@github.com writes:

I guess this is due to how helm--maybe-update-keymap is implemented
(using set-transient-map, set-temporary-overlay-map).

Yes it comes from helm--maybe-update-keymap, but I still don't
understand why set-transient-map doesn't update the keymap according to
the value of input-method in helm-buffer.

Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997

@michael-heerdegen
Copy link
Contributor

Thierry Volpiatto notifications@github.com writes:

Yes it comes from helm--maybe-update-keymap, but I still don't
understand why set-transient-map doesn't update the keymap according
to the value of input-method in helm-buffer.

set-transient-map works by setting overriding-terminal-local-map
(temporarily).

Obviously, setting overriding-terminal-local-map confuses input
methods. Try e.g.

(let ((map (make-sparse-keymap)))
  (define-key map [f12] #'make-frame)
  (setq overriding-terminal-local-map map))

in scratch in emacs -Q and try to use an input method. It wont work.
This doesn't seem to be documented anywhere.

@michael-heerdegen
Copy link
Contributor

Michael Heerdegen michael_heerdegen@web.de writes:

This doesn't seem to be documented anywhere.

Though, I guess set-transient-map was never intended to be used like we
do.

@thierryvolpiatto
Copy link
Member

Michael Heerdegen notifications@github.com writes:

Michael Heerdegen michael_heerdegen@web.de writes:

This doesn't seem to be documented anywhere.

It is documented, see documenation of input-method-function.
When overriding-terminal-local-map or overriding-local-map are non--nil,
the input-method-function just return its argument with no translation.

Though, I guess set-transient-map was never intended to be used like we
do.

Probably, but it serve us well until now, and our task in helm is not
easy, we have to redefine the keymap each time we change source.

Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997

thierryvolpiatto added a commit that referenced this issue Jan 7, 2015
Not really a fix, but this allow at least to use
input-method in some commands.

* helm-files.el (helm-source-ffiles, Helm-find-files): Do it.
* helm-grep.el (helm-do-grep-1): Do it.
* helm-mode.el (helm-read-file-name,
helm-comp-read): Do it.
thierryvolpiatto added a commit that referenced this issue Jan 7, 2015
* helm.el (helm-initial-setup): Do it.
(helm-before-initialize-hook,
helm-after-initialize-hook): Fix docstring.
thierryvolpiatto added a commit that referenced this issue Jan 7, 2015
* helm.el (helm-minor-mode): New minor mode that run in minibuffer.
(helm-read-pattern-maybe): Use it.
Set also minor-mode-overriding-map-alist.
(helm--maybe-update-keymap): Use minor-mode-overriding-map-alist to modify keymap on the fly.
@thierryvolpiatto
Copy link
Member

Now with the helm-minor-mode branch, it should work.

What should work ?

  1. Enable a new input-method in a buffer.
  2. Run any helm command starting from this buffer.
  3. Start writing in minibuffer.
    You should have the expected character (cyrillic or whatever)
  4. In helm commands that have multiples sources, you should have the
    right keymap corresponding to the current source.

@tuhdo
Copy link
Contributor

tuhdo commented Jan 7, 2015

@Fuco1 You should try helm-minor-mode to see if solves your issue with input method.

@thierryvolpiatto
Copy link
Member

Tu Do notifications@github.com writes:

@Fuco1 You should try helm-minor-mode to see if solves your issue with input method.

NO!!! helm-minor-mode should not be used by user, it is internal, IOW
for input method working user have just NOTHING to do, just run helm as
usual after toggling input method in current-buffer.

BTW I have renamed it to helm--minor-mode and make it unusable
interactively, docstring is updated too.

Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997

@tuhdo
Copy link
Contributor

tuhdo commented Jan 7, 2015

Ah so in other words input method won't be malfunctioned in the minibuffer anymore without doing anything? Nice.

@ineu
Copy link
Author

ineu commented Jan 7, 2015

Tried in helm-find-files, works great: inherits keymap from the current buffer and allows to switch keymap.
Is it possible to display current keymap in the helm buffer's modeline just like it is displayed in ordinary buffers?

@thierryvolpiatto
Copy link
Member

Tu Do notifications@github.com writes:

Ah so in other words input method won't be malfunctioned in the
minibuffer anymore without doing anything?

Yes.

Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997

@thierryvolpiatto
Copy link
Member

Eugene Diachkin notifications@github.com writes:

Tried in helm-find-files, works great: inherits keymap from the
current buffer and allows to switch keymap.

Great, merged to master.

Is it possible to display current keymap in the helm buffer's modeline
just like it is displayed in ordinary buffers?

You can see the current keymap bindings with C-c ?.

Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997

@ineu
Copy link
Author

ineu commented Jan 7, 2015

Great, thank you!

@ineu ineu closed this as completed Jan 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants