How to bind C- = in emacs?

This s-expression in my .emacsfile does not give the desired result:

(define-key global-map (kbd "C-=") 'djhaskin987-untab-to-tab-stop)

Why can't I attach a command to Ctrl+ =?

EDIT to clarify:

I use emacs23-noxfor the standard build urxvt-256colorsfor Debian, except that I recompiled with --disable-iso405776(or something like that) so that Ctrl+ Shiftdoes not perform the weird “character insertion”. I don’t know if this affects anything. For example, C-M-isends M-TABwhat I do not understand.

EDIT II :

I apologize for not understanding this. The function djhaskin987-untab-to-tab-stophas a string in it (interactive). This part works.

+6
source share
5

TAB , C-i. C-=, =. . - ( ), Emacs C-= ( - (define-key input-decode-map "...thebytes..." [?\C-=])).

+7

, . :

  1. Emacs

/ .

X Window System. /usr/X11R6/include/X11/keysymdef.h ( locate keysymdef.h), XK_ ( ). , .

X, , :

XTerm.VT100.Translations: #override \
Ctrl ~Meta ~Shift  <Key> equal:         string(0x1b) string("[emacs-C-=")\n

- escape, - .

iTerm Preferences->Keys Send Escape Sequence Action. , :

iTerm key mappings

Emacs Wiki .

Emacs C-=. define-key input-decode-map. :

(defun my/global-map-and-set-key (key command &optional prefix suffix)
   "'my/map-key' KEY then 'global-set-key' KEY with COMMAND.
 PREFIX or SUFFIX can wrap the key when passing to 'global-set-key'."
   (my/map-key key)
   (global-set-key (kbd (concat prefix key suffix)) command))

 (defun my/map-key (key)
   "Map KEY from escape sequence \"\e[emacs-KEY\."
   (define-key function-key-map (concat "\e[emacs-" key) (kbd key)))

, :

(my/global-map-and-set-key "C-=" 'some-function-to-bind-to)

( : ()\|;''"#.,) , C-\..

+8

, emacs . "C- =". emacs, . .

+1

, , . :

(define-key global-map (kbd "C-=") 
    (lambda () (interactive) (djhaskin987-untab-to-tab-stop)))
0

C- = ascii : ^[[61;5u. Emacs, :

(global-set-key (kbd "C-=") 'djhaskin987-untab-to-tab-stop))

, :

(use-package expand-region
  :ensure t
  :bind (("C-=" . er/expand-region)))

I want to thank Sam Brightman for his wonderful decision. This is a very clean, albeit complex, approach that will work for any keys that cannot be sent using regular ASCII codes. I have long wanted to get C-TAB to work inside iterm2 for a long time. I was able to do this by removing the built-in settings keys for C-TAB / C-S-TAB and using its approach. Using the following, I can connect to remote Linux blocks and quickly switch between many open buffers in projects, like a desktop editor. enter image description here

(use-package nswbuff
  :defer 1
  :after (projectile)
  :commands (nswbuff-switch-to-previous-buffer
             nswbuff-switch-to-next-buffer)
  :config
  (progn
    (my/global-map-and-set-key "C-TAB" 'nswbuff-switch-to-previous-buffer)
    (my/global-map-and-set-key "C-S-TAB" 'nswbuff-switch-to-next-buffer))
  :init
  (setq nswbuff-display-intermediate-buffers t
        nswbuff-exclude-buffer-regexps '("^ "
                                         "^\*.*\*"
                                         "\*Treemacs.*\*"
                                         "^magit.*:.+")
        nswbuff-include-buffer-regexps '("^*Org Src")
        nswbuff-start-with-current-centered t
        nswbuff-buffer-list-function '(lambda ()
                                        (interactive)
                                        (if (projectile-project-p)
                                            (nswbuff-projectile-buffer-list)
                                          (buffer-list)))))
0
source

All Articles