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

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

[elpa] externals/phps-mode 897f249 124/405: Work on alternative and inli


From: Stefan Monnier
Subject: [elpa] externals/phps-mode 897f249 124/405: Work on alternative and inline indentation
Date: Sat, 13 Jul 2019 09:59:57 -0400 (EDT)

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

    Work on alternative and inline indentation
---
 phps-mode-functions.el      | 8 ++++++--
 phps-mode-test-functions.el | 6 +++---
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index f77eb71..ab4e8f9 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -33,9 +33,10 @@
 
 ;; NOTE Also format white-space inside the line, i.e. after function 
declarations?
 
+;; TODO Add support for automatic parenthesis, bracket, square-bracket, 
single-quote and double-quote encapsulations
+
 ;; TODO Support inline function indentations
 ;; TODO Support indentation for multi-line scalar assignments
-;; TODO Add support for automatic parenthesis, bracket, square-bracket, 
single-quote and double-quote encapsulations
 
 (defun phps-mode-functions-indent-line ()
   "Indent line."
@@ -77,6 +78,7 @@
                     (first-token-is-closing-curly-bracket nil)
                     (tokens phps-mode-lexer-tokens)
                     (is-first-line-token t))
+
                 ;; (message "token start %s, token end %s" start-token-number 
end-token-number)
                 ;; (message "First token %s, last token %s" (car (nth 
start-token-number tokens)) (car (nth end-token-number tokens)))
 
@@ -102,7 +104,9 @@
                         (setq is-first-line-token nil)
 
                         ;; Is it a closing brace?
-                        (when (string= token "}")
+                        (when (or (string= token "}")
+                                  (eq token 'T_ELSE)
+                                  (eq token 'T_ELSEIF))
                           (setq first-token-is-closing-curly-bracket t)))
 
                       (when (and valid-tokens
diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el
index af79b70..dfa39ed 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -164,12 +164,12 @@
      (should (equal buffer-contents "<?php\n$var = [\n    'random' => [\n      
  'hello',\n    ],\n];\n"))))
   
   (phps-mode-test-with-buffer
-   "<?php\nif (myRandomCondition()):\necho 'Something here';\n    else:\n    
echo 'Something else here';\nendif;\n"
-   (goto-char 60)
+   "<?php\nif (myRandomCondition()):\necho 'Something here';\n    else:\n    
echo 'Something else here 8';\nendif;\n"
+   (goto-char 62)
    (phps-mode-functions-indent-line)
    ;; (message "Tokens %s" phps-mode-lexer-tokens)
    (let ((buffer-contents (buffer-substring-no-properties (point-min) 
(point-max))))
-     (should (equal buffer-contents "<?php\nif (myRandomCondition()):\necho 
'Something here';\nelse:\n    echo 'Something else here';\nendif;\n"))))
+     (should (equal buffer-contents "<?php\nif (myRandomCondition()):\necho 
'Something here';\nelse:\n    echo 'Something else here 8';\nendif;\n"))))
 
   ;; switch case
   



reply via email to

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