Skip to content

eacl - Emacs auto complete lines by grepping project

Notifications You must be signed in to change notification settings

redguardtoo/eacl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eacl - Emacs auto complete lines

https://github.com/redguardtoo/eacl/actions/workflows/test.yml/badge.svg http://melpa.org/packages/eacl-badge.svg http://stable.melpa.org/packages/eacl-badge.svg

Auto complete lines by grepping the project.

Screenshot:

https://raw.githubusercontent.com/redguardtoo/eacl/master/eacl-demo.gif

For example, a web developer need create a new component instance.

Suppose the component is used in current project before:

<MyComponent
  attr1="v1"
  attr2="v2"
  attr3="v3"
  attr4="v4"
/>
  <Toolbar>
    <Button onClick={ e => console.log(e) }>
      <i className="fa fa-circle" />
    </Button>
  </Toolbar>
</MyComponent>

The developer only need input <MyComponent and run M-x eacl-complete-multiline.

Install

Place eacl.el under your Load Path. Then add (require 'eacl) to your configuration.

It’s also possible to use melpa.

git grep is automatically detected for completion if possible. Or else default grep is used.

To use git grep, Git should be added into environment variable “PATH”.

The command line program of grep and git need be added into environment variable “PATH”. Or else you need set eacl-grep-program and eacl-git-program to specify their path.

Usage

M-x eacl-complete-line completes single line. Line candidates are extracted from the project root.

M-x eacl-complete-multiline completes multiline code or html tag in project

C-u M-x eacl-complete-line completes single line from deleted code if current project is tracked by Git.

The keyword to grep is the text from the line beginning to current cursor.

Whitespace in keyword matches any characters.

The project root is automatically detected if Git/Mercurial/Subversion is used.

You can override the default root directory by setting eacl-project-root,

(setq eacl-project-root "~/projs/PROJECT_DIR")

M-x eacl-complete-line-from-buffer to complete single line from the buffers. Set eacl-ignore-buffers and eacl-include-buffers to specify ignored&included buffers.

M-x eacl-complete-line-from-buffer-or-project completes single line by grepping the project root when editing a physical file. Or else, it searches all buffers for line completion.

Tips

Directories and files to ignore

Modify grep-find-ignored-directories and grep-find-ignored-files to setup directories and files grep should ignore:

(with-eval-after-load 'grep
  (dolist (v '("node_modules"
               "bower_components"
               ".sass_cache"
               ".cache"
               ".npm"))
    (add-to-list 'grep-find-ignored-directories v))
  (dolist (v '("*.min.js"
               "*.bundle.js"
               "*.min.css"
               "*.json"
               "*.log"))
    (add-to-list 'grep-find-ignored-files v)))

Or you can setup above ignore options in .dir-locals.el.

Sample of .dir-locals.el,

((nil . ((eval . (progn
                   (dolist (v '("node_modules"
                                "bower_components"
                                ".sass_cache"
                                ".cache"
                                ".npm"))
                     (add-to-list 'grep-find-ignored-directories v))
                   (dolist (v '("*.min.js"
                                "*.bundle.js"
                                "*.min.css"
                                "*.json"
                                "*.log"))
                     (add-to-list 'grep-find-ignored-files v)))))))

git grep is automatically used for grepping in git repository.

Please note git grep does NOT use grep-find-ignored-directories OR grep-find-ignored-files. You could set eacl-git-grep-untracked to tell git whether untracked files should be grepped in the repository.

Bug Report

Check https://github.com/redguardtoo/eacl.

About

eacl - Emacs auto complete lines by grepping project

Resources

Stars

Watchers

Forks

Packages

No packages published