Giter Site home page Giter Site logo

interactive-align's Introduction

ialign.el

https://melpa.org/packages/ialign-badge.svg

Emacs package that provides visual version of align-regexp command.

./demo.gif

Table of contents

Installation

From melpa

This package is available from melpa, just do M-x package-install RET ialign RET. Bind the main function with:

(global-set-key (kbd "C-x l") #'ialign)

Manual

Put path to file ialign.el somewhere in your load-path, then

(require 'ialign)
(global-set-key (kbd "C-x l") #'ialign)

You can also bind it to different key ((kbd "your-key")).

Additional packages

If you have an optional package - pcre2el - installed, you can use PCRE regexps for alignment.

Usage

To use it, mark a region and then call ialign. You can enter a regexp in the minibuffer that will be passed to align-regexp command. As the contents of minibuffer change, the region is realigned. You can also specify other arguments to align-regexp:

  • Increment/decrement spacing (padding) with C-c - and C-c +
  • Increment/decrement the parenthesis group which will be modified with C-c [ and C-c ] Negative parenthesis group means justify (prepend space to each group).
  • Repeat the alignment throughout the line with C-c C-r.
  • Toggle tabs with C-c C-t.
  • Toggle case sensitivity with C-c M-c.
  • Go to next/previous history element with M-n and M-p.

Commands

(ialign BEG END &optional REGEXP GROUP SPACING REPEAT)

Interactively align region BEG END using regexp read from minibuffer.

As characters are typed in the minibuffer, the region is aligned using align-regexp and the result is presented to the user.

In the minibuffer, ialign-minibuffer-keymap is the active keymap.

(ialign-toggle-repeat)

Toggle repeat argument passed to align-regexp.

When the repeat argument is non-nil, the alignment is repeated throughout the line.

(ialign-toggle-tabs)

Toggle tab usage during alignment.

(ialign-toggle-case-fold)

Toggle case-fold searching on or off.

(ialign-toggle-pcre-mode)

Toggle PCRE input mode. With that, the input is treated as a PCRE regexp, and is implicitly converted to elisp regexp implicitly during alignment. This requires the pcre2el library.

(ialign-set-group GROUP)

Set the parenthesis group argument for the align-regexp command to GROUP.

Interactively, this will read GROUP from minibuffer.

(ialign-increment-group), (ialign-decrement-group)

Increment/decrement the parenthesis group argument passed to align-regexp.

(ialign-set-spacing SPACING)

Set the spacing parameter passed to align-regexp command to SPACING.

Interactively, this will read SPACING from minibuffer.

(ialign-increment-spacing), (ialign-decrement-spacing)

Increment/decrement the amount of spacing passed to align-regexp command.

(ialign-commit)

Align the region using the current regexp and commit change in the buffer.

The region is aligned using the current regexp only if it’s valid. Next alignments will use the newly aligned region.

(ialign-show-help)

Describe available keybindings to the user.

Options

ialign-minibuffer-keymap

Keymap used in the minibuffer when ialign command is executed.

KeyCommand
C-c C-rialign-toggle-repeat
C-c C-tialign-toggle-tabs
C-c M-cialign-toggle-case-fold
C-c C-pialign-toggle-pcre-mode
C-c +ialign-increment-spacing
C-c -ialign-decrement-spacing
C-c [ialign-decrement-group
C-c ]ialign-increment-group
C-c C-fialign-set-group
C-c C-sialign-set-spacing
C-c RETialign-commit
C-c C-cialign-update
C-c ?ialign-show-help

ialign-default-spacing

An integer that represents the default amount of padding to use.

The default value is the same as align-default-spacing.

Alias: ialign-initial-spacing.

ialign-align-with-tabs

A value that says when the region should be aligned with tabs.

  • If it’s nil, never use tabs.
  • If it’s t, always use tabs.
  • If it’s the symbol ‘indent-tabs-mode, use value of variable indent-tabs-mode.

The dafault value is nil.

ialign-auto-update

A value that says when to align the region as the characters are typed.

  • If it is nil, never update (you can manually update with ialign-update).
  • If it is t, always update.
  • If it is an integer, update if the number of lines in the region is less than or equal to this, otherwise do not update.

The default value is t.

ialign-initial-regexp

String, initial regexp to use when calling ialign.

The default value is \\(\\s-+\\).

ialign-initial-group

Initial group to use when calling ialign.

The default value is 1.

ialign-initial-repeat

Default state of repeat argument passed to align-regexp.

The default value is nil.

ialign-implicit-regexp

String to prepend to the regexp, if the regex doesn’t have a subgroup.

Set this to \\(\\s-*\\) to implicitly prepend that string to the regexp, if the regexp doesn’t contain a subgroup expression.

The default value is nil.

ialign-pcre-mode

If non-nil, enable PCRE mode when calling ialign, as if by calling ialign-toggle-pcre-mode.

License

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/.

interactive-align's People

Contributors

galaunay avatar laurencewarne avatar mkcms avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

interactive-align's Issues

Example regexp

Nice package, thanks for putting this together.
In your example you use \(\s-*[0-9]+\) I can't get that to work.

What works for me is if I go to group -1 and use \([0-9]+\)

What does the -* do in your example? Is this some negation?

  • \s is whitespace
  • [0-9]+ is one or more number

Also posting all the steps in your gif as commands would be useful.

Request: Be compatible to align-regexp

The idea behind an interactive align function is really great. However, I wished it would be fully compatible to align-regexp, that is it should be possible to use the very same regexp to generate the exact same aligning.

support PCRE regexps

pcre-mode 'advises' read-regexp so that perl regexp syntax can be used instead of elisp. but ialign (i guess because of the 'i' :-)) reads the regexp on its own, thus ignoring pcre-mode's influence. can you modify ialign-update so that accepts PCRE regexps? to do so, you could (1) add a check for pcre-mode and call rxt-pcre-to-elisp on the value returned by minibuffer-contents-no-properties or (2) define a tiny ialign function (e.g. ialign-fetch-minibuffer-contents) to wrap your call to minibuffer-contents-no-properties which could be easily 'advised' to convert PCRE syntax to elisp from an init.el or pcre2el.el itself. thoughts/comments?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.