Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrating existing forks + adding named functions #36

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.markdown → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ wraps with tags.
[<img src="http://img.youtube.com/vi/9SWAKPF0fHE/0.jpg">](https://www.youtube.com/watch?v=9SWAKPF0fHE)

## Installation
I recommend installing via ELPA, but manual installation is simple as well:
~~I recommend installing via ELPA, but manual installation is simple as well:~~

Clone this repository and install manually:

(add-to-list 'load-path "/path/to/wrap-region")
(require 'wrap-region)
Expand Down Expand Up @@ -62,7 +64,7 @@ To add a new mode, do this:
Contribution is much welcome! Wrap region is tested using [Ecukes](http://ecukes.info). When
adding new features, please write tests for them!

Install [cask](https://github.com/rejeep/cask.el) if you haven't
Install [cask](https://github.com/cask/cask) if you haven't
already, then:

$ cd /path/to/wrap-region
Expand Down
23 changes: 13 additions & 10 deletions wrap-region.el
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
;; Author: Johan Andersson <[email protected]>
;; Maintainer: Johan Andersson <[email protected]>
;; Version: 0.7.3
;; Package-Version: 20140117.720
;; Package-Commit: fbae9b0f106187af19823f1a6260b5c68b7252e6
;; Keywords: speed, convenience
;; URL: http://github.com/rejeep/wrap-region
;; Package-Requires: ((dash "1.0.3"))
Expand Down Expand Up @@ -79,9 +81,9 @@
(require 'edmacro)
(require 'dash)
(eval-when-compile
(require 'cl))
(require 'cl-lib))

(defstruct wrap-region-wrapper key left right modes)
(cl-defstruct wrap-region-wrapper key left right modes)

(defgroup wrap-region nil
"Wrap region with delimiters."
Expand Down Expand Up @@ -199,7 +201,7 @@ If nil, always wrap the region."
(insert left)
(goto-char (+ end (length left)))
(insert right))
(if (= pos end) (forward-char 1))
(if (= pos end) (forward-char (length right)))
(if wrap-region-keep-mark
(let* ((beg-p (eq beg pos))
(beg* (+ beg (length left)))
Expand Down Expand Up @@ -300,7 +302,7 @@ If MODE-OR-MODES is not present, all wrappers for KEY are removed."
(wrap-region-unset-key key))

(defun wrap-region-define-wrappers ()
"Defines defaults wrappers."
"Define default wrappers."
(mapc
(lambda (pair)
(apply 'wrap-region-add-wrapper pair))
Expand All @@ -312,12 +314,13 @@ If MODE-OR-MODES is not present, all wrappers for KEY are removed."
("<" ">"))))

(defun wrap-region-define-trigger (key)
"Defines KEY as wrapper."
(wrap-region-define-key
key
`(lambda (arg)
(interactive "p")
(wrap-region-trigger arg ,key))))
"Define KEY as wrapper."
(let ((func-name (intern (concat "wrap-region-trigger-" key))))
(fset func-name
`(lambda (arg)
(interactive "p")
(wrap-region-trigger arg ,key)))
(wrap-region-define-key key func-name)))

(defun wrap-region-unset-key (key)
"Remove KEY from `wrap-region-mode-map'."
Expand Down