-
Notifications
You must be signed in to change notification settings - Fork 27
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
Add new refactor command for emr-c #5
Conversation
New command: emr-c:semantic-insert-function-prototype-or-implementation. What it does: Insert function implementation/prototype into other file (file with the same name but different extension) from anywhere in your project. - If there's only one other file, the command inserts immediately into that file. - If more than one, you are prompted to select a file. - If there's none, you are prompted for the entire files in your project. After you select a file, a prompt offers a list of Semantic tags in the buffer.
TODO:
|
I think I will create a new package of out this. |
@@ -118,6 +123,56 @@ project, return all header files in the current directory." | |||
(--filter (-contains? '("h" "hpp") (file-name-extension it))) | |||
(-map 'file-relative-name))) | |||
|
|||
|
|||
(defvar emr-c:--semantic-tag-list '() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The package-private prefix should be emr-c:
for consistency with the rest of the codebase, so this would be emr-c:semantic-tag-list
. Same for the rest.
A double-dash prefix would be better for all of emr
, but that's a topic for another changeset. :)
Very cool. Please update the identifiers as noted, then let me know when you've pushed all your commits on this feature and I'll merge. :) |
Oh, I see you closed it. Hadn't refreshed. :P Let me know if you want to proceed. |
That's fine by me. I think leaving it in here would be better for everyone. Please open it again. |
This is a good reference list for future features: http://refactoring.com/catalog/ |
I created a package out of this: https://github.com/tuhdo/semantic-refactor I think it's better this way since EMR has many dependencies and not all people want. The package can also be better maintained, since I take an active role over the package. I'm sorry about this. Maybe I can integrate my package into yours at some point, as a dependency, is that ok? |
No worries. Your package looks awesome. :D |
New command: emr-c:semantic-insert-function-prototype-or-implementation.
What it does: Insert function implementation/prototype into other file (file with the same name but different extension) from anywhere in your project. It was originated from this StackExchange question.
START DEMO
at the bottom):In the beginning, test.h is empty. I ran the command in test.c, and it switches to test.h and insert immediately, since the file was empty. After the first function interface is inserted, when running the command on the second interface in test.c switched to test.h and prompt for a place to insert. I selected the first function inserted previously, and as a result, the second signature is inserted after it.
As you see, you can insert based on a position of a tag. Note that when point was in .cpp file, it is inside the function body; you do not have to move point to function name to do this. When the file .h was switched, the command offered a list of Semantic tags for selecting one, and insert after it. If a tag is a child of another tag, it will be appended with prefix
(<parent tag name>)
.{}
is opened and indented nicely, create a body to write code immeidately:TODO:
emr-menu
for the command and future refactor commands.