Giter Site home page Giter Site logo

indent-lint.el's Introduction

https://raw.githubusercontent.com/conao3/files/master/blob/headers/png/indent-lint.el.png https://img.shields.io/github/license/conao3/indent-lint.el.svg?style=flat-square https://img.shields.io/github/tag/conao3/indent-lint.el.svg?style=flat-square https://github.com/conao3/indent-lint.el/workflows/Main%20workflow/badge.svg https://img.shields.io/codacy/grade/62a36f4f04524d5e8c758440e8071c45.svg?logo=codacy&style=flat-square https://img.shields.io/badge/twitter-@conao__3-blue.svg?logo=twitter&style=flat-square https://img.shields.io/badge/chat-on_slack-blue.svg?logo=slack&style=flat-square

Table of Contents

Description

Async indentation checker and flycheck frontend.

Install

  • M-x package-install indent-lint
  • M-x package-install flycheck-indent

Usage

indent-lint

  • interactive

    M-x indent-lint

    Lint indentation for current-buffer.

  • Lisp program

    Use indent-lint function.

    (indent-lint BUF)
        

    BUF accepts buffer name (string) or buffer (buffer object).

    After few seconds, a buffer with different indentation lines are popped.

flycheck-indent

To enable, use something like this.

(eval-after-load 'flycheck
  '(flycheck-indent-setup))

Customize

indent-lint-before-indent-fn
The function will eval before indent
indent-lint-verbose
If non-nil, output diff verbose.

Information

Community

Any feedback and suggestions are welcome!

You can use GitHub issues, but you can also use Slack if you want a more casual conversation.

Contribution

We welcome PR!

Require tools for testing

  • cask
    • install via brew
      brew install cask
              
    • manual install
      cd ~/
      hub clone cask/cask
      export PATH="$HOME/.cask/bin:$PATH"
              

Running test

Below operation flow is recommended.

make                              # Install git-hooks in local .git

git branch [feature-branch]       # Create branch named [feature-branch]
git checkout [feature-branch]     # Checkout branch named [feature-branch]

# <edit loop>
emacs indent-lint.el              # Edit something you want

make test                         # Test indent-lint
git commit -am "brabra"           # Commit (auto-run test before commit)
# </edit loop>

hub fork                          # Create fork at GitHub
git push [user] [feature-branch]  # Push feature-branch to your fork
hub pull-request                  # Create pull-request

Migration

License

General Public License Version 3 (GPLv3)
Copyright (c) Naoya Yamashita - https://conao3.com
https://github.com/conao3/indent-lint.el/blob/master/LICENSE

Author

Contributors

indent-lint.el's People

Contributors

conao3 avatar hdasch avatar

Stargazers

Bruno avatar Semen avatar Mir Behroz Noor avatar Chris Rayner avatar Alex Larsen avatar Julia avatar Seijiro Ozawa  avatar Hudson Couto avatar Larry Xu avatar  avatar  avatar

Watchers

James Cloos avatar  avatar  avatar

indent-lint.el's Issues

Eager macro-expansion skipped due to cycle

When I first tried to evaluate lint-indent.el buffer, I got this:

Warning: Eager macro-expansion skipped due to cycle:
  (load "indent-lint-autoloads.el") => (macroexpand-all (async-defun indent-lint …)) => (macroexpand (async-defun …))

Emacs version: 27

Copy major-mode interactively

When indent-lint is used interactively, I guess you could copy the origin's buffer major-mode to the temporary buffer. This will make sure the same major-mode is used, regardless of what normal-mode says it should be.

But this won't be enough because the origin file could have some file-local variables that need to be set in the temp buffer too. For this to work reliably, I would try something like this instead:

  1. copy the content of the origin buffer to a temporary buffer
  2. indent the origin buffer (that way you are sure you have the same major-mode and local variables)
  3. diff the 2 buffers
  4. copy the content of the temporary buffer to the origin buffer

You should make sure step (4) always happens so I would wrap all of it inside an unwind-protect.

I'm not sure it's going to work but it's probably worth trying.

Error '(void-function _value)' using recent versions of emacs-promise

After submitting pull request #36, I realized I did not adequately describe what it was intended to fix. With recent versions of emacs-promise, indent-lint fails with error '(void-function _value)'. Traceback below:

Debugger entered--Lisp error: (void-function _value)
  (_value (promise-wait indent-lint-batch-timeout (indent-lint buf)))
  (let* ((buf (find-file-noselect filepath 'nowarn)) (res (_value (promise-wait indent-lint-batch-timeout (indent-lint buf))))) (progn (ignore (seqp res)) (let* ((x144 (seq--elt-safe res 1)) (x145 (seq--elt-safe res 0))) (let ((value x144) (state x145)) (cond ((eq :fullfilled state) (progn (ignore ...) (let* ... ...))) ((eq :rejected state) (indent-lint--output-debug-info :rejected value) (setq exitcode (car value))) ((eq :timeouted state) (indent-lint--output-debug-info :timeouted value) (setq exitcode 100)))))))
  (let ((filepath (car tail))) (let* ((buf (find-file-noselect filepath 'nowarn)) (res (_value (promise-wait indent-lint-batch-timeout (indent-lint buf))))) (progn (ignore (seqp res)) (let* ((x144 (seq--elt-safe res 1)) (x145 (seq--elt-safe res 0))) (let ((value x144) (state x145)) (cond ((eq :fullfilled state) (progn ... ...)) ((eq :rejected state) (indent-lint--output-debug-info :rejected value) (setq exitcode ...)) ((eq :timeouted state) (indent-lint--output-debug-info :timeouted value) (setq exitcode 100))))))) (setq tail (cdr tail)))
  (while tail (let ((filepath (car tail))) (let* ((buf (find-file-noselect filepath 'nowarn)) (res (_value (promise-wait indent-lint-batch-timeout (indent-lint buf))))) (progn (ignore (seqp res)) (let* ((x144 (seq--elt-safe res 1)) (x145 (seq--elt-safe res 0))) (let ((value x144) (state x145)) (cond (... ...) (... ... ...) (... ... ...)))))) (setq tail (cdr tail))))
  (let ((tail command-line-args-left)) (while tail (let ((filepath (car tail))) (let* ((buf (find-file-noselect filepath 'nowarn)) (res (_value (promise-wait indent-lint-batch-timeout ...)))) (progn (ignore (seqp res)) (let* ((x144 ...) (x145 ...)) (let (... ...) (cond ... ... ...))))) (setq tail (cdr tail)))))
  (let ((indent-lint-verbose nil) (indent-lint-popup nil) (exitcode 0)) (let ((tail command-line-args-left)) (while tail (let ((filepath (car tail))) (let* ((buf (find-file-noselect filepath ...)) (res (_value ...))) (progn (ignore (seqp res)) (let* (... ...) (let ... ...)))) (setq tail (cdr tail))))) (kill-emacs exitcode))
  indent-lint-batch()
  command-line-1(("--eval=(add-to-list 'load-path \"\")" "--eval=(package-initialize)" "--eval=(require 'indent-lint)" "--eval=(setq debug-on-error t)" "-f" "indent-lint-batch"  ̶[̶e̶l̶i̶d̶e̶d̶ ̶f̶i̶l̶e̶ ̶l̶i̶s̶t̶]̶ ))
  command-line()
  normal-top-level()

Not working indent-lint-batch

Currently indent-lint-batch doesn't work well.

Good

(let ((noninteractive t)
      (command-line-args-left '("/home/conao/dev/repos/indent-lint.el/flycheck-indent.el"))
      (indent-lint-verbose t))
  (cl-flet ((kill-emacs (&rest args) (ignore args)))
    (with-output-to-string
      (unless noninteractive
        (error "`indent-lint-batch' can be used only with --batch"))
      (condition-case err
          (let* ((filepath (nth 0 command-line-args-left))
                 (res
                  (let (done)
                    (funcall
                     (async-lambda ()
                       (let* ((buf (find-file-noselect filepath 'nowarn))
                              (res (await (indent-lint buf))))
                         (setq done res))))
                    (while (not done)
                      (accept-process-output nil 1)
                      (princ (format "%s\n" (current-time-string))))
                    done)))
            (seq-let (code buf) res
              (princ (with-current-buffer buf (buffer-string)))
              (kill-emacs code)))
        (error
         (indent-lint--output-debug-info err))))))

Bad

cask exec emacs -Q --batch -l indent-lint.el -f indent-lint-batch flycheck-indent.el

Add some documentation

Hi,

thank you for sharing your work. It would be nice to have use cases in README: some examples triggering linting warnings for example.

Clean batch output

Clean batch output. Currently, output needless output; Diff output...

Fix GitHub Actions yml

Fix GitHub Actions yml.

  • Do test in Emacs-27.1
  • Do all test job if fail some jobs
  • Don't run double CI for PR and branch

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.