branch: elpa/scala-mode commit 45819956fcecc3828b5e4a7bbd9e6376cffe1c44 Author: Heikki Vesalainen <heikkivesalai...@yahoo.com> Commit: Heikki Vesalainen <heikkivesalai...@yahoo.com>
defined find-tag-default-function --- scala-mode2-syntax.el | 11 +++++++++++ scala-mode2.el | 28 ++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/scala-mode2-syntax.el b/scala-mode2-syntax.el index 1e90354..ace37dc 100644 --- a/scala-mode2-syntax.el +++ b/scala-mode2-syntax.el @@ -218,6 +218,17 @@ (looking-at scala-syntax:literal-re) (scala-syntax:looking-at-stableIdOrPath))) + + +(defun scala-syntax:regexp-for-id (id) + (let ((prefix-regex + (if (string-match scala-syntax:alphaid-re id) + "\\b" (concat "\\(^\\|[^" scala-syntax:opchar-group "]\\)"))) + (suffix-regex + (if (string-match scala-syntax:op-re (substring id -1 nil)) + (concat "\\([^" scala-syntax:opchar-group "]\\|$\\)") "\\b"))) + (concat prefix-regex id suffix-regex))) + ;;; ;;; Other regular expressions ;;; diff --git a/scala-mode2.el b/scala-mode2.el index 174c7c7..40e29f3 100644 --- a/scala-mode2.el +++ b/scala-mode2.el @@ -26,6 +26,32 @@ (defmacro scala-mode:make-local-variables (&rest quoted-names) (cons 'progn (mapcar #'(lambda (quoted-name) `(make-local-variable ,quoted-name)) quoted-names))) +(defun scala-mode:find-tag () + "Determine default tag to search for, based on text at point. +If there is no plausible default, return nil." + (let (from to) + (when (and (progn + ;; Look at text around `point'. + (save-excursion + (if (< 0 (skip-chars-backward scala-syntax:opchar-group)) + (if (= (char-before) ?_) + (skip-syntax-backward "w_")) + (skip-syntax-backward "w_")) + (setq from (point))) + (save-excursion + (skip-syntax-forward "w_.") (setq to (point))) + (save-excursion + (ignore-errors (scala-syntax:backward-sexp)) (setq from (max from (point)))) + (save-excursion + (goto-char from) + (ignore-errors (scala-syntax:forward-sexp)) (setq to (min to (point)))) + (> to from)) + (save-excursion + (goto-char from) + (and (looking-at scala-syntax:id-re) + (not (looking-at scala-syntax:keywords-unsafe-re))))) + (buffer-substring-no-properties from to)))) + (defun scala-mode:forward-sexp-function (&optional count) (unless count (setq count 1)) @@ -62,6 +88,7 @@ When started, runs `scala-mode-hook'. 'comment-column 'comment-multi-line 'forward-sexp-function + 'find-tag-default-function 'indent-line-function 'indent-tabs-mode 'join-line) @@ -93,6 +120,7 @@ When started, runs `scala-mode-hook'. comment-multi-line t forward-sexp-function 'scala-mode:forward-sexp-function + find-tag-default-function 'scala-mode:find-tag indent-line-function 'scala-indent:indent-line indent-tabs-mode nil join-line 'scala-indent:join-line