emacs-scala-mode icon indicating copy to clipboard operation
emacs-scala-mode copied to clipboard

Inappropriate Indentation for classes with keyword names

Open nosewings opened this issue 4 years ago • 2 comments

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.

nosewings avatar Oct 18 '20 06:10 nosewings

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.

nosewings avatar Oct 18 '20 07:10 nosewings

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

hvesalai avatar Oct 18 '20 21:10 hvesalai