Skip to content
Browse files

Factor out my paredit functions to paredit-ext

  • Loading branch information...
1 parent c47a6be commit b00814d2cbbf07c2ae2b81ae16523c992a71c98b @jwiegley committed Jul 3, 2012
Showing with 104 additions and 66 deletions.
  1. +1 −66 init.el
  2. +103 −0 lisp/paredit-ext.el
View
67 init.el
@@ -2670,74 +2670,9 @@ end tell" account account start duration commodity (if cleared "true" "false")
(use-package paredit
:commands paredit-mode
- :diminish paredit-mode
- :init
- (progn
- (defun mark-containing-sexp ()
- (interactive)
- (paredit-backward-up)
- (mark-sexp))
-
- (defun paredit-barf-all-the-way-backward ()
- (interactive)
- (paredit-split-sexp)
- (paredit-backward-down)
- (paredit-splice-sexp))
-
- (defun paredit-barf-all-the-way-forward ()
- (interactive)
- (paredit-split-sexp)
- (paredit-forward-down)
- (paredit-splice-sexp)
- (if (eolp) (delete-horizontal-space)))
-
- (defun paredit-slurp-all-the-way-backward ()
- (interactive)
- (catch 'done
- (while (not (bobp))
- (save-excursion
- (paredit-backward-up)
- (if (eq (char-before) ?\()
- (throw 'done t)))
- (paredit-backward-slurp-sexp))))
-
- (defun paredit-slurp-all-the-way-forward ()
- (interactive)
- (catch 'done
- (while (not (eobp))
- (save-excursion
- (paredit-forward-up)
- (if (eq (char-after) ?\))
- (throw 'done t)))
- (paredit-forward-slurp-sexp)))))
:diminish paredit-mode
:config
- (progn
- (nconc paredit-commands
- '("Extreme Barfage & Slurpage"
- (("C-M-)")
- paredit-slurp-all-the-way-forward
- ("(foo (bar |baz) quux zot)"
- "(foo (bar |baz quux zot))")
- ("(a b ((c| d)) e f)"
- "(a b ((c| d)) e f)"))
- (("C-M-}")
- paredit-barf-all-the-way-forward
- ("(foo (bar |baz quux) zot)"
- "(foo (bar|) baz quux zot)"))
- (("C-M-(")
- paredit-slurp-all-the-way-backward
- ("(foo bar (baz| quux) zot)"
- "((foo bar baz| quux) zot)")
- ("(a b ((c| d)) e f)"
- "(a b ((c| d)) e f)"))
- (("C-M-{")
- paredit-barf-all-the-way-backward
- ("(foo (bar baz |quux) zot)"
- "(foo bar baz (|quux) zot)"))))
-
- (paredit-define-keys)
- (paredit-annotate-mode-with-examples)
+ (progn
(use-package paredit-ext)
(add-hook 'allout-mode-hook
View
103 lisp/paredit-ext.el
@@ -0,0 +1,103 @@
+;;; paredit-ext --- Extra functions for paredit
+
+;; Copyright (C) 2012 John Wiegley
+
+;; Author: John Wiegley <jwiegley@gmail.com>
+;; Created: 03 Jul 2012
+;; Version: 1.0
+;; Keywords: paredit lisp
+;; X-URL: https://github.com/jwiegley/dot-emacs
+
+;; This program is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation; either version 2, or (at
+;; your option) any later version.
+
+;; This program is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING. If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+
+;; These commands are ones that I use very often.
+
+(require 'paredit)
+
+(defgroup paredit-ext nil
+ "Extra functions for paredit"
+ :group 'paredit)
+
+(defun mark-containing-sexp ()
+ (interactive)
+ (paredit-backward-up)
+ (mark-sexp))
+
+(defun paredit-barf-all-the-way-backward ()
+ (interactive)
+ (paredit-split-sexp)
+ (paredit-backward-down)
+ (paredit-splice-sexp))
+
+(defun paredit-barf-all-the-way-forward ()
+ (interactive)
+ (paredit-split-sexp)
+ (paredit-forward-down)
+ (paredit-splice-sexp)
+ (if (eolp) (delete-horizontal-space)))
+
+(defun paredit-slurp-all-the-way-backward ()
+ (interactive)
+ (catch 'done
+ (while (not (bobp))
+ (save-excursion
+ (paredit-backward-up)
+ (if (eq (char-before) ?\()
+ (throw 'done t)))
+ (paredit-backward-slurp-sexp))))
+
+(defun paredit-slurp-all-the-way-forward ()
+ (interactive)
+ (catch 'done
+ (while (not (eobp))
+ (save-excursion
+ (paredit-forward-up)
+ (if (eq (char-after) ?\))
+ (throw 'done t)))
+ (paredit-forward-slurp-sexp))))
+
+(nconc paredit-commands
+ '("Extreme Barfage & Slurpage"
+ (("C-M-)")
+ paredit-slurp-all-the-way-forward
+ ("(foo (bar |baz) quux zot)"
+ "(foo (bar |baz quux zot))")
+ ("(a b ((c| d)) e f)"
+ "(a b ((c| d)) e f)"))
+ (("C-M-}")
+ paredit-barf-all-the-way-forward
+ ("(foo (bar |baz quux) zot)"
+ "(foo (bar|) baz quux zot)"))
+ (("C-M-(")
+ paredit-slurp-all-the-way-backward
+ ("(foo bar (baz| quux) zot)"
+ "((foo bar baz| quux) zot)")
+ ("(a b ((c| d)) e f)"
+ "(a b ((c| d)) e f)"))
+ (("C-M-{")
+ paredit-barf-all-the-way-backward
+ ("(foo (bar baz |quux) zot)"
+ "(foo bar baz (|quux) zot)"))))
+
+(paredit-define-keys)
+(paredit-annotate-mode-with-examples)
+(paredit-annotate-functions-with-examples)
+
+(provide 'paredit-ext)
+
+;;; paredit-ext.el ends here

0 comments on commit b00814d

Please sign in to comment.
Something went wrong with that request. Please try again.