5

I am a beginner of helm-mode.

Why remapping of arrow keys ((kbd "<left>"), (kbd "right"), ...) on helm-map doesn't work while others work fine?

Here are the entire settings:

(require 'helm-config)
(helm-mode 1)
(define-key global-map (kbd "C-;") 'helm-mini)
(define-key global-map (kbd "M-y") 'helm-show-kill-ring)
(define-key global-map (kbd "C-x C-r") 'helm-recentf)
(define-key global-map [remap find-file] 'helm-find-files) ;
(define-key global-map [remap execute-extended-command] 'helm-M-x)
(define-key helm-map (kbd "C-h") 'delete-backward-char)
(define-key helm-find-files-map (kbd "<left>") 'backward-char)
(define-key helm-find-files-map (kbd "<right>") 'forward-char)

;; no effects and default key bind works for following two lines
(define-key helm-map (kbd "<left>") 'backward-char)
(define-key helm-map (kbd "<right>") 'forward-char)

Thank you.

2
  • 1
    C-h k <right> says it is on helm-buffer-map.
    – xuchunyang
    Commented Feb 28, 2017 at 7:09
  • I cannot reproduce this. Mapping <right> and <left> within helm-map like in your example works for me.
    – Timm
    Commented Mar 1, 2017 at 17:03

2 Answers 2

4

I searched in GitHub repository by "left", then the problem solved by inserting (setq helm-ff-lynx-style-map nil) before (helm-mode 1).

https://github.com/emacs-helm/helm/blob/91ced00ad8bac63ca1311a39b0045677f9b2caae/helm-files.el#L409

Hence my complete settings will be following:

(require 'helm-config)
(setq helm-ff-lynx-style-map nil)
(helm-mode 1)
(define-key global-map (kbd "C-;") 'helm-mini)
(define-key global-map (kbd "M-y") 'helm-show-kill-ring)
(define-key global-map (kbd "C-x C-r") 'helm-recentf)
(define-key global-map [remap find-file] 'helm-find-files) ;
(define-key global-map [remap execute-extended-command] 'helm-M-x)
(define-key helm-map (kbd "C-h") 'delete-backward-char)
(define-key helm-map (kbd "<left>") 'backward-char)
(define-key helm-map (kbd "<right>") 'forward-char)
4
  • You can use C-f and C-b for forward-char and backward-char respectively. If you get used to them you'll find out that using arrows is much more time consuming for simple navigation. I think this is the reason why they're natively remapped to something else.
    – Daniel
    Commented Mar 1, 2017 at 9:30
  • Yes, but I could not get used to them even in several years use.
    – tubo
    Commented Mar 1, 2017 at 14:14
  • have a look at hardcore-mode. It's never too late to try again =)
    – Daniel
    Commented Mar 1, 2017 at 15:26
  • Using emacs for decades. And no, using C-n etc is not easier for me since I use arrow keys in every other app under the sun and it's ingrained. Anyone not supporting arrows in edit lines by default needs to wake up to the real world ;) Of course, add the facility to turn it off the truly Emacsed.
    – RichieHH
    Commented Dec 12, 2019 at 8:26
0

To provide a more 'up-to-date' answer (for anyone new reading this):

Looking at the helm source documentation it seems that we should use customize, and it clearly states that declaring helm-ff-lynx-style-map manually with setq will not work...

I disagree, and this was found to be working fine:

(require 'helm)
(require 'helm-config)

;; to enable fuzzy matching with helm-mini, add the following settings:
(setq helm-buffers-fuzzy-matching t
      helm-recentf-fuzzy-match    t)

;; helm-find-files - file navigation on steroids!
;; if the point is located on a folder path, C-x C-f will
;; start in that folder. (Use C-l C-r to navigate directories)
(global-set-key (kbd "C-x C-f") 'helm-find-files)

;; move to end or beginning of source when reaching top or bottom
(setq helm-move-to-line-cycle-in-source t)

;; use arrow keys to navigate helm-find-files menu
(setq helm-ff-lynx-style-map t)
(helm-mode 1)
1
  • 2
    Usually when a docstring says "use customize, setq won't work" it doesn't mean "we guarantee that setq won't work for you" but rather that if you use setq don't come complaining if it ends up not working.
    – Stefan
    Commented May 11, 2020 at 2:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.