emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/scala-mode b8e835f 161/217: scala-mode:goto-start-of-code


From: ELPA Syncer
Subject: [nongnu] elpa/scala-mode b8e835f 161/217: scala-mode:goto-start-of-code close #90
Date: Sun, 29 Aug 2021 11:31:04 -0400 (EDT)

branch: elpa/scala-mode
commit b8e835f41f49ba87ba4046bc2f73a313c9a18273
Author: Sam Halliday <sam.halliday@gmail.com>
Commit: Sam Halliday <sam.halliday@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.
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]