branch: elpa/scala-mode
commit e8c8a51d55c27d52118d3b3f4aa4817cdc70414f
Author: Igor Shymko <[email protected]>
Commit: Sam Halliday <[email protected]>
Couple imenu-related issues (#95)
* Fix couple imenu related issues
* Lisp nesting exceeds `max-lisp-eval-depth' error in
`scala-syntax:handle-brace-equals-or-next`
in SBT build scripts not ending with closing braces.
* Scan error: "Containing expression ends prematurely"
in files like:
```
object X {
object Y
}
```
* Add word boundaries for `scala-syntax:definition-words-re`.
This prevents case insensitive match like:
`class X extends Default {}`. Def in Default doesn't match in this case.
* Unreverse the order of nested imenu-index items
---
scala-mode2-imenu.el | 13 +++++++------
scala-mode2-syntax.el | 16 +++++++++-------
2 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/scala-mode2-imenu.el b/scala-mode2-imenu.el
index 5eec53a..9bc9c77 100644
--- a/scala-mode2-imenu.el
+++ b/scala-mode2-imenu.el
@@ -97,12 +97,13 @@
(defun scala-imenu:nested-members ()
(let ((start-point (point)))
- (save-excursion (scala-syntax:end-of-definition)
- ;; This gets us inside of the class definition
- ;; It seems like there should be a better way
- ;; to do this.
- (backward-char)
- (scala-imenu:get-nested-members start-point))))
+ (save-excursion
+ (scala-syntax:end-of-definition)
+ ;; This gets us inside of the class definition
+ ;; It seems like there should be a better way
+ ;; to do this.
+ (backward-char)
+ (reverse (scala-imenu:get-nested-members start-point)))))
(defvar scala-imenu:nested-definition-types '("class" "object" "trait"))
diff --git a/scala-mode2-syntax.el b/scala-mode2-syntax.el
index 80cc8cc..401f529 100644
--- a/scala-mode2-syntax.el
+++ b/scala-mode2-syntax.el
@@ -922,7 +922,7 @@ not. A list must be either enclosed in parentheses or start
with
(defconst scala-syntax:all-definition-re
(scala-syntax:build-definition-re
- (concat "\\(?1:" scala-syntax:definition-words-re "\\)")))
+ (concat "\\(?1:" scala-syntax:definition-words-re "\\)\\b")))
;; Functions to help with beginning and end of definitions.
@@ -968,12 +968,14 @@ val a, b = (1, 2)
(lambda () (condition-case ex (scala-syntax:forward-sexp-or-next-line)
('error nil)))))))
(defun scala-syntax:handle-brace-equals-or-next ()
- (cond ((looking-at "[[:space:]]*{") (forward-sexp))
- ((looking-at "[[:space:]]*=") (scala-syntax:forward-sexp-or-next-line)
- (scala-syntax:handle-brace-equals-or-next))
- ((looking-at scala-syntax:all-definition-re) nil)
- (t (scala-syntax:forward-sexp-or-next-line)
- (scala-syntax:handle-brace-equals-or-next))))
+ (cond ((eobp) nil)
+ ((looking-at "[[:space:]]*{") (forward-sexp))
+ ((looking-at "[[:space:]]*=") (scala-syntax:forward-sexp-or-next-line)
+ (scala-syntax:handle-brace-equals-or-next))
+ ((looking-at scala-syntax:all-definition-re) nil)
+ ((looking-at "[[:space:]]*\n[[:space:]]*}") (skip-syntax-forward
"[[:space:]]*\n[[:space:]]*}"))
+ (t (scala-syntax:forward-sexp-or-next-line)
+ (scala-syntax:handle-brace-equals-or-next))))
(defun scala-syntax:movement-function-until-re (re movement-function)
(save-excursion