- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
EMACS Scala Mode Indentation Patch
Sun, 2009-03-15, 19:49
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))))
Mon, 2009-03-16, 08:57
#2
Re: EMACS Scala Mode Indentation Patch
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))))
>
>
Mon, 2009-03-16, 09:07
#3
Re: EMACS Scala Mode Indentation Patch
I 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-tp22525898p2252...
> > Sent from the Scala - Tools mailing list archive at Nabble.com.
> >
>
Mon, 2009-03-16, 14:27
#4
Re: EMACS Scala Mode Indentation Patch
GNU 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.
Anders Bach Nielsen-2 wrote:
>
> I 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-tp22525898p2252...
>> > Sent from the Scala - Tools mailing list archive at Nabble.com.
>> >
>>
Thu, 2009-03-19, 19:27
#5
Re: EMACS Scala Mode Indentation Patch
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
Fri, 2009-03-20, 10:17
#6
Re: EMACS Scala Mode Indentation Patch
Hey
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
Hey
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))))
>
>