Привязки клавиш Spacemacs не регистрируются

В моем файле .spacemacs есть раздел, который выглядит так:

(defun dotspacemacs/user-config ()
  "Configuration function for user code.
This function is called at the very end of Spacemacs initialization after
layers configuration.
This is the place where most of your configurations should be done. Unless it is
explicitly specified that a variable should be set before a package is loaded,
you should place your code here."

;; Keybindings
(global-unset-key [(control z)]) ;; unbind sleep button
(global-unset-key [(control x)(control z)]) ;; unbind sleep button
(global-unset-key [(control e)])
(global-unset-key [(control k)]) ;; unbind kill line
(global-set-key [(control z)] 'undo) ;; set Windows-style undo
(global-set-key [(control e)] 'View-scroll-half-page-backward) ;; remap page up

;; Setting and showing the 80-character column width
(set-fill-column 80)
(auto-fill-mode t)
(toggle-fill-column-indicator)

(custom-set-variables
  ;; custom-set-variables was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
  '(paradox-github-token t))
(custom-set-faces
  ;; custom-set-faces was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
  )

  )

Я следовал синтаксису из этой статьи: https://github.com/andrewfwang/dotfiles/blob/ee84ddd304d1dad7ece206062debd3e3c86e927f/.emacs.d/init.el

Однако каждый раз, когда я перезапускаю spacemacs, ни одно из моих изменений не регистрируется. Однако, если я включаю или отключаю пакеты в этом же файле, эти изменения регистрируются. Должны ли эти настройки привязки клавиш быть не ниже user-config?


person Alex Petralia    schedule 05.12.2016    source источник


Ответы (2)


Настройка CTRL+Z немного сложна, так как код spacemacs содержит функцию для повторной привязки при переключении в режим emacs и обратно. Он делает это через ссылку на evil-toggle-key, которая по умолчанию CTRL+Z. Если вы измените Evil-toggle-key на что-то другое, вы можете использовать CTRL+Z для отмены.

Предложение: в файле .spacemacs

Добавьте эту строку в раздел custom-set-variables

'( evil-toggle-key "C-`")

и эта строка в разделе dotspacemacs/user-config

(global-set-key (kbd "C-z") 'undo) 

Приведенная выше конфигурация работает на spacemacs версии 0.200.7, emacs версии 25.1.1 как под Windows, так и под Linux.

person moose1089    schedule 23.01.2017
comment
Похоже ставить '( evil-toggle-key "C-)` в dotspacemacs/user-config в custom-set-variables поздно, так как зло к тому времени уже загрузилось. Однако размещение (setq evil-toggle-key "C-`") в разделе dotspacemacs/user-init () .spacemacs, кажется, работает. - person NeilenMarais; 05.11.2017

По моему опыту, ответ moose1089 в основном соответствует этому, но злую конфигурацию необходимо загрузить раньше, чем раздел dotspacemacs/user-config в .spacemacs. Я обнаружил, что добавление (setq evil-toggle-key "C-")in thedotspacemacs/user-init()section of.spacemacs` прекрасно работает.

person NeilenMarais    schedule 05.11.2017