From 901acb8a614c9f309365d933889e7433bed1ee90 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Sun, 28 Sep 2008 13:41:20 +0000 Subject: Changes for version 16. - Introduced M-S (paredit-split-sexp) to split lists or strings from the middle. - Fixed the definition of M-; to use (kbd "M-;") to correctly identify the key sequence meta-semicolon, not "M-;" for M hyphen semicolon. darcs-hash:20080928134120-00fcc-f3d0c5f1318c5cc1c4de78c69666bbc126f305fd --- paredit.el | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/paredit.el b/paredit.el index a887893..4fb7f0c 100644 --- a/paredit.el +++ b/paredit.el @@ -1,7 +1,7 @@ ;;; -*- mode: emacs-lisp -*- ;;;;;; paredit: Parenthesis editing minor mode -;;;;;; Version 15 +;;;;;; Version 16 ;;; This code is written by Taylor Campbell (except where explicitly ;;; noted) and placed in the Public Domain. All warranties are @@ -66,7 +66,7 @@ ;;; This assumes Unix-style LF line endings. -(defconst paredit-version 15) +(defconst paredit-version 16) @@ -86,7 +86,7 @@ (define-key keymap "\"" 'paredit-doublequote) (define-key keymap "\\" 'paredit-backslash) (define-key keymap ";" 'paredit-semicolon) - (define-key keymap "M-;" 'paredit-comment-dwim) + (define-key keymap (kbd "M-;") 'paredit-comment-dwim) ;; This defies ordinary conventions, but I believe it is justified ;; and more convenient this way, to have RET be fancy and C-j @@ -139,7 +139,8 @@ (define-key keymap (kbd "C-}") 'paredit-forward-barf-sexp) (define-key keymap (kbd "C-(") 'paredit-backward-slurp-sexp) (define-key keymap (kbd "C-{") 'paredit-backward-barf-sexp) - + (define-key keymap (kbd "M-S") 'paredit-split-sexp) + keymap) "Keymap for the paredit minor mode. Does not work in `emacs -nw' running under Unix terminals, only in @@ -777,6 +778,7 @@ forward past the S-expression following the point." (interactive) (condition-case () (forward-sexp) + ;++ Is it necessary to use UP-LIST and not just FORWARD-CHAR? (scan-error (if (paredit-in-string-p) (forward-char) (up-list))))) (defun paredit-backward () @@ -1043,6 +1045,27 @@ it was barfed." (indent-sexp)) (goto-char beg)))) +(defun paredit-split-sexp () + "Splits the list or string the point is on into two." + (interactive) + (cond ((paredit-in-string-p) + (delete-horizontal-space) + (insert "\"") + (save-excursion (insert " \""))) + ((or (paredit-in-comment-p) + (paredit-in-char-p)) + (error "Invalid context for `paredit-split-sexp'")) + (t (let ((open (save-excursion (backward-up-list) + (char-after))) + (close (save-excursion (up-list) + (char-before)))) + (delete-horizontal-space) + (insert close) + (save-excursion (insert ?\ ) + (insert open) + (backward-char) + (indent-sexp)))))) + ;;; ---------------- -- cgit v1.2.1