Skip to content

A package to automatically, language agnostically, fill in delimiters

License

Notifications You must be signed in to change notification settings

MatthewBregg/paren-completer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Automatically complete delimiters

Tired of having to manually type out delimiters when ending a large block, especially with varianted delimiters? Don’t like the heavy handed current solutions, that complete while you type, without much control? That’s where this package comes in!

Usage

This package has four, public facing functions

paren-completer-add-single-delimiter

and

paren-completer-add-all-delimiters

Along with a version that inserts a newline after each delimiter,

paren-completer-add-single-delimiter-with-newline
paren-completer-add-all-delimiters-with-newline

Calling the former will insert the next delimiter to close the nearest open one.

IE

{ ( 

Calling paren-completer-add-delimiter-in, right here, inserts ), and then } if called a second time.

The latter function, completes all missing delimiters, completing closing the block.

Be aware that these functions are only aware of delimiters from the beginning of the buffer, up till your point.

Customizing what delimiters to look for.

Modify paren-completer–open-delimiter-list, and paren-completer–close-delimiter-list They must be in the same order. IE, (ignoring the paren-completer prefix for brevity)

open-delimiter-list : [ \( \{ ]
close-delimiter-list : [\( \{ ] 

is fine, but

open-delimiter-list : [ \{ \[ ]
close-delimiter-list : [\( \{ ] 

Is quite problematic.

MISC

Caching the point won’t work, because it’s too easy to be at the same point, despite having made changes. Could make a hook to hook into on buffer change, but that would likely cancel any performance gains, might as well just run it multiple times.... ( Plus that’s a bit uglier.)

Customizations

  • paren-completer–complete-stringsp? : If true, use the syntax table to auto-close strings also.
  • paren-completer–ignore-commentsp? : If true, ignore delimiters in comments
  • paren-completer–ignore-stringsp? : If true, ignore delimiters within strings

About

A package to automatically, language agnostically, fill in delimiters

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published