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

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

[elpa] externals/phps-mode 4592bce 385/405: Only running newline heurist


From: Stefan Monnier
Subject: [elpa] externals/phps-mode 4592bce 385/405: Only running newline heuristic when rest of line is whitespace
Date: Sat, 13 Jul 2019 10:00:58 -0400 (EDT)

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

    Only running newline heuristic when rest of line is whitespace
---
 phps-mode-functions.el      | 12 +++++++-----
 phps-mode-test-functions.el |  8 ++++++--
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index d169e85..282492a 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -849,14 +849,15 @@
               (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)
-          (apply old-function arguments)
-          (setq phps-mode-functions-allow-after-change t)
-
           (if looking-at-whitespace
               (progn
                 ;; (message "Looking at white-space")
+
+                ;; Temporarily disable change detection to not trigger 
incremental lexer
+                (setq phps-mode-functions-allow-after-change nil)
+                (apply old-function arguments)
+                (setq phps-mode-functions-allow-after-change t)
+                
                 (setq new-pos (point))
                 (let ((diff (- new-pos old-pos)))
                   (when (> diff 0)
@@ -866,6 +867,7 @@
                     ;; TODO Move imenu-index?
                     ;; (message "Old pos %s, new pos: %s, diff: %s" old-pos 
new-pos diff)
                     )))
+            (apply old-function arguments)
             ;; (message "Not looking at white-space")
             )))
     (apply old-function arguments)))
diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el
index 904b5ef..ced802e 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -906,10 +906,11 @@
    ;; Initial state
    (should (equal (phps-mode-lexer-get-tokens)
                   '((T_OPEN_TAG 1 . 7) (T_VARIABLE 7 . 11) ("=" 12 . 13) 
(T_CONSTANT_ENCAPSED_STRING 14 . 19) (";" 19 . 20) (T_VARIABLE 22 . 27) ("=" 28 
. 29) (T_CONSTANT_ENCAPSED_STRING 30 . 35) (";" 35 . 36))))
+
    (should (equal (phps-mode-lexer-get-states)
                   '((35 36 1 (1 1 1 1 1)) (30 35 1 (1 1 1 1 1)) (28 29 1 (1 1 
1 1 1)) (22 27 1 (1 1 1 1 1)) (19 20 1 (1 1 1 1 1)) (14 19 1 (1 1 1 1 1)) (12 
13 1 (1 1 1 1 1)) (7 11 1 (1 1 1 1 1)) (1 7 1 (1 1 1 1 1)))))
 
-   ;; Change
+   ;; Insert newline
    (goto-char 21)
    (newline nil nil)
 
@@ -918,6 +919,7 @@
    ;; (message "States: %s" (phps-mode-lexer-get-states))
    (should (equal (phps-mode-lexer-get-tokens)
                   '((T_OPEN_TAG 1 . 7) (T_VARIABLE 7 . 11) ("=" 12 . 13) 
(T_CONSTANT_ENCAPSED_STRING 14 . 19) (";" 19 . 20) (T_VARIABLE 23 . 28) ("=" 29 
. 30) (T_CONSTANT_ENCAPSED_STRING 31 . 36) (";" 36 . 37))))
+
    (should (equal (phps-mode-lexer-get-states)
                '((36 37 1 (1 1 1 1 1)) (31 36 1 (1 1 1 1 1)) (29 30 1 (1 1 1 1 
1)) (23 28 1 (1 1 1 1 1)) (19 20 1 (1 1 1 1 1)) (14 19 1 (1 1 1 1 1)) (12 13 1 
(1 1 1 1 1)) (7 11 1 (1 1 1 1 1)) (1 7 1 (1 1 1 1 1)))))
    
@@ -932,10 +934,11 @@
    ;; (message "States: %s" (phps-mode-lexer-get-states))
    (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))))
+
    (should (equal (phps-mode-lexer-get-states)
                   '((60 61 1 (1 1 1 1 1)) (55 60 1 (1 1 1 1 1)) (53 54 1 (1 1 
1 1 1)) (48 53 1 (1 1 1 1 1)) (46 47 1 (1 1 1 1 1)) (40 45 1 (1 1 1 1 1)) (34 
35 1 (1 1 1 1 1)) (29 34 1 (1 1 1 1 1)) (27 28 1 (1 1 1 1 1)) (22 26 1 (1 1 1 1 
1)) (16 17 1 (1 1 1 1 1)) (15 16 1 (1 1 1 1 1)) (11 15 1 (1 1 1 1 1)) (10 11 1 
(1 1 1 1 1)) (7 9 1 (1 1 1 1 1)) (1 7 1 (1 1 1 1 1)))))
 
-   ;; Change
+   ;; Insert newline and then indent
    (goto-char 54)
    (newline-and-indent)
 
@@ -944,6 +947,7 @@
    ;; (message "States: %s" (phps-mode-lexer-get-states))
    (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 60 . 65) (";" 
65 . 66))))
+
    (should (equal (phps-mode-lexer-get-states)
                   '((65 66 1 (1 1 1 1 1)) (60 65 1 (1 1 1 1 1)) (53 54 1 (1 1 
1 1 1)) (48 53 1 (1 1 1 1 1)) (46 47 1 (1 1 1 1 1)) (40 45 1 (1 1 1 1 1)) (34 
35 1 (1 1 1 1 1)) (29 34 1 (1 1 1 1 1)) (27 28 1 (1 1 1 1 1)) (22 26 1 (1 1 1 1 
1)) (16 17 1 (1 1 1 1 1)) (15 16 1 (1 1 1 1 1)) (11 15 1 (1 1 1 1 1)) (10 11 1 
(1 1 1 1 1)) (7 9 1 (1 1 1 1 1)) (1 7 1 (1 1 1 1 1)))))
 



reply via email to

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