(try) to fix closing paren functions

This commit is contained in:
2023-06-08 08:25:51 +02:00
parent 0892d743ef
commit 429a503dc0

View File

@@ -42,7 +42,8 @@ Used when enabling smartparens-mode."
;; 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)
(setq sp-ignore-modes-list (setq sp-ignore-modes-list
(delete 'minibuffer-inactive-mode sp-ignore-modes-list)) (delete 'minibuffer-inactive-mode sp-ignore-modes-list)
sp-navigate-close-if-unbalanced t)
;; automatically enable where needed ;; automatically enable where needed
(add-something-to-mode-hooks (add-something-to-mode-hooks
@@ -50,8 +51,8 @@ Used when enabling smartparens-mode."
;; TODO: https://github.com/Fuco1/smartparens/issues/1160#event-9374528894 ;; TODO: https://github.com/Fuco1/smartparens/issues/1160#event-9374528894
;; try to find a way around the problem of closing paren below. ;; try to find a way around the problem of closing paren below.
(add-something-to-mode-hooks ;; (add-something-to-mode-hooks
'(emacs-lisp ielm lisp elisp lisp-interaction scheme slime-repl ) 'electric-pair-mode) ;; '(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
@@ -91,6 +92,21 @@ 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)
(defun tvd-insert-paren-or-close-move-up ()
"First hitting key (closing paren) executes 'sp-up-sexp, next time hitting
it, insert a closing paren. Requires viking mode to be installed."
(interactive)
(let* ((key-times (viking-last-key-repeats)))
(cond
((> key-times 1)
(progn
(message "inserting )")
(insert ")")))
((eq key-times 1)
(progn
(message "sp-up-sexp")
(call-interactively #'sp-up-sexp))))))
(when (fboundp 'defhydra) (when (fboundp 'defhydra)
(defhydra hydra-smartparens (:hint nil) (defhydra hydra-smartparens (:hint nil)
" "
@@ -196,9 +212,8 @@ _k_: kill (C-k) _s_: split _{_: wrap with { }
;; comment the whole sexp ;; comment the whole sexp
(";" . 'tvd-lisp-comment) (";" . 'tvd-lisp-comment)
;; move up closing parens unable to insert parens ;; move up closing parens or insert closing paren
;; everywhere else, especially if one is missing! (")" (")" . #'tvd-insert-paren-or-close-move-up)
;; . #'sp-up-sexp)
;; replace my global setting ;; replace my global setting
;; FIXME: fhceck/fix M<up+down>! ;; FIXME: fhceck/fix M<up+down>!