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

added a deindent() function . #267

Merged
merged 1 commit into from
May 27, 2013
Merged

Conversation

will-v-king
Copy link
Contributor

deindent() makes coding easier.
Also it's good for the further modification about indent/de-indent behaviour.

@bitwiseman
Copy link
Member

Hey, thanks for contributing!
Please add to the python implementation as well. It's easy.

As an aside:
Instead of deindenting, I would rather see us add a mode frame and then restore_mode when we want to deindent(). This is currently the only place we deindent, what is another example of where we'd deindent?

@will-v-king
Copy link
Contributor Author

@bitwiseman Thanks for your comment.
I just added a python implementation of deindent.

Last few years, I'm using jsbeautify.vim, and I modified the jsbeautify.vim. When I improve the format of 'switch', I found there's a need of deindent function.
https://github.com/will-v-king/_jsbeautify/blob/master/plugin/_jsbeautify.vim (you can search the keyword 'deindent' there)
That is my first time to use vim-script. And I note that there's a need to rebuild _jsbeautify.vim if I want to improve the effect. But now I think vim-jsbeautify(which refer js-beauify) will be a better choice.

I know 'switch' may be the only place need de-indent, but I think it's better to write 'deindent()' than write 'self.flags.indentation_level -= 1'.

@will-v-king
Copy link
Contributor Author

@bitwiseman I'm not sure the restore_mode is good or not. I think I may confuse when I use restore_mode. Because I should define a place to restore.
Do you mean the function like jumpIn('switch'), jumpOut('While') ?

@bitwiseman
Copy link
Member

@will-v-king said:

I think it's better to write 'deindent()' than write 'self.flags.indentation_level -= 1'.

Agreed, but in jsbeautify.vim the function like what you implemented is called unindent. That sounds better to me. If you can make that change (and rebase you commits into one commit with a meaningful first line in the commit message), I'll be happy to merge this.

@will-v-king
Copy link
Contributor Author

As English is not my mother language. I was entangled with which prefix is better to use, de or un, when I name the function. And I remember I googled the question like 'difference between de- and un-'. Then I got the answer which said 'de' is better.
And I googled the question again, here is the answer:
http://in.answers.yahoo.com/question/index?qid=20110620095604AATOwwf

"Best Answer - Chosen by Voters
They are not interchangeable. "de-" suggests the removal or reversal of a quality while "un-" suggests the nonexistence of a quality.

Eg.
My phone number has been delisted from public record; perhaps if you search old records, you will find it.
(I'm conveying the number was removed from public record, but it was once listed.)

My phone number is unlisted.
(I'm only conveying that my number is not listed.)

More examples -
Deice - removal ice that is there
Unattractive - not attractive (absence of that quality)"

more:http://english.stackexchange.com/search?q=+de+un
http://nullege.com/codes/show/[email protected]@kss@plugin@timer@tests@py@[email protected]

@will-v-king
Copy link
Contributor Author

I have question about how to rebase my commit.
Should I checkout the 'commit 6210928' then re-modify it and commit?


Oh,I googled and used the rebase. And commit again. I'm not sure if I should close this request and open a new one.

…ifier/__init__.py .

deindent() is used to reverse the indent() action.
@bitwiseman
Copy link
Member

I am an english speaker, and you just schooled me. 😄 Thanks!

bitwiseman added a commit that referenced this pull request May 27, 2013
added a deindent() function .
@bitwiseman bitwiseman merged commit 8fe8e64 into beautifier:master May 27, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants