Commit cb655bbe authored by Steve Purcell's avatar Steve Purcell

Initial version

parents
*.elc
\ No newline at end of file
paredit-everywhere.el
=====================
It turns out that a lot of the `paredit` key bindings work as
expected in non-lisp buffers, since many major modes provide
reasonable sexp-oriented navigation.
This library, then, provides a minor mode which enables a subset
of the `paredit` library's editing commands in non-lisp buffers.
Installation
=============
If you choose not to use one of the convenient packages in
[Melpa][melpa] and [Marmalade][marmalade], you'll need to add the
directory containing `paredit-everywhere.el` to your `load-path`, and then
`(require 'paredit-everywhere)`.
Usage
=====
Enable the minor mode in non-lisp buffers by adding `paredit-everywhere-mode` to
your mode hooks. In Emacs 24 and greater, `prog-mode-hook` is a great choice:
```lisp
(add-hook 'prog-mode-hook 'paredit-everywhere-mode)
```
Use <kbd>C-h m</kbd> to see which paredit commands are available.
[marmalade]: http://marmalade-repo.org
[melpa]: http://melpa.milkbox.net
<hr>
[![](http://api.coderwall.com/purcell/endorsecount.png)](http://coderwall.com/purcell)
[![](http://www.linkedin.com/img/webpromo/btn_liprofile_blue_80x15.png)](http://uk.linkedin.com/in/stevepurcell)
[Steve Purcell's blog](http://www.sanityinc.com/) // [@sanityinc on Twitter](https://twitter.com/sanityinc)
;;; paredit-everywhere.el --- Enable some paredit features in non-lisp buffers
;; Copyright (C) 2013 Steve Purcell
;; Author: Steve Purcell <steve@sanityinc.com>
;; Keywords: languages, convenience
;; Version: DEV
;; Package-Requires: ((paredit "22"))
;; 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 3 of the License, 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 this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; It turns out that a lot of the paredit key bindings work as
;; expected in non-lisp buffers, since many major modes provide
;; reasonable sexp-oriented navigation.
;; This library, then, provides a minor mode which enables a subset
;; of the `paredit' library's editing commands in non-lisp buffers.
;; Usage:
;;
;; (add-hook 'prog-mode-hook 'paredit-everywhere-mode)
;;; Code:
(require 'paredit)
(defvar paredit-everywhere-mode-map
(let ((m (make-sparse-keymap)))
(define-key m (kbd "C-)") 'paredit-forward-slurp-sexp)
(define-key m (kbd "C-}") 'paredit-forward-barf-sexp)
(define-key m (kbd "M-(") 'paredit-wrap-round)
(define-key m (kbd "M-[") 'paredit-wrap-square)
(define-key m (kbd "M-{") 'paredit-wrap-curly)
(define-key m (kbd "M-)") 'paredit-close-round-and-newline)
(define-key m (kbd "M-]") 'paredit-close-square-and-newline)
(define-key m (kbd "M-}") 'paredit-close-curly-and-newline)
m)
"Keymap for `paredit-everywhere-mode'.")
;;;###autoload
(define-minor-mode paredit-everywhere-mode
"A cut-down version of paredit which can be used in non-lisp buffers."
nil
" Par-"
paredit-everywhere-mode-map)
(defun turn-off-paredit-everywhere-mode ()
"Disable `paredit-everywhere-mode'."
(paredit-everywhere-mode 0))
;; Disable paredit-everywhere when full paredit is enabled
(add-hook 'paredit-mode-hook 'turn-off-paredit-everywhere-mode)
(provide 'paredit-everywhere)
;;; paredit-everywhere.el ends here
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment