|
View:
New views
7 Messages
—
Rating Filter:
Alert me
|
|
|
EMACS Scala Mode Indentation PatchThis fixes indentation for class definitions which are multi-line in nature.
e.g., class Point (x: Int, y: Int) = { def .... // properly indented here. In scala-mode-indent.el (defun scala-comment-indentation () @@ -121,9 +127,15 @@ (defun scala-block-indentation () (let ((block-start-eol (scala-point-after (end-of-line))) - (block-after-spc (scala-point-after (scala-forward-spaces)))) + (block-after-spc (scala-point-after (scala-forward-spaces)))) (if (> block-after-spc block-start-eol) - (+ (current-indentation) scala-mode-indent:step) + (progn + (beginning-of-line) + (if (search-forward ")" block-start-eol t) + (progn + (scala-forward-spaces) + (backward-sexp))) + (+ (current-indentation) scala-mode-indent:step)) (current-column)))) |
|
|
Re: [scala-tools] EMACS Scala Mode Indentation PatchHey
Thank you very much, I will look at this tomorrow and integrate it into the emacs mode in the repository! /Anders Grey wrote: > > This fixes indentation for class definitions which are multi-line in nature. > > e.g., > > class Point (x: Int, > y: Int) = { > def .... // properly indented here. > > In scala-mode-indent.el > > (defun scala-comment-indentation () > @@ -121,9 +127,15 @@ > > (defun scala-block-indentation () > (let ((block-start-eol (scala-point-after (end-of-line))) > - (block-after-spc (scala-point-after (scala-forward-spaces)))) > + (block-after-spc (scala-point-after (scala-forward-spaces)))) > (if (> block-after-spc block-start-eol) > - (+ (current-indentation) scala-mode-indent:step) > + (progn > + (beginning-of-line) > + (if (search-forward ")" block-start-eol t) > + (progn > + (scala-forward-spaces) > + (backward-sexp))) > + (+ (current-indentation) scala-mode-indent:step)) > (current-column)))) > > > -- > View this message in context: http://www.nabble.com/EMACS-Scala-Mode-Indentation-Patch-tp22525898p22525898.html > Sent from the Scala - Tools mailing list archive at Nabble.com. > -- Anders Bach Nielsen | http://www.daimi.au.dk/~abachn/ University of Aarhus | abachn@... - Earth men are real men! |
|
|
Re: [scala-tools] EMACS Scala Mode Indentation PatchHey
I have just tried to apply this patch, but it does not fix the example you give here! What version of emacs did you use ? /Anders Grey wrote: > > This fixes indentation for class definitions which are multi-line in nature. > > e.g., > > class Point (x: Int, > y: Int) = { > def .... // properly indented here. > > In scala-mode-indent.el > > (defun scala-comment-indentation () > @@ -121,9 +127,15 @@ > > (defun scala-block-indentation () > (let ((block-start-eol (scala-point-after (end-of-line))) > - (block-after-spc (scala-point-after (scala-forward-spaces)))) > + (block-after-spc (scala-point-after (scala-forward-spaces)))) > (if (> block-after-spc block-start-eol) > - (+ (current-indentation) scala-mode-indent:step) > + (progn > + (beginning-of-line) > + (if (search-forward ")" block-start-eol t) > + (progn > + (scala-forward-spaces) > + (backward-sexp))) > + (+ (current-indentation) scala-mode-indent:step)) > (current-column)))) > > > -- > View this message in context: http://www.nabble.com/EMACS-Scala-Mode-Indentation-Patch-tp22525898p22525898.html > Sent from the Scala - Tools mailing list archive at Nabble.com. > -- Anders Bach Nielsen | http://www.daimi.au.dk/~abachn/ University of Aarhus | abachn@... - Holy crap! Did you see that? They arrested Terrance and Philip! |
|
|
Re: [scala-tools] EMACS Scala Mode Indentation PatchI have just tried with both emacs 22.3.1 and emacs 23.0.91 and in both
cases there are no improvements :-( /Anders Anders Bach Nielsen wrote: > Hey > > I have just tried to apply this patch, but it does not fix the example > you give here! What version of emacs did you use ? > > /Anders > > Grey wrote: > > > > This fixes indentation for class definitions which are multi-line in nature. > > > > e.g., > > > > class Point (x: Int, > > y: Int) = { > > def .... // properly indented here. > > > > In scala-mode-indent.el > > > > (defun scala-comment-indentation () > > @@ -121,9 +127,15 @@ > > > > (defun scala-block-indentation () > > (let ((block-start-eol (scala-point-after (end-of-line))) > > - (block-after-spc (scala-point-after (scala-forward-spaces)))) > > + (block-after-spc (scala-point-after (scala-forward-spaces)))) > > (if (> block-after-spc block-start-eol) > > - (+ (current-indentation) scala-mode-indent:step) > > + (progn > > + (beginning-of-line) > > + (if (search-forward ")" block-start-eol t) > > + (progn > > + (scala-forward-spaces) > > + (backward-sexp))) > > + (+ (current-indentation) scala-mode-indent:step)) > > (current-column)))) > > > > > > -- > > View this message in context: http://www.nabble.com/EMACS-Scala-Mode-Indentation-Patch-tp22525898p22525898.html > > Sent from the Scala - Tools mailing list archive at Nabble.com. > > > > -- > Anders Bach Nielsen | http://www.daimi.au.dk/~abachn/ > University of Aarhus | abachn@... > - > Holy crap! Did you see that? They arrested Terrance and Philip! > -- Anders Bach Nielsen | http://www.daimi.au.dk/~abachn/ University of Aarhus | abachn@... - BOFH Excuse #421: Domain controller not responding |
|
|
Re: [scala-tools] EMACS Scala Mode Indentation PatchGNU Emacs 23.0.91.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.10.14) which is the lastest emacs from csv, however, it should work on the current released versions.
Not working in the sense of errors, no noticeable effect whatsoever, something is happening but it sure ain't the anticipated correct behavior? I have done a number of changes. I may have an unanticipated dependency on some of the other mods and/or my .emacs config. Standby and I'll re-validate everything on a clean pull of the scala-tools emacs code and a virgin emacs install.
|
|
|
Re: [scala-tools] EMACS Scala Mode Indentation PatchOK, I'd forgotten a line, but this should work in all situations except for those where in it fails.
First declaration within the class block indents correctly. --- scala-mode-indent.el | 24 +++++++++++++++--------- 1 files changed, 15 insertions(+), 9 deletions(-) diff --git a/scala-mode-indent.el b/scala-mode-indent.el index 4e3c8ec..2a55a74 100644 --- a/scala-mode-indent.el +++ b/scala-mode-indent.el @@ -123,7 +123,12 @@ (let ((block-start-eol (scala-point-after (end-of-line))) (block-after-spc (scala-point-after (scala-forward-spaces)))) (if (> block-after-spc block-start-eol) - (+ (current-indentation) scala-mode-indent:step) + (progn + (beginning-of-line) + (when (search-forward ")" block-start-eol t) + (scala-forward-spaces) + (backward-sexp)) + (+ (current-indentation) scala-mode-indent:step)) (current-column)))) (defun scala-indentation-from-following () @@ -152,14 +157,15 @@ ;; current expression. Return nil if indentation cannot be guessed. (save-excursion (scala-backward-spaces) - (when (and (not (bobp)) - (or (eq (char-syntax (char-before)) ?\() - (progn - (when (eq (char-before) ?\)) - (backward-sexp) - (scala-backward-spaces)) - (scala-looking-at-backward scala-expr-start-re)))) - (+ (current-indentation) scala-mode-indent:step)))) + (and (not (bobp)) + (if (eq (char-syntax (char-before)) ?\() + (scala-block-indentation) + (progn + (when (eq (char-before) ?\)) + (backward-sexp) + (scala-backward-spaces)) + (scala-looking-at-backward scala-expr-start-re))) + (+ (current-indentation) scala-mode-indent:step)))) (defun scala-indentation-from-block () ;; Return suggested indentation based on the current block. -- 1.6.0.6 |
|
|
Re: [scala-tools] EMACS Scala Mode Indentation PatchHey
Yes, this works just fine and committed as revision 17339. /Anders Grey wrote: > > OK, I'd forgotten a line, but this should work in all situations except for > those where in it fails. > > > First declaration within the class block indents correctly. > --- > scala-mode-indent.el | 24 +++++++++++++++--------- > 1 files changed, 15 insertions(+), 9 deletions(-) > > diff --git a/scala-mode-indent.el b/scala-mode-indent.el > index 4e3c8ec..2a55a74 100644 > --- a/scala-mode-indent.el > +++ b/scala-mode-indent.el > @@ -123,7 +123,12 @@ > (let ((block-start-eol (scala-point-after (end-of-line))) > (block-after-spc (scala-point-after (scala-forward-spaces)))) > (if (> block-after-spc block-start-eol) > - (+ (current-indentation) scala-mode-indent:step) > + (progn > + (beginning-of-line) > + (when (search-forward ")" block-start-eol t) > + (scala-forward-spaces) > + (backward-sexp)) > + (+ (current-indentation) scala-mode-indent:step)) > (current-column)))) > > (defun scala-indentation-from-following () > @@ -152,14 +157,15 @@ > ;; current expression. Return nil if indentation cannot be guessed. > (save-excursion > (scala-backward-spaces) > - (when (and (not (bobp)) > - (or (eq (char-syntax (char-before)) ?\() > - (progn > - (when (eq (char-before) ?\)) > - (backward-sexp) > - (scala-backward-spaces)) > - (scala-looking-at-backward scala-expr-start-re)))) > - (+ (current-indentation) scala-mode-indent:step)))) > + (and (not (bobp)) > + (if (eq (char-syntax (char-before)) ?\() > + (scala-block-indentation) > + (progn > + (when (eq (char-before) ?\)) > + (backward-sexp) > + (scala-backward-spaces)) > + (scala-looking-at-backward scala-expr-start-re))) > + (+ (current-indentation) scala-mode-indent:step)))) > > (defun scala-indentation-from-block () > ;; Return suggested indentation based on the current block. > -- > 1.6.0.6 > > -- > View this message in context: http://www.nabble.com/EMACS-Scala-Mode-Indentation-Patch-tp22525898p22606345.html > Sent from the Scala - Tools mailing list archive at Nabble.com. > -- Anders Bach Nielsen | http://www.daimi.au.dk/~abachn/ University of Aarhus | abachn@... - There is always someone worse off than yourself. |
| Free embeddable forum powered by Nabble | Forum Help |