Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indentation needs fixing #1

Open
punassuming opened this issue Mar 15, 2015 · 8 comments
Open

Indentation needs fixing #1

punassuming opened this issue Mar 15, 2015 · 8 comments
Labels

Comments

@punassuming
Copy link
Owner

Fix indentation algorithm

@punassuming
Copy link
Owner Author

It is currently working, but not containing all items needed. Will likely rewrite the entire indentation heuristic.

;; Block types that can affect indentation
;; comments - ; AAA
;; - previous block beginning brace = +0
;; - indentation level is skipped when determining position for current line
;; function - AAA(.*) { .\n. } = +1
;; function - AAA(.*) { } = +0
;; label - AAA: = 0
;; Keybindings (next line) AAA:: = +1
;; Keybindings (current line) AAA:: =+0
;; Open block - {( +1 on next
;; Close block - {( -1 on current
;; Class AAA.* { ... } = +1
;; #if block open - #[iI]f[^ \n]* (.*) = +1
;; #if block close - #[iI]f[^ \n]*$ = -1
;; return block - [Rr]eturn = -1
;; for .*\n { .. } = +1
;; loop .*\n { .. } = +1
;; open assignment - .*operator-regexp$ = +1

@punassuming punassuming changed the title Indentation is broken Indentation needs fixing Apr 9, 2015
@bbatsov
Copy link
Collaborator

bbatsov commented Feb 15, 2016

You should check modern modes like https://github.com/chrisbarrett/swift-mode and https://github.com/elixir-lang/emacs-elixir for ideas how to improve indentation overall. It's generally a good idea to leverage smie these days - https://www.gnu.org/software/emacs/manual/html_node/elisp/SMIE.html

@p3r7
Copy link

p3r7 commented Mar 4, 2016

Indentation doesn't seem to be working at all on my setup (emacs x64 25.1.90.2 on Microsoft Windows).
I get error ahk-indent-line: Symbol’s function definition is void: current-line.

Similarly, when installing via melpa, I get this warning: Warning (bytecomp): the function ‘current-line’ is not known to be defined.

@bbatsov
Copy link
Collaborator

bbatsov commented Mar 20, 2016

Yeah, there's no current-line function. I was wondering about this myself.

@bbatsov
Copy link
Collaborator

bbatsov commented Mar 20, 2016

@p3r7 I've just pushed a fix for this.

@ekr1
Copy link

ekr1 commented Apr 12, 2020

I have just created pull request #30 with a few fixes to the indentation code. It now works correctly for a 1800 line AHK script, for me and fixes some blatant misbehaviours.

@p3r7
Copy link

p3r7 commented Apr 13, 2020

Just came here to say thanks.

It works great!

@LewWadoo
Copy link

LewWadoo commented Jun 2, 2022

In the Switch-Case statement the Default keyword sticks to the beginning of the line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants