[elpa] externals/phps-mode 3427bf1: Added support for alternative newline characters

2019-11-11 Thread Christian Johansson
branch: externals/phps-mode
commit 3427bf16654bd391b42028c3ea366830c3032281
Author: Christian Johansson 
Commit: Christian Johansson 

Added support for alternative newline characters
---
 phps-mode-analyzer.el | 87 +--
 phps-mode.el  |  4 +--
 2 files changed, 65 insertions(+), 26 deletions(-)

diff --git a/phps-mode-analyzer.el b/phps-mode-analyzer.el
index d6a523e..6465f40 100644
--- a/phps-mode-analyzer.el
+++ b/phps-mode-analyzer.el
@@ -145,7 +145,7 @@
 ;; NOTE original is [a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*
 ;; NOTE Rebuilt for comparability with emacs-lisp
 
-(defvar phps-mode-lexer-WHITESPACE "[ \n\r\t]+"
+(defvar phps-mode-lexer-WHITESPACE "[ \n\r\t\C-m]+"
   "White-space.")
 
 (defvar phps-mode-lexer-TABS_AND_SPACES "[ \t]*"
@@ -156,10 +156,10 @@
 ;; NOTE Original is [;:,.\[\]()|^&+-/*=%!~$<>?@]
 ;; NOTE The hyphen moved last since it has special meaning and to avoid it 
being interpreted as a range.
 
-(defvar phps-mode-lexer-ANY_CHAR ".\\|\n"
+(defvar phps-mode-lexer-ANY_CHAR ".\\|\n\\|\C-m"
   "Any character.  The Zend equivalent is [^] but is not possible in Emacs 
Lisp.")
 
-(defvar phps-mode-lexer-NEWLINE "\\(\r\\|\n\\|\r\n\\)"
+(defvar phps-mode-lexer-NEWLINE "\\(\r\\|\n\\|\C-m\\|\r\n\\)"
   "Newline characters.")
 
 
@@ -191,6 +191,11 @@
   (when (boundp 'semantic-lex-end-point)
 (setq semantic-lex-end-point position)))
 
+(defun phps-mode-lexer-yyless (points)
+  "Move lexer back POINTS."
+  (when (boundp 'semantic-lex-end-point)
+(setq semantic-lex-end-point (- semantic-lex-end-point points
+
 (defun phps-mode-lexer-set-region-syntax-color (start end properties)
   "Do syntax coloring for region START to END with PROPERTIES."
   (with-silent-modifications (set-text-properties start end properties)))
@@ -199,6 +204,14 @@
   "Clear region of syntax coloring from START to END."
   (with-silent-modifications (set-text-properties start end nil)))
 
+(defun phps-mode-anaylzer-inline-char-handler ()
+  "Mimic inline_char_handler."
+  (let ((start (match-beginning 0)))
+(let ((string-start (search-forward "\n?"))
+ (and ST_IN_SCRIPTING (looking-at "\\?>\n?\C-m?"))
  (lambda()
(let ((start (match-beginning 0))
  (end (match-end 0)))
@@ -1626,9 +1665,9 @@
(let ((string-start
   (search-forward-regexp
(concat
-"\\(\n"
+"\\(\\(\n\\|\C-m\\)"
 heredoc_label
-";?\n\\|\\$"
+";?\\(\n\\|\C-m\\)\\|\\$"
 phps-mode-lexer-LABEL
 "\\|{\\$"
 phps-mode-lexer-LABEL
@@ -1643,7 +1682,7 @@
 
(cond
 
-((string-match (concat "\n" heredoc_label ";?\n") data)
+((string-match (concat "\\(\n\\|\C-m\\)" heredoc_label 
";?\\(\n\\|\C-m\\)") data)
 ;, (message "Found heredoc end at 
%s-%s" start end)
  (phps-mode-lexer-BEGIN 'ST_END_HEREDOC)
  (phps-mode-lexer-RETURN_TOKEN 'T_ENCAPSED_AND_WHITESPACE 
old-start start))
@@ -1661,7 +1700,7 @@
 (phps-mode-lexer-re2c-rule
  (and ST_NOWDOC (looking-at phps-mode-lexer-ANY_CHAR))
  (lambda()
-   (let ((string-start (search-forward-regexp (concat "\n" 
heredoc_label ";?\n") nil t)))
+   (let ((string-start (search-forward-regexp (concat 
"\\(\n\\|\C-m\\)" heredoc_label ";?\\(\n\\|\C-m\\)") nil t)))
  (if string-start
  (let* ((start (match-beginning 0))
 (end (match-end 0))
@@ -2044,14 +2083,14 @@
  curly-bracket-level
  square-bracket-level
  round-bracket-level)
-  "Generate a list of indentation for each line in INLINE-HTML, 
-working incrementally on INDENT, TAG-LEVEL, CURLY-BRACKET-LEVEL, 
+  "Generate a list of indentation for each line in INLINE-HTML.
+Working incrementally on INDENT, TAG-LEVEL, CURLY-BRACKET-LEVEL,
 SQUARE-BRACKET-LEVEL and ROUND-BRACKET-LEVEL."
   (phps-mode-debug-message
(message "Calculating HTML indent for: '%s'" inline-html))
 
   ;; Add trailing newline if missing
-  (unless (string-match "\n$" inline-html)
+  (unless (string-match-p "\\(\n\\|\C-m\\)$" inline-html)
 (setq inline-html (concat inline-html "\n")))
 
   (let ((start 0)
@@ -2070,7 +2109,7 @@ SQUARE-BRACKET-LEVEL and ROUND-BRACKET-LEVEL."
 
 (cond
 
- ((string= string "\n")
+ ((string-match-p "\\(\n\\|\C-m\\)" string)
 
   (let ((temp-indent indent))
 (when first-object-is-nesting-decrease
@@ -2123,7 +2162,7 @@ SQUARE-BRACKET-LEVEL and ROUND-BRACKET-LEVEL."
  )
 
 (when first-object-on-line
-  (unless (string= string "\n")
+  (unless (string-match-p "\\(\n\\|\C-m\\)" string)
 (setq first-object-on-line nil)
 (setq indent

[elpa] externals/phps-mode dd1cb7a: Fixed indentation of special case single line alternative control structure

2019-11-11 Thread Christian Johansson
branch: externals/phps-mode
commit dd1cb7a130a7b512daf977d1045ded7570cd3e0e
Author: Christian Johansson 
Commit: Christian Johansson 

Fixed indentation of special case single line alternative control structure
---
 phps-mode-analyzer.el| 12 +---
 phps-mode.el |  2 +-
 test/phps-mode-test-functions.el |  5 +
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/phps-mode-analyzer.el b/phps-mode-analyzer.el
index 6465f40..7a9de58 100644
--- a/phps-mode-analyzer.el
+++ b/phps-mode-analyzer.el
@@ -2204,6 +2204,7 @@ SQUARE-BRACKET-LEVEL and ROUND-BRACKET-LEVEL."
   (round-bracket-level 0)
   (square-bracket-level 0)
   (alternative-control-structure-level 0)
+  (alternative-control-structure-line 0)
   (in-concatenation nil)
   (in-concatenation-round-bracket-level nil)
   (in-concatenation-square-bracket-level nil)
@@ -2608,7 +2609,9 @@ SQUARE-BRACKET-LEVEL and ROUND-BRACKET-LEVEL."
 
   ;; Handle the else if case
   (if (equal 'T_IF token)
-  (setq after-special-control-structure-token token)
+  (progn
+(setq after-special-control-structure-token token)
+(setq alternative-control-structure-line 
token-start-line-number))
 
 ;; Is token not a curly bracket - because that is a 
ordinary control structure syntax
 (if (string= token "{")
@@ -2653,10 +2656,12 @@ SQUARE-BRACKET-LEVEL and ROUND-BRACKET-LEVEL."
 token))
 
   (setq in-inline-control-structure t)
-  (setq temp-pre-indent (1+ column-level)
+  (when (< alternative-control-structure-line 
token-start-line-number)
+(setq temp-pre-indent (1+ column-level))
 
 (setq after-special-control-structure nil)
-(setq after-special-control-structure-token nil)))
+(setq after-special-control-structure-token nil)
+(setq alternative-control-structure-line nil)))
 
 ;; Support extra special control structures (CASE)
 (when (and after-extra-special-control-structure
@@ -2708,6 +2713,7 @@ SQUARE-BRACKET-LEVEL and ROUND-BRACKET-LEVEL."
   (equal token 'T_DEFAULT))
   (setq after-special-control-structure round-bracket-level)
   (setq after-special-control-structure-token token)
+  (setq alternative-control-structure-line 
token-start-line-number)
   (setq nesting-key token)
   (setq special-control-structure-started-this-line t)
 
diff --git a/phps-mode.el b/phps-mode.el
index e07816e..08ac499 100644
--- a/phps-mode.el
+++ b/phps-mode.el
@@ -6,7 +6,7 @@
 ;; Maintainer: Christian Johansson 
 ;; Created: 3 Mar 2018
 ;; Modified: 11 Nov 2019
-;; Version: 0.3.11
+;; Version: 0.3.12
 ;; Keywords: tools, convenience
 ;; URL: https://github.com/cjohansson/emacs-phps-mode
 
diff --git a/test/phps-mode-test-functions.el b/test/phps-mode-test-functions.el
index c5e3a3d..a82909f 100644
--- a/test/phps-mode-test-functions.el
+++ b/test/phps-mode-test-functions.el
@@ -275,6 +275,11 @@
 (should (equal '((1 (0 0)) (2 (1 0)) (3 (2 0)) (4 (1 0)) (5 (1 0)) (6 (0 
0)) (7 (0 0)) (8 (0 0)) (9 (1 0)) (10 (0 0)) (11 (0 0)) (12 (0 0)) (13 (1 0)) 
(14 (0 0))) (phps-mode-test-hash-to-list 
(phps-mode-functions-get-lines-indent)
)
 
+  (phps-mode-test-with-buffer
+   "