Skip to content

tre-flip/atp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 

Repository files navigation

Overview

This package provides:

  • Automatic recognition and highlighting of things at point.
  • Simple integration with existing commands that operate on regions.
  • An interface for writing commands that operate on things.
  • Commands for copying, killing and pasting things as an example of use of this interface.
  • An option to disable the highlighting as soon as the user starts typing. It will be enabled again when the user calls any command apart from self-insert-command.

Inspired by xah-fly-keys, expand-region and objed. Works best when combined with modal text editing. This package is not stable yet. It’s sitll in development, public interface may change.

Motivation

I started working on this package because I was lookig for a new approach that would save me a couple of keystrokes on each common task such as copying and pasting text, evaluation of lisp expressions and shell-commands, changing letter case, etc.

For a year I used a wonderful package “expand-region” for that purpose. Despite it being very smart and useful, it still requires 2 actions to select an object under the point. First, the user must navigate to the desired location, and then call er/expand-region to select an object. I thought that the second step was redundant and decided to write a package that works without it.

User guide

Basics

To enable automatic recognition and highlighting turn on atp-mode. Variable atp-known-commands is a list of commands that are known to atp and can operate of highlighted things. It’s assumed, that each command in this list operates on a marked region of text and deactivates the mark after execution. This variable has the following definition:

	 (defvar atp-known-commands (list 'kill-region 'kill-ring-save))

Customization

As you can see, by default atp works with kill-region and kill-ring-save. So “C-w” or “M-w” will respectively kill or copy the highlighted thing as it was a region. To make a command work with atp in the same way, the user should add it to that list.

If some command expected to keep the region active after its execution, the user must add it to atp-known-repeatable-commands instead.

Disable highlighting conditionally

Variable atp-excluded-modes is a list of major modes in which atp is always disabled.

Variable atp-inhibit-on-self-insert may be set to t to disable highlighting of and operation on things as soon as the user starts typing text. Highlighting will be enabled automatically when the user issues any other command (for example moves the cursor).

Integration with expand region

When the user calls er/expand-region by issuing a keystroke, the highlighted thing will be marked as a region and then er/expand-region will execute, expanding this region. To disable this behavior, remove er/expand-region from atp-known-repeatable-commands:

	(setq atp-known-repeatable-commands
		  (delete 'er/expand-region atp-known-repeatable-commands))

Tasks

  • Use defcustom instead of defvar where possible.
  • Record a demo.
  • Fix atp-toggle-comment.
  • Compatibility with electric-pair. (hard) Implement convenient insertion of pairs around highlighted thing.

About

Auto-thing-at-point for emacs.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published