emacskey-bindingsemacs-helm

Binding `helm-toggle-visible-mark-forward` to a key in `helm-map`


Setup

I have these key bindings of Helm commands:

  (define-key helm-map (kbd "C-a")       #'helm-select-action)
  (define-key helm-map (kbd "C-n")       #'helm-next-page)
  (define-key helm-map (kbd "C-p")       #'helm-previous-page)
  (define-key helm-map (kbd "TAB")       #'helm-next-line)
  (define-key helm-map (kbd "<backtab>") #'helm-previous-line)
  (define-key helm-map (kbd "C-TAB")     #'helm-toggle-visible-mark-forward)

Problem

All of these work except for the last line, helm-toggle-visible-mark-forward. When I hit C-TAB in the Helm completion window, I get the error message, <C-tab> is undefined.

What I've Tried

Using \t

(define-key helm-map (kbd "C-\t")     #'helm-toggle-visible-mark-forward)

   -- same result, <C-tab> is undefined

Using <C-tab>

(define-key helm-map (kbd "<C-tab>")     #'helm-toggle-visible-mark-forward)

   -- wrong type argument, commandp

Removing #

(define-key helm-map (kbd "C-TAB")     'helm-toggle-visible-mark-forward)

  -- same result, <C-tab> is undefined

Using M-TAB

(define-key helm-map (kbd "M-TAB")     #'helm-toggle-visible-mark-forward)

  -- wrong type argument, commandp

Using a lambda

(define-key helm-map (kbd "M-TAB")     (lambda () (interactive) (helm-toggle-visible-mark-forward)))

  -- symbol's function definition is void: helm-toggle-visible-mark-forward

Question

Is it possible to rebind helm-toggle-visible-mark-forward? If so, what am I doing wrong?


Solution

  • helm-toggle-visible-mark-forward and helm-toggle-visible-mark-backward were added in v3.6.1. The latest release (as of 2020-04-25) is v3.6.0. Hence, you would need to install from source if you want to use these functions. Otherwise, they will be undefined.

    As a workaround, you can add them directly to your configs before your key bindings like so:

      ;; Adding these functions here until they become available in the main source in version 3.6.1
      (defun helm-toggle-visible-mark-forward ()
        (interactive)
        (helm-toggle-visible-mark 1))
    
      (defun helm-toggle-visible-mark-backward ()
        (interactive)
        (helm-toggle-visible-mark -1))
    
      (define-key helm-map (kbd "<C-tab>")     #'helm-toggle-visible-mark-forward)