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

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

[elpa] externals/phps-mode 36a4b64 222/405: Added lost test for token-le


From: Stefan Monnier
Subject: [elpa] externals/phps-mode 36a4b64 222/405: Added lost test for token-less lines again
Date: Sat, 13 Jul 2019 10:00:17 -0400 (EDT)

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

    Added lost test for token-less lines again
---
 phps-mode-functions.el      | 27 ++++++++++++++-------------
 phps-mode-test-functions.el |  2 +-
 2 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index 7555c93..cd7af95 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -420,17 +420,6 @@
                       ;; ;; Start indentation might differ from ending 
indentation in cases like } else {
                       (setq column-level-start column-level)
 
-
-                      ;; Indent token-less lines here in between last tokens 
if distance is more than 1 line
-                      (when (and (> next-token-start-line-number (1+ 
token-start-line-number))
-                                 (not (equal token 'T_CLOSE_TAG)))
-                        (let ((token-line-number-diff (1- (- 
token-start-line-number next-token-start-line-number))))
-                          (while (>= token-line-number-diff 0)
-                            (puthash (- token-start-line-number 
token-line-number-diff) `(,column-level-start ,tuning-level) line-indents)
-                            ;; (message "Saved line %s indent %s %s" (- 
token-end-line-number token-line-number-diff) column-level tuning-level)
-                            (setq token-line-number-diff (1- 
token-line-number-diff)))))
-
-
                       ;; Support temporarily pre-indent
                       (when temp-pre-indent
                         (setq column-level-start temp-pre-indent)
@@ -445,7 +434,6 @@
 
 
                       ;; Save line indent
-                      
                       (when phps-mode-functions-verbose
                         (message "Process line ending. nesting: %s-%s, 
line-number: %s-%s,     indent: %s.%s,  token: %s" nesting-start nesting-end 
token-start-line-number token-end-line-number column-level-start tuning-level 
token))
 
@@ -467,7 +455,6 @@
                           (when nesting-stack
                             (setq nesting-stack-end (car (cdr (car 
nesting-stack)))))
 
-                          ;; Increase indentation
                           (if allow-custom-column-increment
                               (progn
                                 (setq column-level (+ column-level (- 
nesting-end nesting-start)))
@@ -509,6 +496,20 @@
                           (setq tuning-level 0)))
 
 
+                      ;; Indent token-less lines here in between last tokens 
if distance is more than 1 line
+                      (when (and (> next-token-start-line-number (1+ 
token-end-line-number))
+                                 (not (equal token 'T_CLOSE_TAG)))
+
+                        (when phps-mode-functions-verbose
+                          (message "\nDetected token-less lines between %s and 
%s, should have indent: %s\n" token-end-line-number 
next-token-start-line-number column-level))
+
+                        (let ((token-line-number-diff (1- (- 
next-token-start-line-number token-end-line-number))))
+                          (while (>= token-line-number-diff 0)
+                            (puthash (- next-token-start-line-number 
token-line-number-diff) `(,column-level ,tuning-level) line-indents)
+                            ;; (message "Saved line %s indent %s %s" (- 
token-end-line-number token-line-number-diff) column-level tuning-level)
+                            (setq token-line-number-diff (1- 
token-line-number-diff)))))
+
+
                       ;; ;; When nesting decreases but ends with a nesting 
increase, increase indent by one
                       ;; (when (and (< nesting-end nesting-start)
                       ;;            line-contained-nesting-increase)
diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el
index 59a92f8..195567f 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -276,7 +276,7 @@
    "<html><head><title><?php if ($myCondition) {\n    if ($mySeconCondition) 
{\n        echo $title2;\n\n    } ?></title><body>Bla bla</body></html>"
    "Mixed HTML/PHP with if expression and token-less lines"
    ;; (message "Tokens: %s" phps-mode-lexer-tokens)
-   (should (equal '((1 (0 0)) (2 (1 0)) (3 (2 0))  (4 (2 0)) (5 (1 0))) 
(phps-mode-test-functions--hash-to-list 
(phps-mode-functions-get-lines-indent)))))
+   (should (equal '((1 (0 0)) (2 (1 0)) (3 (2 0)) (4 (2 0)) (5 (1 0))) 
(phps-mode-test-functions--hash-to-list 
(phps-mode-functions-get-lines-indent)))))
 
   (phps-mode-test-with-buffer
    "<html><head><title><?php\nif ($myCondition) {\n    if ($mySecondCondition) 
{\n        echo $title;\n    } else if ($mySecondCondition) {\n        echo 
$title4;\n    } else {\n        echo $title2;\n        echo $title3;\n    }\n} 
?></title><body>Bla bla</body></html>"



reply via email to

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