hvesalai/emacs-scala-mode

jump over imports when opening files

fommil opened this issue · 5 comments

it would be pretty useful to jump to the first non-package, non-import line in a scala file when opening.

Hmm... maybe attach something to the find-file-hook hook that will position the file.

yup, we might have some regex in ENSIME that finds the right place to put new imports... probably the thing we need here.

(defun scala-mode:goto-start-of-code ()
  "Go to the start of the real code in the file: object, class or trait."
  (interactive)
  (let* ((case-fold-search nil))
    (search-forward-regexp "\\([[:space:]]+\\|^\\)\\(class\\|object\\|trait\\)" nil t)
    (move-beginning-of-line nil)))

put it in your scala-mode-hook

(if anybody actually wrote comments in Scala, perhaps we should jump to those as well)