Skip to content

Commit 74eaa24

Browse files
committed
Cycles between current indent and 0 when cycle-indent is true
1 parent c18f2bb commit 74eaa24

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

scala-mode-indent.el

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ strings"
905905
(beginning-of-line)
906906
(when (looking-at "^\\s +$") (point)))))
907907

908-
(defvar-local scala-indent:cycle-indent-stack nil
908+
(defvar-local scala-indent:cycle-indent-stack (list)
909909
"The automatically buffer local scala indent cycle stack.
910910
911911
The stack is initialized as (left-margin, (current-indentation))
@@ -931,20 +931,21 @@ Will fail if INDENTATION is not an integer"
931931
932932
Modifies the stack in-place."
933933

934-
(pop 'scala-indent:cycle-indent-stack))
934+
(pop (buffer-local-value 'scala-indent:cycle-indent-stack (current-buffer))))
935935

936936
(defun scala-indent:cycle-indent-stack-depth ()
937937
"The current depth of the \"scala-indent:cycle-indent-stack\" stack"
938938

939-
(length 'scala-indent:cycle-indent-stack))
939+
(length (buffer-local-value 'scala-indent:cycle-indent-stack (current-buffer))))
940940

941-
(defun scala-indent:cycle-indent-stack-emptyp ()
941+
942+
(defun scala-indent:cycle-indent-stack-emptyp (x)
942943
"Check if the \"scala-indent:cycle-indent-stack\" is empty.
943944
944945
Returns t if the \"scala-indent:cycle-indent-stack\" is empty,
945946
nil otherwise."
946-
947-
(eql (length 'scala-indent:cycle-indent-stack) 0))
947+
948+
(= (length (buffer-local-value 'scala-indent:cycle-indent-stack (current-buffer))) 0))
948949

949950
(defun scala-indent:cycle-indent-line (&optional strategy)
950951
"Cycle scala indentation using optionally passed STRATEGY.
@@ -955,7 +956,7 @@ the optionally passed STRATEGY. Indent to the top of
955956
\"scala-indent:cycle-indent-stack\" when non-empty."
956957

957958
(interactive "*")
958-
(cond (((scala-indent:cycle-indent-stack-emptyp))
959+
(cond ((scala-indent:cycle-indent-stack-emptyp nil)
959960
(scala-indent:cycle-indent-stack-push (current-indentation))
960961
(scala-indent:cycle-indent-stack-push 0)
961962
(call-interactively 'scala-indent:strategy-indent-line t))

0 commit comments

Comments
 (0)