emacs-scala-mode
emacs-scala-mode copied to clipboard
Inappropriate Indentation for classes with keyword names
Minimal example:
case class For()
On the line after this class declaration, pressing Tab causes an indentation. The same happens if I name the class If
or While
, but not, e.g., Foo
.
On further inspection, I believe this is caused by the use of looking-at
in scala-syntax:looking-back-token
here, called from scala-indent:body-p
here. M-x toggle-case-fold-search
fixes the problem, so I'm not sure whether it should still be considered a bug.
Yes it's a bug. You shouldn't have to set anything. We need to add (let ((case-fold-search nil)))
into all functions that use looking-at
to fix this.
The best way would be to implement it once in scala-mode-lib.el
(call it scala-lib:looking-at
) and use that instead of the original.
https://www.gnu.org/software/emacs/manual/html_node/elisp/Searching-and-Case.html