[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))))
)
- [elpa] externals/phps-mode 7dca537 105/405: Started work on renaming files, (continued)
- [elpa] externals/phps-mode 7dca537 105/405: Started work on renaming files, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode e11a1fc 123/405: Fine-tuning of logic collecting data about inline and alternative control structures, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode e206605 115/405: Adding failing unit tests for inline and alternative syntax, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c6aa633 118/405: More work on keeping track of alternative control structures, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 60c7431 122/405: Unit tests for gather data about inline and alternative control structure syntax passes, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 897f249 124/405: Work on alternative and inline indentation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode be35ed6 127/405: Added sample files for inline and alternative control structures, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 7279913 113/405: Improved TODOs, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode a8eadfa 130/405: Improved sample files inline and alternative control structures, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 9996ae0 146/405: More work on indentation calculation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 3776841 138/405: Added new support for tracking doc-comment, HEREDOC and NOWDOC indentation,
Stefan Monnier <=
- [elpa] externals/phps-mode 780d065 125/405: Code styling updates, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 314dba1 135/405: Improved articulation of what information get-current-line-data should return, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode f0523b7 137/405: More work on new function to calculate indentation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 16d8056 144/405: Foundation for new indentation tests completed, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode d380cd4 129/405: Updated readme, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 3f08b86 128/405: Updated tracking of alternative control structures, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 52c502c 139/405: Improved logic for doc-comment tracking, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 1472273 136/405: Begun working on new approach to indentation calculation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 9792f70 133/405: Cleaning up code gather point meta information, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode cc947a9 140/405: Added more tests for new indentation function, Stefan Monnier, 2019/07/13