Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7088701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:49:59+00:00 2026-05-28T07:49:59+00:00

When writing Scala code in Emacs, I notice the following indentation issue: List(1,2,3).foreach{ x

  • 0

When writing Scala code in Emacs, I notice the following indentation issue:

List(1,2,3).foreach{ x =>

Then press enter.

Then close the bracket, and this is what ends up happening:

List(1,2,3).foreach{ x =>
                  }

Although this is one particular example, this issue appears in a variety of ways when auto-indenting in Emacs.

An answer to either of these two questions would be appreciated:

  1. How can this issue be fixed so that the brace gets put in the proper place and anything within the braces is indented one level to the right?

  2. Is it possible to disable this type of auto-indentation (i.e. like ‘set noautoindent’ in vi). I tried solutions like the ones suggested here: Disable auto indent globally in Emacs without success.

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:49:59+00:00Added an answer on May 28, 2026 at 7:49 am

    I tried to solve this by editing scala-mode-indent.el file. It breaks indent in some of the other situations, but at least you will not have all those indents half-screen forward.

    Comment out this line:

    ;; (scala-indentation-from-following)
    

    And modify scala-indentation-from-preceding:

    (defun scala-indentation-from-preceding ()
       ;; Return suggested indentation based on the preceding part of the
       ;; current expression. Return nil if indentation cannot be guessed.
       (save-excursion
       (scala-backward-spaces)
       (and 
         (not (bobp))
       (if (eq (char-syntax (char-before)) ?\()
          (scala-block-indentation)
          (progn
            (when (eq (char-before) ?\))
            (backward-sexp)
            (scala-backward-spaces))
            t
           ;;(scala-looking-at-backward scala-expr-start-re)
    
          ))
        (if (scala-looking-at-backward scala-expr-start-re)
          (+ (current-indentation) scala-mode-indent:step)
          (current-indentation)
        ))))
    

    As I said, it still remains broken after that. I plan to write a better support shortly, maybe in a week or two.

    EDIT:

    If you want to disable scala indentation completely, comment out the line in scala-mode.el

    ;; indent-line-function          'scala-indent-line
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When writing the following code in scala var m = Map((0,1) -> a) m
I'm fairly new to Lift/Scala but like the ideas of less code writing and
While writing Scala RemoteActor code, I noticed some pitfalls: RemoteActor.classLoader = getClass().getClassLoader() has to
I'm writing a code generator which produces Scala output. I need to emulate a
Folks, I've been writing some code in Scala lately to teach myself the language
Writing Scala code, I regularly encounter cases where I have processor functions that operate
I have the following code object DispatchLibrary { private var nodes = Map.empty[java.util.UUID, List[BigInt]]
While I was writing some Scala code, I got a strange error message when
I'm experimenting with using jEdit as my main editor for writing Scala code. Along
I'm writing some Scala code which uses the Apache POI API. I would like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.