[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/scala-mode ac13b94 061/217: post-self-insert-hooks
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/scala-mode ac13b94 061/217: post-self-insert-hooks |
Date: |
Sun, 29 Aug 2021 11:30:43 -0400 (EDT) |
branch: elpa/scala-mode
commit ac13b94f38e2752d2c7b99b909aeb4c35c2b943d
Author: Heikki Vesalainen <heikkivesalainen@yahoo.com>
Commit: Heikki Vesalainen <heikkivesalainen@yahoo.com>
post-self-insert-hooks
scala-indent:indent-on-special-words
scala-indent:indent-on-scaladoc-asterisk
---
README.md | 1 -
scala-mode-indent.el | 25 ++++++++++++++++++++++++-
scala-mode-map.el | 4 +++-
3 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index f44a388..55e9ada 100644
--- a/README.md
+++ b/README.md
@@ -325,7 +325,6 @@ customization variable *frame-background-mode* to *dark*
(use **M-x**
- syntax-begin-function for reliably fontifying elements which span
multiple lines
- beginning-of-defun, end-of-defun
-- indent case, etc after they are typed (use first space as self-insert-hook)
- movement commands to move to previous or next definition (val,
var, def, class, trait, object)
- highlight headings and annotations inside scaladoc specially (use
diff --git a/scala-mode-indent.el b/scala-mode-indent.el
index cf953c0..8ceb7d1 100644
--- a/scala-mode-indent.el
+++ b/scala-mode-indent.el
@@ -789,7 +789,25 @@ comment is outside the comment region. "
(+ (match-beginning 0) 1)))
(current-column))))
-(defun scala-mode:indent-scaladoc-asterisk (&optional insert-space-p)
+(defconst scala-indent:indent-on-words-re
+ (concat "^\\s *"
+ (regexp-opt '("catch" "case" "else" "finally" "yield") 'words)))
+
+(defun scala-mode:indent-on-special-words ()
+ "This function is meant to be used with post-self-insert-hook.
+
+Indents the line if position is right after a space that is after
+a word that needs to be indented specially."
+ ;; magic numbers used 4 = length of "case"
+ (when (and (> (current-column) 4)
+ (= (char-before) ?\s)
+ (= (char-syntax (char-before (- (point) 1))) ?w)
+ (save-excursion (backward-char)
+ (looking-back scala-indent:indent-on-words-re))
+ (not (nth 8 (syntax-ppss))))
+ (scala-indent:indent-line-to (scala-indent:calculate-indent-for-line))))
+
+(defun scala-mode:indent-on-scaladoc-asterisk (&optional insert-space-p)
"This function is meant to be used with post-self-insert-hook.
Indents the line if position is right after an asterisk in a
@@ -804,3 +822,8 @@ the asterisk is the last character on the line."
(looking-at "\\s *$"))
(insert " "))
(scala-indent:indent-line-to (scala-indent:scaladoc-indent (nth 8
state))))))
+
+(defun scala-mode:indent-scaladoc-asterisk (&optional insert-space-p)
+ (message "scala-mode:indent-scaladoc-asterisk has been deprecated, use
+scala-mode:indent-on-scaladoc-asterisk")
+ (scala-mode:indent-on-scaladoc-asterisk insert-space-p))
diff --git a/scala-mode-map.el b/scala-mode-map.el
index efba50b..f6d99ca 100644
--- a/scala-mode-map.el
+++ b/scala-mode-map.el
@@ -22,7 +22,9 @@
(defun scala-mode-map:add-self-insert-hooks ()
(add-hook 'post-self-insert-hook
- #'scala-mode-map:indent-parentheses))
+ 'scala-mode-map:indent-parentheses)
+ (add-hook 'post-self-insert-hook
+ 'scala-mode:indent-on-special-words))
(when (not scala-mode-map)
(let ((keymap (make-sparse-keymap)))
- [nongnu] elpa/scala-mode 6257e3b 033/217: Renamed bad-equals to indent-value-expression. Added info to README.md, (continued)
- [nongnu] elpa/scala-mode 6257e3b 033/217: Renamed bad-equals to indent-value-expression. Added info to README.md, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 4e3a24f 043/217: Updated Examples.md to reflect issues already solved, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 338ff73 060/217: Changed the indent defaults, closes #19, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 6c257f6 057/217: Enhanced support for comments and multi-line strings, including, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 68ca175 056/217: Fixes #20, the cons bug (a :: b :: Nil) as well as improving some of, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 78fff40 039/217: scala-indent:align-forms customization variable, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode f61e32d 047/217: Update README.md, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 0991658 051/217: Fixes #17: string syntax, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 3174f4c 048/217: Update README.md clone to be a valid command., ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode a78716d 046/217: Update README.md, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode ac13b94 061/217: post-self-insert-hooks,
ELPA Syncer <=
- [nongnu] elpa/scala-mode 2201b1c 092/217: Interact nicely with global-font-lock-mode., ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 98d22a5 099/217: Added programming languages to README.md code, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 453c012 106/217: fixed bug in string escapes marking, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 6116127 042/217: Updated README.md, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 11a710d 044/217: Correct annotation highlighting., ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 49bd528 045/217: working on README, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode d357a77 038/217: New 'scala-indent:align-parameters' customization variable, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode af0e387 053/217: Fixes #18: highlight escapes in strings after chars, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode bc446e7 120/217: sbt support is now in sbt-mode, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 597d421 145/217: Seems the imenu var needs to be set in a very local way., ELPA Syncer, 2021/08/29