Skip to content

method motions to include decorators #1015

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

Merged

Conversation

KamranMaharov
Copy link
Contributor

method motions to include decorators

@diraol
Copy link
Contributor

diraol commented May 11, 2019

@KamranMaharov can you rebase against thedevelop branch, so we can see if the tests passes?

@KamranMaharov KamranMaharov force-pushed the method_motion_include_decorator branch from ffcb12f to 4359924 Compare May 12, 2019 05:22
method motions to include decorators
@KamranMaharov KamranMaharov force-pushed the method_motion_include_decorator branch from 4359924 to d4aa916 Compare May 12, 2019 05:26
@KamranMaharov
Copy link
Contributor Author

@diraol , done.

onoremap <buffer> iM :<C-U>call pymode#motion#select('^<Bslash>s*<Bslash>(async<Bslash>s<Bslash>+<Bslash>)<Bslash>=def<Bslash>s', 1)<CR>
vnoremap <buffer> aM :<C-U>call pymode#motion#select('^<Bslash>s*<Bslash>(async<Bslash>s<Bslash>+<Bslash>)<Bslash>=def<Bslash>s', 0)<CR>
vnoremap <buffer> iM :<C-U>call pymode#motion#select('^<Bslash>s*<Bslash>(async<Bslash>s<Bslash>+<Bslash>)<Bslash>=def<Bslash>s', 1)<CR>
onoremap <buffer> C :<C-U>call pymode#motion#select_c('^<Bslash>s*class<Bslash>s', 0)<CR>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @KamranMaharov
Why have you used select_c over here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point. it could have been select(pattern, pattern)
to not duplicate pattern all over the script (that would be confusing), we call
select_c(pattern) and then select_c(pattern) calls select(pattern, pattern)

vnoremap <buffer> aC :<C-U>call pymode#motion#select_c('^<Bslash>s*class<Bslash>s', 0)<CR>
vnoremap <buffer> iC :<C-U>call pymode#motion#select_c('^<Bslash>s*class<Bslash>s', 1)<CR>

onoremap <buffer> M :<C-U>call pymode#motion#select('^<Bslash>s*<Bslash>(async<Bslash>s<Bslash>+<Bslash>)<Bslash>=@', '^<Bslash>s*<Bslash>(async<Bslash>s<Bslash>+<Bslash>)<Bslash>=def<Bslash>s', 0)<CR>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't @ be an optional "group"?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, for a decorator, we don't use async before decorators right?
So this:

(async<Bslash>s<Bslash>+<Bslash>)<Bslash>=@

have an extra async doesn't? [sorry if I didn't understand the regexes correctly].

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not familiar with async keyword.
as far as i can tell, it was here before and we could use it for matching decorator pattern.

@diraol
Copy link
Contributor

diraol commented May 12, 2019

Also, can you provide a sample code for us to test it?
Eventually you can add the file inside the 'tests' directory with comments on how to test it manually. =)

I'm thinking in adding such snippets for us to be able to test the features, even if it is manually (at some point we can automate the test, but writing tests here is not trivial).

python file for testing motions
@KamranMaharov
Copy link
Contributor Author

@diraol added sample test file. it is based on the code which you provided for testing.
i just added a little bit.

  • tested again. it's working.

@diraol diraol merged commit f61b74a into python-mode:develop Jun 30, 2019
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