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

Unable to (re)map M-3 key binding to insert # character on UK Macbook Pro keyboard #5820

Closed
dubnde opened this issue Apr 17, 2016 · 3 comments

Comments

@dubnde
Copy link
Contributor

dubnde commented Apr 17, 2016

Description

The Mac UK keyboard uses M-3 binding to insert the # character. Spacemacs however has this mapped to select window number 3. This presents a challenge in inserting the # character so ubiquitous with C/C++ coding.

Also unable to unbind the key.

Should mention the keybinding works in plain old vanilla emacs

Reproduction guide

  • Start Emacs
  • Create a empty buffer
  • Try insert # character on UK mac keyboard

Observed behaviour:
Jumps to window 3 or indicates no window 3 if less than three windows open

Expected behaviour:
insert # character at point.

System Info

  • OS: darwin
  • Emacs: 24.5.1
  • Spacemacs: 0.105.18
  • Spacemacs branch: develop (rev. edfc5de)
  • Graphic display: t
  • Distribution: spacemacs
  • Editing style: vim
  • Completion: helm
  • Layers:
((auto-completion :variables auto-completion-enable-help-tooltip t auto-completion-enable-snippets-in-popup t auto-completion-return-key-behavior 'complete auto-completion-tab-key-behavior 'cycle :disabled-for shell)
 better-defaults
 (colors :variables colors-enable-rainbow-identifiers nil)
 cscope
 (c-c   :variables c-c  -enable-clang-support t auto-completion-enable-help-tooltip t c-c  -default-mode-for-headers 'c  -mode)
 emacs-lisp evil-cleverparens evil-commentary
 (evil-snipe :variables evil-snipe-enable-alternate-f-and-t-behaviors t)
 git github haskell html ibuffer javascript markdown
 (org :variables org-enable-github-support t)
 osx semantic
 (shell :variables shell-enable-smart-eshell t)
 shell-scripts spacemacs-helm spell-checking syntax-checking ruby version-control windows-scripts yaml)
@sooheon
Copy link

sooheon commented Apr 18, 2016

Worked for me:

(defun sooheon/post-init-window-numbering ()
  (let ((m window-numbering-keymap))
    (define-key m "\M-0" nil)
    (define-key m "\M-1" nil)
    (define-key m "\M-2" nil)
    (define-key m "\M-3" nil)
    (define-key m "\M-4" nil)
    (define-key m "\M-5" nil)
    (define-key m "\M-6" nil)
    (define-key m "\M-7" nil)
    (define-key m "\M-8" nil)
    (define-key m "\M-9" nil)
    (define-key m (kbd "s-1") 'select-window-1)
    (define-key m (kbd "s-2") 'select-window-2)
    (define-key m (kbd "s-3") 'select-window-3)
    (define-key m (kbd "s-4") 'select-window-4)
    (define-key m (kbd "s-5") 'select-window-5)
    (define-key m (kbd "s-6") 'select-window-6)
    (define-key m (kbd "s-7") 'select-window-7)
    (define-key m (kbd "s-8") 'select-window-8)
    (define-key m (kbd "s-9") 'select-window-9))
  (evil-leader/set-key
    "0" nil "1" nil "2" nil "3" nil "4" nil
    "5" nil "6" nil "7" nil "8" nil "9" nil))

@dubnde
Copy link
Contributor Author

dubnde commented Apr 18, 2016

@sooheon I ended up using the s-3 to insert the # character. I like your approach better though. Especially that I use the SPC n to select window n.

Tried it and thanks to Emacs question - hash key managed to get the workaround going after adding the bindings below.

(defun setup-mac-meta-keys ()
  (spacemacs/toggle-maximize-frame-on)
  (let ((m window-numbering-keymap))
    ;; On UK MBP keyboards, META key is used to insert certain characters clear the key
    (define-key m "\M-0" nil)
    (define-key m "\M-1" nil)
    (define-key m "\M-2" nil)
    (define-key m "\M-3" nil)
    (define-key m "\M-4" nil)
    (define-key m "\M-5" nil)
    (define-key m "\M-6" nil)
    (define-key m "\M-7" nil)
    (define-key m "\M-8" nil)
    (define-key m "\M-9" nil)

    ;; http://stackoverflow.com/questions/3977069/emacs-question-hash-key
    (global-set-key (kbd "M-2") '(lambda () (interactive) (insert "€")))
    (global-set-key (kbd "M-3") '(lambda () (interactive) (insert "#")))
    (define-key isearch-mode-map (kbd "M-3")
      '(lambda ()
         (interactive)
         (isearch-process-search-char ?\#)))))

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!

@github-actions github-actions bot added the stale marked as a stale issue/pr (usually by a bot) label Feb 29, 2020
@lebensterben lebensterben removed the stale marked as a stale issue/pr (usually by a bot) label Feb 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Forum
  
To close
Development

No branches or pull requests

4 participants