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

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

[elpa] externals/phps-mode 3776841 138/405: Added new support for tracki


From: Stefan Monnier
Subject: [elpa] externals/phps-mode 3776841 138/405: Added new support for tracking doc-comment, HEREDOC and NOWDOC indentation
Date: Sat, 13 Jul 2019 10:00:00 -0400 (EDT)

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

    Added new support for tracking doc-comment, HEREDOC and NOWDOC indentation
---
 phps-mode-functions.el      | 15 ++++++++-------
 phps-mode-test-functions.el | 14 +++++++-------
 2 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index 080c351..69d413e 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -39,7 +39,7 @@
 ;; TODO Support indentation for multi-line scalar assignments
 
 (defun phps-mode-functions-get-current-line-indent ()
-  "Get the column number for current line."
+  "Get the column number and space number for current line."
   (if (boundp 'phps-mode-lexer-tokens)
       (save-excursion
         (beginning-of-line)
@@ -56,6 +56,7 @@
               (alternative-control-structure-level 0)
               (inline-control-structure-level 0)
               (indent-level 0)
+              (adjust-level 0)
               (indent-start 0)
               (indent-end 0)
               (last-line-number 0))
@@ -78,10 +79,6 @@
                   ;; Calculate indentation leven at end of line
                   (setq indent-end (+ round-bracket-level square-bracket-level 
curly-bracket-level alternative-control-structure-level 
inline-control-structure-level))
 
-                  ;; TODO Increase indent with 1 inside doc-comment, heredoc 
or nowdoc
-                  (when (or in-doc-comment in-heredoc)
-                    (setq indent-end (1+ indent-end)))
-
                   ;; Is line ending indentation higher than line beginning 
indentation?
                   (when (> indent-end indent-start)
 
@@ -130,7 +127,7 @@
                 (when (or (equal token 'T_IF)
                           (equal token 'T_WHILE)
                           (equal token 'T_CASE)
-                          (equal token 'T_DEFAULT)
+                             (equal token 'T_DEFAULT)
                           (equal token 'T_FOR)
                           (equal token 'T_FOREACH)
                           (equal token 'T_SWITCH)
@@ -166,8 +163,12 @@
 
                 )))
 
+          ;; Increase indent with one space inside doc-comment, HEREDOC or 
NOWDOC
+          (when (or in-doc-comment in-heredoc)
+            (setq adjust-level 1))
+
           (if in-scripting
-              indent-level
+              (list indent-level adjust-level)
             nil)))
     nil))
 
diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el
index ffef9fb..e5b89b1 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -40,22 +40,22 @@
   (phps-mode-test-with-buffer
    "<html><head><title><?php if ($myCondition) {\nif ($mySeconCondition) 
{\necho $title;\n\n} ?></title><body>Bla bla</body></html>"
    (goto-char 69)
-   (should (equal 1 (phps-mode-functions-get-current-line-indent))))
+   (should (equal '(1 0) (phps-mode-functions-get-current-line-indent))))
 
   (phps-mode-test-with-buffer
    "<html><head><title><?php if ($myCondition) {\nif ($mySeconCondition) 
{\necho $title;\n\n} ?></title><body>Bla bla</body></html>"
    (goto-char 40)
-   (should (equal 0 (phps-mode-functions-get-current-line-indent))))
+   (should (equal '(0 0) (phps-mode-functions-get-current-line-indent))))
 
   (phps-mode-test-with-buffer
    "<html><head><title><?php if ($myCondition) {\nif ($mySeconCondition) 
{\necho $title;\n\n} ?></title><body>Bla bla</body></html>"
    (goto-char 75)
-   (should (equal 2 (phps-mode-functions-get-current-line-indent))))
+   (should (equal '(2 0) (phps-mode-functions-get-current-line-indent))))
 
-  ;; (phps-mode-test-with-buffer
-  ;;  "<?php\n/**\n* Bla\n*/"
-  ;;  (goto-char 13)
-  ;;  (should (equal 2 (phps-mode-functions-get-current-line-indent))))
+  (phps-mode-test-with-buffer
+   "<?php\n/**\n* Bla\n*/"
+   (goto-char 13)
+   (should (equal '(0 1) (phps-mode-functions-get-current-line-indent))))
 
 
   )



reply via email to

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