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

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

[elpa] externals/phps-mode 2efd7d7 367/405: Started on function to move


From: Stefan Monnier
Subject: [elpa] externals/phps-mode 2efd7d7 367/405: Started on function to move line-indent index
Date: Sat, 13 Jul 2019 10:00:52 -0400 (EDT)

branch: externals/phps-mode
commit 2efd7d724a4041f87c9c77d1425561e0704ba596
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>

    Started on function to move line-indent index
---
 phps-mode-functions.el      | 20 +++++++++++++++++++-
 phps-mode-test-functions.el |  2 +-
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index 3385c41..16c7340 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -69,6 +69,21 @@
     (phps-mode-functions--process-current-buffer)
     (setq phps-mode-functions-processed-buffer t)))
 
+;; TODO Fix this function
+(defun phps-mode-functions-move-lines-indent (start-line-number diff)
+  "Move line-indent index from START-LINE-NUMBER with DIFF amount."
+  (let ((lines-indent (phps-mode-functions-get-lines-indent))
+        (line-number (+ start-line-number diff)))
+    (when lines-indent
+      (let ((line-indent (gethash line-number 
phps-mode-functions-lines-indent)))
+        (while line-indent
+          (when (not (= line-number start-line-number))
+            (puthash (1- line-number) line-indent lines-indent)
+            )
+          (setq line-number (1+ line-number))
+          (setq line-indent (gethash line-number lines-indent)))
+        (setq phps-mode-functions-lines-indent lines-indent)))))
+
 (defun phps-mode-functions-get-lines-indent ()
   "Return lines indent, process buffer if not done already."
   (phps-mode-functions-process-current-buffer)
@@ -814,7 +829,8 @@
         ;; (message "Running advice")
         (let ((old-pos (point))
               (new-pos)
-              (looking-at-whitespace (looking-at-p "[\ \n\t\r]*\n")))
+              (looking-at-whitespace (looking-at-p "[\ \n\t\r]*\n"))
+              (old-line-number (line-number-at-pos)))
 
           ;; Temporarily disable change detection to not trigger incremental 
lexer
           (setq phps-mode-functions-allow-after-change nil)
@@ -829,6 +845,8 @@
                   (when (> diff 0)
                     (phps-mode-lexer-move-tokens old-pos diff)
                     (phps-mode-lexer-move-states old-pos diff)
+                    (phps-mode-functions-move-lines-indent old-line-number 1)
+                    ;; TODO Move imenu-index?
                     ;; (message "Old pos %s, new pos: %s, diff: %s" old-pos 
new-pos diff)
                     )))
             ;; (message "Not looking at white-space")
diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el
index 5feb51e..e843588 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -882,7 +882,7 @@
    (message "Tokens %s" (phps-mode-lexer-get-tokens))
    (should (equal (phps-mode-lexer-get-tokens)
                   '(should (equal (phps-mode-lexer-get-tokens)
-                  '((T_OPEN_TAG 1 . 7) (T_IF 7 . 9) ("(" 10 . 11) (T_STRING 11 
. 15) (")" 15 . 16) (":" 16 . 17) (T_VARIABLE 22 . 26) ("=" 27 . 28) 
(T_CONSTANT_ENCAPSED_STRING 29 . 34) (";" 34 . 35) (T_VARIABLE 40 . 45) ("=" 46 
. 47) (T_CONSTANT_ENCAPSED_STRING 48 . 53) (";" 53 . 54) (T_ENDIF 55 . 60) (";" 
60 . 61))))))
+                  '((T_OPEN_TAG 1 . 7) (T_IF 7 . 9) ("(" 10 . 11) (T_STRING 11 
. 15) (")" 15 . 16) (":" 16 . 17) (T_VARIABLE 22 . 26) ("=" 27 . 28) 
(T_CONSTANT_ENCAPSED_STRING 29 . 34) (";" 34 . 35) (T_VARIABLE 40 . 45) ("=" 46 
. 47) (T_CONSTANT_ENCAPSED_STRING 48 . 53) (";" 53 . 54) (T_ENDIF 60 . 65) (";" 
65 . 66) (END_PARSE 68 . 68))))))
    )
 
   )



reply via email to

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