Reinstate keyswap-mode
This commit is contained in:
parent
c60c0a544a
commit
f017b173a6
36
init.org
36
init.org
|
@ -1577,21 +1577,45 @@ It'd be really cool to (recenter 3) when you /open/ a section, and (recenter) wh
|
|||
#+END_SRC
|
||||
** Programming
|
||||
*** FIXME common
|
||||
Swap [] with () in programming and text modes.
|
||||
|
||||
pjb suggested a different approach [[http://paste.lisp.org/display/10157][here]], which is basically -
|
||||
#+BEGIN_SRC emacs-lisp :tangle no :load no
|
||||
(defun contrapunctus-swap-brackets-parens ()
|
||||
(interactive)
|
||||
(keyboard-translate ?\( ?\[)
|
||||
(keyboard-translate ?\) ?\])
|
||||
(keyboard-translate ?\[ ?\()
|
||||
(keyboard-translate ?\] ?\)))
|
||||
|
||||
(add-hook 'prog-mode-hook 'contrapunctus-swap-brackets-parens)
|
||||
(add-hook 'text-mode-hook 'contrapunctus-swap-brackets-parens)
|
||||
|
||||
(defun normal-brackets-parens ()
|
||||
(interactive)
|
||||
(keyboard-translate ?\( ?\()
|
||||
(keyboard-translate ?\) ?\))
|
||||
(keyboard-translate ?\[ ?\[)
|
||||
(keyboard-translate ?\] ?\]))
|
||||
#+END_SRC
|
||||
|
||||
...which I tried, but experienced some subtle bugs, and luckily I got keyswap mode to work the way I wanted - no number-symbol switching, just parens and brackets.
|
||||
|
||||
1. [ ] =keyswap-mode= swaps numeric keys with symbols by default. We want to swap just () with [] (to begin with), but the code below doesn't work, for some reason.
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(use-package keyswap-mode
|
||||
:disabled t
|
||||
(use-package keyswap
|
||||
:hook ((prog-mode . keyswap-mode)
|
||||
(text-mode . keyswap-mode)
|
||||
(emacs-lisp-mode . contrapunctus-swap-brackets-parens))
|
||||
(emacs-lisp-mode . contrapunctus-swap-brackets-parens)
|
||||
(emacs-lisp-mode . keyswap-colon-semicolon)
|
||||
(lisp-mode . keyswap-colon-semicolon)
|
||||
(scheme-mode . keyswap-colon-semicolon))
|
||||
:config
|
||||
(defun contrapunctus-swap-brackets-parens ()
|
||||
(setq keyswap-pairs nil)
|
||||
(setq-local keyswap-pairs nil)
|
||||
(message "keyswap-pairs is %s" keyswap-pairs)
|
||||
;; (message "keyswap-pairs is %s" keyswap-pairs)
|
||||
(keyswap-add-pairs ?\[ ?\()
|
||||
(keyswap-add-pairs ?\] ?\))
|
||||
;; (push (cons ?\[ [?\(]) keyswap-pairs)
|
||||
(keyswap-update-keys)))
|
||||
|
||||
(use-package projectile
|
||||
|
|
Loading…
Reference in New Issue