branch: elpa/scala-mode commit b8e835f41f49ba87ba4046bc2f73a313c9a18273 Author: Sam Halliday <sam.halli...@gmail.com> Commit: Sam Halliday <sam.halli...@gmail.com>
scala-mode:goto-start-of-code close #90 --- README.md | 11 +++++++++++ scala-mode2.el | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/README.md b/README.md index 3a90d00..a86bd4a 100644 --- a/README.md +++ b/README.md @@ -459,6 +459,16 @@ not traversed. scala-mode2's imenu support depends heavily on the `scala-syntax:end-of-definition` and `scala-syntax:beginning-of-definition` functions, and as such, it shares their limitations. +## Jump to the code + +Some people find it useful to add the following function to their +`scala-mode-hook` as it will jump the package and import boilerplate +in most files: + +```elisp +(scala-mode:goto-start-of-code) +``` + ## Other features - highlights only properly formatted string and character constants - indenting a code line removes trailing whitespace @@ -523,3 +533,4 @@ Contributors and valuable feedback: - Tillmann Rendel - Jim Powers - Ivan Malison +- Sam Halliday diff --git a/scala-mode2.el b/scala-mode2.el index 44ab399..8df7f99 100644 --- a/scala-mode2.el +++ b/scala-mode2.el @@ -78,6 +78,14 @@ If there is no plausible default, return nil." forward-sexp-function 'scala-mode:forward-sexp-function)) ;;;###autoload +(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))) + +;;;###autoload (define-derived-mode scala-mode prog-mode "Scala" "Major mode for editing scala code.