[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode efcefde 035/405: Added support for closing pa
From: |
Stefan Monnier |
Subject: |
[elpa] externals/phps-mode efcefde 035/405: Added support for closing parenthesis and braces |
Date: |
Sat, 13 Jul 2019 09:59:35 -0400 (EDT) |
branch: externals/phps-mode
commit efcefde38812c77f851c197254e1f83d97656f92
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>
Added support for closing parenthesis and braces
---
phps-functions.el | 14 ++++++++++----
phps-test-functions.el | 16 +++++++++++++++-
2 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/phps-functions.el b/phps-functions.el
index 677d19a..1d26588 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -41,12 +41,18 @@
(let ((data (phps-mode/lexer-get-point-data)))
(save-excursion
(beginning-of-line)
- (let ((start (nth 0 data))
- (end (nth 1 data)))
+ (let* ((start (nth 0 data))
+ (end (nth 1 data))
+ (in-scripting (nth 0 start)))
;; Are we in scripting?
- (if (nth 0 start)
- (let ((indent-level (* (+ (nth 1 start) (nth 2 start)) 4)))
+ (if in-scripting
+ (let* ((indent-start (* (+ (nth 1 start) (nth 2 start)) 4))
+ (indent-end (* (+ (nth 1 end) (nth 2 end)) 4))
+ (indent-diff 0))
+ (when (> indent-start indent-end)
+ (setq indent-diff (- indent-start indent-end)))
+ (setq indent-level (- indent-start indent-diff))
(message "inside scripting, start: %s, end: %s, indenting to
column %s " start end indent-level)
(indent-line-to indent-level))
(progn
diff --git a/phps-test-functions.el b/phps-test-functions.el
index 350c0cd..f5f637f 100644
--- a/phps-test-functions.el
+++ b/phps-test-functions.el
@@ -64,7 +64,7 @@
(goto-char 98)
(phps-mode/indent-line)
(let ((buffer-contents (buffer-substring-no-properties (point-min)
(point-max))))
- (should (equal buffer-contents "<html><head><title><?php if
($myCondition) {\nif ($mySeconCondition) {\necho $title;\n\n }
?></title><body>Bla bla</body></html>"))))
+ (should (equal buffer-contents "<html><head><title><?php if
($myCondition) {\nif ($mySeconCondition) {\necho $title;\n\n }
?></title><body>Bla bla</body></html>"))))
(phps-mode/with-test-buffer
"<html><head><title><?php if ($myCondition) {\nif ($mySeconCondition)
{\necho $title;\n\n}\n?>\n</title><body>Bla bla</body></html>"
@@ -74,6 +74,20 @@
(let ((buffer-contents (buffer-substring-no-properties (point-min)
(point-max))))
(should (equal buffer-contents "<html><head><title><?php if
($myCondition) {\nif ($mySeconCondition) {\necho
$title;\n\n}\n?>\n</title><body>Bla bla</body></html>"))))
+ (phps-mode/with-test-buffer
+ "<?php\n$variable = array(\n'random'\n);\n$variable = true;\n"
+ (goto-char 28)
+ (phps-mode/indent-line)
+ (let ((buffer-contents (buffer-substring-no-properties (point-min)
(point-max))))
+ (should (equal buffer-contents "<?php\n$variable = array(\n
'random'\n);\n$variable = true;\n"))))
+
+(phps-mode/with-test-buffer
+ "<?php\n$variable = array(\n 'random'\n );\n$variable = true;\n"
+ (goto-char 39)
+ (phps-mode/indent-line)
+ (let ((buffer-contents (buffer-substring-no-properties (point-min)
(point-max))))
+ (should (equal buffer-contents "<?php\n$variable = array(\n
'random'\n);\n$variable = true;\n"))))
+
)
(defun phps-mod/test-functions ()
- [elpa] externals/phps-mode 7fa9fdb 024/405: More unit tests for lexing comments and doc comments, (continued)
- [elpa] externals/phps-mode 7fa9fdb 024/405: More unit tests for lexing comments and doc comments, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 64a3ca8 014/405: Modified start and end for single and double quoted strings, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 3ea8c64 003/405: Added license, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode f6e3ce4 027/405: Added another test for comments, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 4fa9341 030/405: Started with unit tests for indentation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 184dfa5 034/405: Indentation outside PHP now does nothing, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 5c0568b 033/405: Added some basic unit tests for indentation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 47440dd 036/405: Added test for decreasing indentation with letters, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 9d3f644 032/405: Separated indentation tests for lexer tests, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode d839f8a 029/405: More work on indentation support, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode efcefde 035/405: Added support for closing parenthesis and braces,
Stefan Monnier <=
- [elpa] externals/phps-mode 1b891ea 031/405: More work on indentation and related tests, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c6e5255 038/405: Merge branch 'master' of https://github.com/cjohansson/emacs-phps-mode, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 3837d9c 001/405: My initial commit, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 6776468 037/405: Started worked with adding references to tokens from point meta information, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode feb5724 039/405: Various debug work, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode e36d477 045/405: token-number from point now is the same format as (nth), Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode b437374 040/405: Fixed bug in parsing of object parameters inside double quoted string, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 7161184 041/405: Handles stacked states better, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c625217 042/405: Added flag for PSR-2 white-space settings, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode b629c4b 050/405: Updated comments and TODOs, Stefan Monnier, 2019/07/13