mirror of
https://codeberg.org/scip/dot-emacs.git
synced 2025-12-17 20:40:58 +01:00
[re-]enabled electric pair mode for lisp
Now if I enter ) after an sexp whose closing parenthesis is located on the line below (or somewhere else below) the closing parens will be moved to the current line. I am used to this and my old config seemed to have this enabled somehow by default.
This commit is contained in:
@@ -30,10 +30,14 @@ Used when enabling smartparens-mode."
|
|||||||
(goto-char beg))))
|
(goto-char beg))))
|
||||||
|
|
||||||
(use-package smartparens
|
(use-package smartparens
|
||||||
:config
|
:init
|
||||||
(require 'smartparens-config)
|
(require 'smartparens-config)
|
||||||
(require 'cl-lib)
|
(require 'cl-lib)
|
||||||
|
|
||||||
|
;; :custom-face
|
||||||
|
;; (sp-show-pair-match-face ((t (:foreground "White"))))
|
||||||
|
|
||||||
|
:config
|
||||||
;; enable sp in minibuffer as well
|
;; enable sp in minibuffer as well
|
||||||
;; maybe, see: https://github.com/Fuco1/smartparens/issues/33:
|
;; maybe, see: https://github.com/Fuco1/smartparens/issues/33:
|
||||||
;; (sp-local-pair 'minibuffer-inactive-mode "'" nil :actions nil)
|
;; (sp-local-pair 'minibuffer-inactive-mode "'" nil :actions nil)
|
||||||
@@ -44,6 +48,9 @@ Used when enabling smartparens-mode."
|
|||||||
(add-something-to-mode-hooks
|
(add-something-to-mode-hooks
|
||||||
'(rust emacs-lisp ielm lisp elisp lisp-interaction scheme slime-repl ) 'smartparens-mode)
|
'(rust emacs-lisp ielm lisp elisp lisp-interaction scheme slime-repl ) 'smartparens-mode)
|
||||||
|
|
||||||
|
(add-something-to-mode-hooks
|
||||||
|
'(emacs-lisp ielm lisp elisp lisp-interaction scheme slime-repl ) 'electric-pair-mode)
|
||||||
|
|
||||||
;; also in some select prog modes
|
;; also in some select prog modes
|
||||||
;; (add-something-to-mode-hooks
|
;; (add-something-to-mode-hooks
|
||||||
;; '(perl ruby c c++ sh makefile config-general yaml go) (smartparens-mode t))
|
;; '(perl ruby c c++ sh makefile config-general yaml go) (smartparens-mode t))
|
||||||
@@ -82,57 +89,6 @@ respectively."
|
|||||||
;;(add-hook 'smartparens-enabled-hook #'tvd-disable-par-and-pair)
|
;;(add-hook 'smartparens-enabled-hook #'tvd-disable-par-and-pair)
|
||||||
;;(add-hook 'smartparens-enabled-hook #'turn-on-smartparens-strict-mode)
|
;;(add-hook 'smartparens-enabled-hook #'turn-on-smartparens-strict-mode)
|
||||||
|
|
||||||
;; auto wrapping w/o region
|
|
||||||
(define-key smartparens-mode-map (kbd "C-c (") 'wrap-with-parens)
|
|
||||||
(define-key smartparens-mode-map (kbd "C-c [") 'wrap-with-brackets)
|
|
||||||
(define-key smartparens-mode-map (kbd "C-c {") 'wrap-with-braces)
|
|
||||||
(define-key smartparens-mode-map (kbd "C-c '") 'wrap-with-single-quotes)
|
|
||||||
(define-key smartparens-mode-map (kbd "C-c \"") 'wrap-with-double-quotes)
|
|
||||||
(define-key smartparens-mode-map (kbd "C-c `") 'wrap-with-back-quotes)
|
|
||||||
|
|
||||||
;; modification
|
|
||||||
(define-key smartparens-mode-map (kbd "C-k") 'sp-kill-hybrid-sexp)
|
|
||||||
(define-key smartparens-mode-map (kbd "C-<left>") 'sp-forward-slurp-sexp)
|
|
||||||
(define-key smartparens-mode-map (kbd "C-<right>") 'sp-forward-barf-sexp)
|
|
||||||
|
|
||||||
;; movement
|
|
||||||
;; Also Check: https://github.com/Fuco1/smartparens/wiki/Working-with-expressions
|
|
||||||
;; (look for "quick summary for each navigation function")
|
|
||||||
;;
|
|
||||||
;; Jump after the next balanced expression. If inside one and
|
|
||||||
;; there is no forward exp., jump after its closing pair.
|
|
||||||
(define-key smartparens-mode-map (kbd "C-M-<right>") 'sp-forward-sexp)
|
|
||||||
;; Jump before the previous balanced expression. If inside one
|
|
||||||
;; and there is no previous exp., jump before its opening pair.
|
|
||||||
(define-key smartparens-mode-map (kbd "C-M-<left>") 'sp-backward-sexp)
|
|
||||||
;; Jump up one level from the current balanced expression. This
|
|
||||||
;; means skipping all the enclosed expressions within this and
|
|
||||||
;; then jumping after the closing pair.
|
|
||||||
(define-key smartparens-mode-map (kbd "C-M-<up>") 'sp-up-sexp)
|
|
||||||
;; Jump after the opening pair of next balanced expression. This
|
|
||||||
;; effectively descends one level down in the "expression
|
|
||||||
;; hierarchy". If there is no expression to descend to, jump
|
|
||||||
;; after current expression's opening pair. This can be used to
|
|
||||||
;; quickly navigate to the beginning of current balanced
|
|
||||||
;; expression.
|
|
||||||
(define-key smartparens-mode-map (kbd "C-M-<down>") 'sp-down-sexp)
|
|
||||||
;; Jump to the beginning of following balanced expression. If
|
|
||||||
;; there is no following expression on the current level, jump
|
|
||||||
;; one level up backward, effectively doing sp-backward-up-sexp.
|
|
||||||
(define-key smartparens-mode-map (kbd "C-S-<left>") 'sp-next-sexp)
|
|
||||||
;; Jump to the end of the previous balanced expression. If there
|
|
||||||
;; is no previous expression on the current level, jupm one level
|
|
||||||
;; up forward, effectively doing sp-up-sexp.
|
|
||||||
(define-key smartparens-mode-map (kbd "C-S-<right>") 'sp-previous-sexp)
|
|
||||||
|
|
||||||
;; comment the whole sexp
|
|
||||||
(define-key smartparens-mode-map (kbd ";") 'tvd-lisp-comment)
|
|
||||||
|
|
||||||
;; replace my global setting
|
|
||||||
;; FIXME: fhceck/fix M<up+down>!
|
|
||||||
(define-key smartparens-mode-map (kbd "M-<right>") 'sp-forward-symbol)
|
|
||||||
(define-key smartparens-mode-map (kbd "M-<left>") 'sp-backward-symbol)
|
|
||||||
|
|
||||||
(when (fboundp 'defhydra)
|
(when (fboundp 'defhydra)
|
||||||
(defhydra hydra-smartparens (:hint nil)
|
(defhydra hydra-smartparens (:hint nil)
|
||||||
"
|
"
|
||||||
@@ -189,8 +145,59 @@ _k_: kill (C-k) _s_: split _{_: wrap with { }
|
|||||||
("C-<left>" sp-backward-barf-sexp)
|
("C-<left>" sp-backward-barf-sexp)
|
||||||
("C-<right>" sp-backward-slurp-sexp))
|
("C-<right>" sp-backward-slurp-sexp))
|
||||||
|
|
||||||
(define-key smartparens-mode-map (kbd "C-x (") 'hydra-smartparens/body)
|
(define-key smartparens-mode-map (kbd "C-x (") 'hydra-smartparens/body))
|
||||||
))
|
|
||||||
|
:bind (:map smartparens-mode-map
|
||||||
|
;; auto wrapping w/o region
|
||||||
|
( "C-c (" . 'wrap-with-parens)
|
||||||
|
( "C-c [" . 'wrap-with-brackets)
|
||||||
|
( "C-c {" . 'wrap-with-braces)
|
||||||
|
( "C-c '" . 'wrap-with-single-quotes)
|
||||||
|
( "C-c \"" . 'wrap-with-double-quotes)
|
||||||
|
( "C-c `" . 'wrap-with-back-quotes)
|
||||||
|
|
||||||
|
;; modification
|
||||||
|
("C-k" . 'sp-kill-hybrid-sexp)
|
||||||
|
("C-<left>" . 'sp-forward-slurp-sexp)
|
||||||
|
("C-<right>" . 'sp-forward-barf-sexp)
|
||||||
|
|
||||||
|
;; movement
|
||||||
|
;; Also Check: https://github.com/Fuco1/smartparens/wiki/Working-with-expressions
|
||||||
|
;; (look for "quick summary for each navigation function")
|
||||||
|
;;
|
||||||
|
;; Jump after the next balanced expression. If inside one and
|
||||||
|
;; there is no forward exp., jump after its closing pair.
|
||||||
|
("C-M-<right>" . 'sp-forward-sexp)
|
||||||
|
;; Jump before the previous balanced expression. If inside one
|
||||||
|
;; and there is no previous exp., jump before its opening pair.
|
||||||
|
("C-M-<left>" . 'sp-backward-sexp)
|
||||||
|
;; Jump up one level from the current balanced expression. This
|
||||||
|
;; means skipping all the enclosed expressions within this and
|
||||||
|
;; then jumping after the closing pair.
|
||||||
|
("C-M-<up>" . 'sp-up-sexp)
|
||||||
|
;; Jump after the opening pair of next balanced expression. This
|
||||||
|
;; effectively descends one level down in the "expression
|
||||||
|
;; hierarchy". If there is no expression to descend to, jump
|
||||||
|
;; after current expression's opening pair. This can be used to
|
||||||
|
;; quickly navigate to the beginning of current balanced
|
||||||
|
;; expression.
|
||||||
|
("C-M-<down>" . 'sp-down-sexp)
|
||||||
|
;; Jump to the beginning of following balanced expression. If
|
||||||
|
;; there is no following expression on the current level, jump
|
||||||
|
;; one level up backward, effectively doing sp-backward-up-sexp.
|
||||||
|
("C-S-<left>" . 'sp-next-sexp)
|
||||||
|
;; Jump to the end of the previous balanced expression. If there
|
||||||
|
;; is no previous expression on the current level, jupm one level
|
||||||
|
;; up forward, effectively doing sp-up-sexp.
|
||||||
|
("C-S-<right>" . 'sp-previous-sexp)
|
||||||
|
|
||||||
|
;; comment the whole sexp
|
||||||
|
(";" . 'tvd-lisp-comment)
|
||||||
|
|
||||||
|
;; replace my global setting
|
||||||
|
;; FIXME: fhceck/fix M<up+down>!
|
||||||
|
("M-<right>" . 'sp-forward-symbol)
|
||||||
|
("M-<left>" . 'sp-backward-symbol)))
|
||||||
|
|
||||||
;;; Parens config goes here as well
|
;;; Parens config goes here as well
|
||||||
|
|
||||||
|
|||||||
2
init.el
2
init.el
@@ -164,7 +164,7 @@
|
|||||||
'(custom-safe-themes
|
'(custom-safe-themes
|
||||||
'("7f1d414afda803f3244c6fb4c2c64bea44dac040ed3731ec9d75275b9e831fe5" default))
|
'("7f1d414afda803f3244c6fb4c2c64bea44dac040ed3731ec9d75275b9e831fe5" default))
|
||||||
'(package-selected-packages
|
'(package-selected-packages
|
||||||
'(tramp dictcc beacon which-key goto-last-change browse-kill-ring fringe-current-line swiper smex undo-tree fic-mode cmake-mode yaml-mode windresize web-mode use-package tablist solarized-theme smartparens rust-mode projectile persistent-scratch org-bullets markdown-mode magit iedit ibuffer-vc ibuffer-tramp hydra htmlize highlight-indentation go-mode eyebrowse elmacro dumb-jump dired-ranger dired-k dired-filter default-text-scale change-inner buffer-move))
|
'(howm tiny tramp dictcc beacon which-key goto-last-change browse-kill-ring fringe-current-line swiper smex undo-tree fic-mode cmake-mode yaml-mode windresize web-mode use-package tablist solarized-theme smartparens rust-mode projectile persistent-scratch org-bullets markdown-mode magit iedit ibuffer-vc ibuffer-tramp hydra htmlize highlight-indentation go-mode eyebrowse elmacro dumb-jump dired-ranger dired-k dired-filter default-text-scale change-inner buffer-move))
|
||||||
'(safe-local-variable-values '((ruby-indent-level 4)))
|
'(safe-local-variable-values '((ruby-indent-level 4)))
|
||||||
'(warning-suppress-types '((comp))))
|
'(warning-suppress-types '((comp))))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user