-
Notifications
You must be signed in to change notification settings - Fork 69
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
Introduce scala-indent:defition-parameter-scaling-factor
#173
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1018,6 +1018,25 @@ val a, b = (1, 2) | |
(scala-syntax:find-brace-equals-or-next) | ||
(scala-syntax:handle-brace-equals-or-next)) | ||
|
||
(defun scala-syntax:in-definition-parameter-list (anchor start) | ||
"Return t if the (anchor, start) region is the parameter list | ||
of a definition(class, def, etc.)" | ||
(save-excursion | ||
(goto-char anchor) | ||
(when | ||
(or (string= "class" (current-word)) | ||
(string= "def" (current-word))) | ||
;; try to find ( | ||
(while (and (< (point) start) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not quite sure what you are trying to achieve here. I read the code as follows: you search for (, skip it, then search for ), skip that. Why? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What I was trying to do is:
I'm not sure whether there is some assumption I can leverage so simplify that, happy to take them. Also the approach doesn't really work for case like this because there is more complicated scenario like annoation within for the parameter list, like this case class Option(
@arg(
name="port",
doc="TCP port to listen to"
)
port: Int = 0,
) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok... first some note:
(you could of course ignore this for your specific modification)
But then some implementation hints:
here
As an example, consider the following code
Let's assume Now if you follow the instruction 1 above, you can use that to jump out of the parameter list, i.e. to the last That's it. HAVING SAID THAT, now that I read the code, I see I propose you implement the thing without refactoring There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually the thing I did with |
||
(/= (char-after) ?\()) | ||
(forward-char)) | ||
(when (< (point) start) | ||
;; And we haven't see ) yet. | ||
(while (and (< (point) start) | ||
(/= (char-after) ?\))) | ||
(forward-char)) | ||
(= (point) start))))) | ||
|
||
(defun scala-syntax:find-brace-equals-or-next () | ||
(scala-syntax:go-to-pos | ||
(save-excursion | ||
|
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.
Can you fix the indentation here. You are most probably using tabs, please use spaces only.