summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLev Lamberov <dogsleg@debian.org>2017-06-20 05:03:24 -0300
committerLev Lamberov <dogsleg@debian.org>2017-06-20 05:03:24 -0300
commitb56c7ff788af105bca6f974c1cc0193832341f7e (patch)
tree6c8eebdd0ddd8d76b7c557f66a2e8009805ffaa3
Import zzz-to-char_0.1.2.orig.tar.gz
[dgit import orig zzz-to-char_0.1.2.orig.tar.gz]
-rw-r--r--.gitignore3
-rw-r--r--.travis.yml35
-rw-r--r--Cask7
-rw-r--r--README.md37
-rw-r--r--zzz-to-char.el105
5 files changed, 187 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..525381d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+*-autoloads.el
+*.elc
+*~
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..6ba545c
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,35 @@
+env:
+ matrix:
+ - EMACS=emacs24
+ - EMACS=emacs-snapshot
+
+matrix:
+ allow_failures:
+ - env: EMACS=emacs-snapshot
+
+before_install:
+ - git submodule --quiet update --init --recursive
+
+install:
+ - if [ "$EMACS" = 'emacs24' ]; then
+ sudo add-apt-repository -y ppa:cassou/emacs &&
+ sudo apt-get -qq update &&
+ sudo apt-get -qq -f install &&
+ sudo apt-get -qq install emacs24 emacs24-el;
+ fi
+ - if [ "$EMACS" = 'emacs-snapshot' ]; then
+ sudo add-apt-repository -y ppa:ubuntu-elisp/ppa &&
+ sudo apt-get -qq update &&
+ sudo apt-get -qq -f install &&
+ sudo apt-get -qq install emacs-snapshot &&
+ sudo apt-get -qq install emacs-snapshot-el;
+ fi
+ - curl -fsSkL https://raw.github.com/cask/cask/master/go | python
+ - export PATH="/home/travis/.cask/bin:$PATH"
+ - cask install
+
+script:
+ - cask build
+
+notifications:
+ email: false
diff --git a/Cask b/Cask
new file mode 100644
index 0000000..967612d
--- /dev/null
+++ b/Cask
@@ -0,0 +1,7 @@
+(source gnu)
+(source melpa)
+
+(package-file "zzz-to-char.el")
+
+(development
+ (depends-on "avy"))
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..c3712a6
--- /dev/null
+++ b/README.md
@@ -0,0 +1,37 @@
+# Zzz to Char
+
+[![License GPL 3](https://img.shields.io/badge/license-GPL_3-green.svg)](http://www.gnu.org/licenses/gpl-3.0.txt)
+[![MELPA](https://melpa.org/packages/zzz-to-char-badge.svg)](https://melpa.org/#/zzz-to-char)
+[![Build Status](https://travis-ci.org/mrkkrp/zzz-to-char.svg?branch=master)](https://travis-ci.org/mrkkrp/zzz-to-char)
+
+This package provides two new commands: `zzz-to-char` and `zzz-up-to-char`
+which work like built-ins `zap-to-char` and `zap-up-to-char`, but allow you
+quickly select exact character you want to “zzz” to.
+
+The commands are minimalistic and often work like built-in ones when there
+is only one occurrence of the target character (except they automatically
+work in backward direction too). You can also specify how many characters to
+scan from each side of point, see `zzz-to-char-reach`.
+
+## Installation
+
+Download this package and place it somewhere, so Emacs can see it. Then put
+`(require 'zzz-to-char)` into your configuration file. Done!
+
+To install the package via MELPA, execute: <kbd>M-x package-install RET
+zzz-to-char RET</kbd>.
+
+## Usage
+
+Just bind `zzz-to-char` or `zzz-up-to-char` (depends on your taste, the
+latter doesn't include target char into killed text):
+
+```emacs-lisp
+(global-set-key (kbd "M-z") #'zzz-to-char)
+```
+
+## License
+
+Copyright © 2015–2017 Mark Karpov
+
+Distributed under GNU GPL, version 3.
diff --git a/zzz-to-char.el b/zzz-to-char.el
new file mode 100644
index 0000000..7b62644
--- /dev/null
+++ b/zzz-to-char.el
@@ -0,0 +1,105 @@
+;;; zzz-to-char.el --- Fancy version of `zap-to-char' command -*- lexical-binding: t; -*-
+;;
+;; Copyright © 2015–2017 Mark Karpov <markkarpov92@gmail.com>
+;;
+;; Author: Mark Karpov <markkarpov92@gmail.com>
+;; URL: https://github.com/mrkkrp/zzz-to-char
+;; Version: 0.1.2
+;; Package-Requires: ((emacs "24.4") (cl-lib "0.5")(avy "0.3.0"))
+;; Keywords: convenience
+;;
+;; This file is not part of GNU 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 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:
+
+;; This package provides two new commands: `zzz-to-char' and
+;; `zzz-up-to-char' which work like built-ins `zap-to-char' and
+;; `zap-up-to-char', but allow you quickly select exact character you want
+;; to “zzz” to.
+;;
+;; The commands are minimalistic and often work like built-in ones when
+;; there is only one occurrence of target character (except they
+;; automatically work in backward direction too). You can also specify how
+;; many characters to scan from each side of point, see `zzz-to-char-reach'.
+
+;;; Code:
+
+(require 'avy)
+(require 'cl-lib)
+
+(defgroup zzz-to-char nil
+ "Fancy version of `zap-to-char' command."
+ :group 'convenience
+ :tag "Zzz to Char"
+ :prefix "zzz-to-char-"
+ :link '(url-link :tag "GitHub" "https://github.com/mrkkrp/zzz-to-char"))
+
+(defcustom zzz-to-char-reach 80
+ "Number of characters to scan on each side of the point."
+ :tag "How many characters to scan"
+ :type 'integer)
+
+(defun zzz-to-char--base (char n-shift)
+ "Kill text between the point and character CHAR.
+
+Boundary of text to kill that doesn't coincide with point
+position can be shifted with help of N-SHIFT argument.
+
+This is an internal function, see also `zzz-to-char' and
+`zzz-up-to-char'."
+ (let ((p (point))
+ (avy-all-windows nil))
+ (avy-with zzz-to-char
+ (avy--generic-jump
+ (if (= 13 char)
+ "\n"
+ (regexp-quote (string char)))
+ nil
+ avy-style
+ (max (- p zzz-to-char-reach)
+ (point-min))
+ (min (+ p zzz-to-char-reach)
+ (point-max))))
+ (let ((n (point)))
+ (when (/= n p)
+ (cl-destructuring-bind (beg . end)
+ (if (> n p)
+ (cons p (- (1+ n) n-shift))
+ (cons (+ n n-shift) p))
+ (goto-char end)
+ (kill-region beg end))))))
+
+;;;###autoload
+(defun zzz-to-char (char)
+ "Kill text between the point and the character CHAR.
+
+This command is similar to `zap-to-char', it kills target
+character too."
+ (interactive (list (read-char "Zzz to: " t)))
+ (zzz-to-char--base char 0))
+
+;;;###autoload
+(defun zzz-up-to-char (char)
+ "Kill text between the point and the character CHAR.
+
+This command is similar to `zap-up-to-char', it doesn't kill
+target character."
+ (interactive (list (read-char "Zzz up to: " t)))
+ (zzz-to-char--base char 1))
+
+(provide 'zzz-to-char)
+
+;;; zzz-to-char.el ends here