From bcd1d90b2280f93ed139e4aa82838a8e62a4bac9 Mon Sep 17 00:00:00 2001 From: Kevin Liu Date: Sat, 23 May 2015 04:17:13 -0700 Subject: [PATCH] Cleanup and mark as stable release --- README.org | 22 ++++++++++------------ corral.el | 50 ++++++++++++++++++++++++-------------------------- 2 files changed, 34 insertions(+), 38 deletions(-) diff --git a/README.org b/README.org index a8849c2..8e64dbd 100644 --- a/README.org +++ b/README.org @@ -1,10 +1,8 @@ [[http://melpa.org/#/corral][file:http://melpa.org/packages/corral-badge.svg]] * Corral -** What it is -A lightweight set of commands that enable you to quickly wrap parentheses, brackets, quotes, and other delimiters around text. +Corral is a lightweight set of commands that enable you to quickly wrap parentheses, brackets, quotes, and other delimiters around text. -** What it isn't -A replacement to a fully-featured structural editing mode for lisp, such as paredit. Corral prioritizes speed and simplicity, and should work for any language. +It is not meant to be a replacement to lisp structural editing modes such as paredit. Corral emphasizes speed and simplicity, and should work for any language. ** Examples [[./corral-example-c.gif]] \\ @@ -18,14 +16,7 @@ Corral can be found on melpa, and should be installed from there. To install it #+END_SRC ** Usage -Call a command once to wrap the delimiters around the sexp at point. Repeated calls of the same command, backward or forward, will shift the delimiters in the respective direction, corralling more text. - -The wrapping algorithm tries to operate on these principles: -- If the point is over a word, it will always wrap around that word. -- Otherwise, =backward= and =forward= commands should have different effects. -- Symbols will not be directly corraled. - -If there are any discrepancies, feel free to report it on the issue tracker. +Call a command once to wrap delimiters around the sexp at point. Repeated calls of the same command, backward or forward, will shift the delimiters in the respective direction, corralling more text. To use these commands, just bind them to keys of your choosing. Here are some example keybindings: #+BEGIN_SRC emacs-lisp @@ -37,6 +28,13 @@ To use these commands, just bind them to keys of your choosing. Here are some e (global-set-key (kbd "M-}") 'corral-braces-forward) (global-set-key (kbd "M-\"") 'corral-double-quotes-backward) #+END_SRC + +The wrapping algorithm tries to follow these rules: +- If the point is over a word, it will always wrap around that word. +- Otherwise, =backward= and =forward= commands should have different effects. + +You can tweak how the wrapping works by modifying the syntax table through =corral-syntax-entries= (see [[https://github.com/nivekuil/corral#configure-how-corral-handles-punctuationsymbols][Settings]]). + ** Settings *** Keep point position instead of following delimiters This is controlled by the variable =corral-preserve-point=, which can be set manually or through customize. diff --git a/corral.el b/corral.el index b624f5f..e441495 100644 --- a/corral.el +++ b/corral.el @@ -4,9 +4,7 @@ ;; Author: Kevin Liu ;; Created: 16 May 2015 ;; Homepage: http://github.com/nivekuil/corral -;; Version: 0.1.8 - -;; This file is not part of GNU Emacs. +;; Version: 0.2 ;; 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 @@ -23,11 +21,11 @@ ;;; Commentary: -;; This package contains functions that incrementally wrap (or "corral") -;; s-expressions with delimiters, such as parentheses and brackets. -;; After calling one of the interactive commands, repeated calls will shift -;; the corral instead of inserting new delimiters, expanding the amount of -;; text contained within the delimiters. +;; This package adds commands that allow the user to quickly and intuitively +;; wrap a desired amount of text within delimiters, including parentheses and +;; quotes. After calling one of the interactive commands, repeated calls will +;; shift the corral instead of inserting new delimiters, expanding the amount +;; of text contained within the delimiters. ;;; Code: @@ -109,8 +107,8 @@ You can also use 'add-to-list', like this: (corral-shift-backward open close)) (corral-wrap-backward open close))) (setq corral--virtual-point (point)))) - (unless corral-preserve-point - (goto-char corral--virtual-point))) + (unless corral-preserve-point + (goto-char corral--virtual-point))) (defun corral-command-forward (open close backward forward) "Handle command with OPEN and CLOSE from commands BACKWARD and FORWARD." @@ -128,8 +126,8 @@ You can also use 'add-to-list', like this: (corral-shift-forward open close)) (corral-wrap-forward open close))) (setq corral--virtual-point (point)))) - (unless corral-preserve-point - (goto-char corral--virtual-point))) + (unless corral-preserve-point + (goto-char corral--virtual-point))) ;;;###autoload @@ -137,8 +135,8 @@ You can also use 'add-to-list', like this: "Wrap parentheses around sexp, moving point to the closing parentheses." (interactive) (corral-command-backward ?( ?) - 'corral-parentheses-backward - 'corral-parentheses-forward)) + 'corral-parentheses-backward + 'corral-parentheses-forward)) ;;;###autoload (defun corral-parentheses-forward () @@ -153,8 +151,8 @@ You can also use 'add-to-list', like this: "Wrap brackets around sexp, moving point to the opening bracket." (interactive) (corral-command-backward ?[ ?] - 'corral-brackets-backward - 'corral-brackets-forward)) + 'corral-brackets-backward + 'corral-brackets-forward)) ;;;###autoload (defun corral-brackets-forward () @@ -177,16 +175,8 @@ You can also use 'add-to-list', like this: "Wrap brackets around sexp, moving point to the closing bracket." (interactive) (corral-command-forward ?{ ?} - 'corral-braces-backward - 'corral-braces-forward)) - -;;;###autoload -(defun corral-double-quotes-forward () - "Wrap double quotes around sexp, moving point to the closing double quote." - (interactive) - (corral-command-forward ?\" ?\" - 'corral-double-quotes-backward - 'corral-double-quotes-forward)) + 'corral-braces-backward + 'corral-braces-forward)) ;;;###autoload (defun corral-double-quotes-backward () @@ -196,6 +186,14 @@ You can also use 'add-to-list', like this: 'corral-double-quotes-backward 'corral-double-quotes-forward)) +;;;###autoload +(defun corral-double-quotes-forward () + "Wrap double quotes around sexp, moving point to the closing double quote." + (interactive) + (corral-command-forward ?\" ?\" + 'corral-double-quotes-backward + 'corral-double-quotes-forward)) + (provide 'corral) ;;; corral.el ends here