Skip to content

Commit

Permalink
Auto insersion of closing " (doublequote) in paredit-mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
fukamachi committed Aug 14, 2018
1 parent 745a26b commit 5df7c74
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lem-paredit-mode/paredit-mode.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,22 @@ link : http://www.daregada.sakuraweb.com/paredit_tutorial_ja.html
(character-offset p -1))
(character-offset p -1)))

(define-command paredit-insert-doublequote () ()
(let ((p (current-point)))
(when (eql (character-at p -1) #\\)
(insert-character p #\")
(return-from paredit-insert-doublequote))
(unless (or (eql (character-at p -1) #\Space)
(bolp p))
(insert-character p #\Space))
(dolist (c '(#\" #\"))
(insert-character p c))
(unless (or (eolp p)
(eql (character-at p) #\Space))
(insert-character p #\Space)
(character-offset p -1))
(character-offset p -1)))

(define-command paredit-backward-delete (&optional (n 1)) ("p")
(when (< 0 n)
(with-point ((p (current-point)))
Expand All @@ -68,6 +84,9 @@ link : http://www.daregada.sakuraweb.com/paredit_tutorial_ja.html
(delete-next-char)
(delete-previous-char)))
(#\) (backward-char))
(#\" (when (char= (character-at p 1) #\")
(delete-next-char)
(delete-previous-char)))
(otherwise
(delete-previous-char))))
(paredit-backward-delete (1- n))))
Expand Down Expand Up @@ -151,6 +170,7 @@ link : http://www.daregada.sakuraweb.com/paredit_tutorial_ja.html
(backward-sexp . paredit-backward)
("(" . paredit-insert-paren)
(")" . paredit-close-parenthesis)
("\"" . paredit-insert-doublequote)
(delete-previous-char . paredit-backward-delete)
("C-Right" . paredit-slurp)
("C-Left" . paredit-barf)
Expand Down

0 comments on commit 5df7c74

Please sign in to comment.