zzz-to-char-1.0.0/0000755000175000017500000000000014437660716013550 5ustar dogslegdogslegzzz-to-char-1.0.0/zzz-to-char.el0000644000175000017500000000657514437660716016277 0ustar dogslegdogsleg;;; zzz-to-char.el --- Fancy version of `zap-to-char' command -*- lexical-binding: t; -*- ;; ;; Copyright © 2015–present Mark Karpov ;; ;; Author: Mark Karpov ;; URL: https://github.com/mrkkrp/zzz-to-char ;; Version: 1.0.0 ;; Package-Requires: ((emacs "24.4") (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 . ;;; Commentary: ;; This package provides two new commands: `zzz-to-char' and ;; `zzz-up-to-char' which work like the built-ins `zap-to-char' and ;; `zap-up-to-char', but allow the user to quickly select the exact ;; character they want to zzz to. The commands work like the built-ins when ;; there is only one occurrence of the target character, excepting that they ;; automatically work in the backward direction, too. One can specify how ;; many characters to scan from each side of the point, see ;; `zzz-to-char-reach'. ;;; Code: (require 'avy) (require 'cl-lib) (defgroup zzz-to-char nil "A 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 the character CHAR. Boundary of text to kill that doesn't coincide with point position can be shifted with help of the 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-jump (if (= 13 char) "\n" (regexp-quote (string char))) :window-flip nil :beg (max (- p zzz-to-char-reach) (point-min)) :end (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 the target character too." (interactive (list (read-char "Zzz to: " t))) (zzz-to-char--base char 0)) ;;;###autoload (defun zzz-to-char-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 the 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 zzz-to-char-1.0.0/README.md0000644000175000017500000000260614437660716015033 0ustar dogslegdogsleg# 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) ![CI](https://github.com/mrkkrp/zzz-to-char/workflows/CI/badge.svg?branch=master) This package provides two new commands: `zzz-to-char` and `zzz-up-to-char` which work like the built-ins `zap-to-char` and `zap-up-to-char`, but allow the user to quickly select the exact character they want to zzz to. The commands work like the built-ins when there is only one occurrence of the target character, excepting that they automatically work in the backward direction, too. One can specify how many characters to scan from each side of the point, see `zzz-to-char-reach`. ## Installation The package is available via MELPA, so you can just type `M-x package-install RET zzz-to-char RET`. If you would like to install the package manually, download or clone it and put on Emacs' `load-path`. Then you can require it in your init file like this: ```emacs-lisp (require 'zzz-to-char) ``` ## Usage Just bind `zzz-to-char` or `zzz-to-char-up-to-char` (depends on your taste, the latter doesn't include the target char into the killed text): ```emacs-lisp (global-set-key (kbd "M-z") #'zzz-to-char) ``` ## License Copyright © 2015–present Mark Karpov Distributed under GNU GPL, version 3. zzz-to-char-1.0.0/flake.nix0000644000175000017500000000037114437660716015353 0ustar dogslegdogsleg{ inputs = { emacs-package-flake.url = "github:mrkkrp/emacs-package-flake"; }; outputs = { self, emacs-package-flake }: emacs-package-flake.lib.mkOutputs { name = "zzz-to-char"; srcDir = ./.; deps = ["avy"]; }; } zzz-to-char-1.0.0/flake.lock0000644000175000017500000000371114437660716015506 0ustar dogslegdogsleg{ "nodes": { "emacs-package-flake": { "inputs": { "flake-utils": "flake-utils", "nixpkgs": "nixpkgs" }, "locked": { "lastModified": 1686064298, "narHash": "sha256-AmhZ5UPCdEyUuYCKuNuga59YDNJmyyjImYc/J5wo4vE=", "owner": "mrkkrp", "repo": "emacs-package-flake", "rev": "ffeea4f1aa7d32eb09e53772e183f73ebda72cfd", "type": "github" }, "original": { "owner": "mrkkrp", "repo": "emacs-package-flake", "type": "github" } }, "flake-utils": { "inputs": { "systems": "systems" }, "locked": { "lastModified": 1685518550, "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", "owner": "numtide", "repo": "flake-utils", "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", "type": "github" }, "original": { "owner": "numtide", "repo": "flake-utils", "type": "github" } }, "nixpkgs": { "locked": { "lastModified": 1685931219, "narHash": "sha256-8EWeOZ6LKQfgAjB/USffUSELPRjw88A+xTcXnOUvO5M=", "owner": "NixOS", "repo": "nixpkgs", "rev": "7409480d5c8584a1a83c422530419efe4afb0d19", "type": "github" }, "original": { "id": "nixpkgs", "ref": "nixos-unstable", "type": "indirect" } }, "root": { "inputs": { "emacs-package-flake": "emacs-package-flake" } }, "systems": { "locked": { "lastModified": 1681028828, "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", "owner": "nix-systems", "repo": "default", "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", "type": "github" }, "original": { "owner": "nix-systems", "repo": "default", "type": "github" } } }, "root": "root", "version": 7 }