hvesalai / emacs-scala-mode

The definitive scala-mode for emacs
http://ensime.org
GNU General Public License v3.0
361 stars 68 forks source link

jump over imports when opening files #90

Closed fommil closed 9 years ago

fommil commented 9 years ago

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

hvesalai commented 9 years ago

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

fommil commented 9 years ago

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

fommil commented 9 years ago

I can probably cook something up from https://github.com/ensime/ensime-emacs/blob/master/ensime-editor.el#L493

fommil commented 9 years ago
(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

fommil commented 9 years ago

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