[elpa] externals/phps-mode 9d3f644 032/405: Separated indentation tests for lexer tests

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 9d3f6447e56650765d29c9e03c7ddabb8b758385
Author: Christian Johansson 
Commit: Christian Johansson 

Separated indentation tests for lexer tests
---
 Makefile   | 12 ++--
 README.md  | 10 +--
 phps-test-functions.el | 76 ++
 phps-test-lexer.el | 44 ++---
 phps-test.el   | 54 +++
 5 files changed, 150 insertions(+), 46 deletions(-)

diff --git a/Makefile b/Makefile
index 1beb44f..64b18c6 100644
--- a/Makefile
+++ b/Makefile
@@ -7,17 +7,23 @@ ELC := $(EL:.el=.elc)
 clean:
rm -f $(ELC)
 
-compile: $(ELC)
+compile:
+   $(ELC)
 
 %.elc: %.el
$(EMACS_CMD) -f batch-byte-compile $<
 
-test: clean lexer-test parser-test
+test:
+   clean test-functions test-lexer test-parser
+
+test-functions:
+   $(EMACS_CMD) -l phps-test-functions.el
 
 test-lexer:
$(EMACS_CMD) -l phps-test-lexer.el
 
+
 test-parser:
$(EMACS_CMD) -l phps-test-parser.el
 
-.PHONY: clean compile test test-lexer test-parser
+.PHONY: clean compile test test-functions test-lexer test-parser
diff --git a/README.md b/README.md
index 51e9237..8f8fc3e 100644
--- a/README.md
+++ b/README.md
@@ -10,12 +10,12 @@ With current progress estimates:
 * Lexer based on official PHP re2c lexer (100%)
 * Syntax coloring based on lexer tokens (100%)
 * Incremental lexer and syntax coloring after changes (0%)
-* PSR based indentation based on lexer tokens (20%)
+* PSR based indentation based on lexer tokens (50%)
 * Wisent LALR parser based on official PHP yacc parser automatically converted 
(60%)
 * Flymake support (0%)
 * Full integration with Emacs Semantic subsystem (0%)
 
-## Unit testing
+## Unit tests
 
 Not ready yet.
 
@@ -30,3 +30,9 @@ make test-lexer
 ``` bash
 make test-parser
 ```
+
+### Indentation
+
+``` bash
+make test-functions
+```
diff --git a/phps-test-functions.el b/phps-test-functions.el
new file mode 100644
index 000..c25f820
--- /dev/null
+++ b/phps-test-functions.el
@@ -0,0 +1,76 @@
+;;; phps-test-functions.el --- Tests for functions
+
+;; Author: Christian Johansson 
+;; Maintainer: Christian Johansson 
+;; Created: 3 Mar 2018
+;; Modified: .
+;; Version: 0.1
+;; Keywords: tools, convenience
+;; URL: -
+
+;; Copyright (C) 2018 Christian Johansson
+
+;; This file is not part of GNU Emacs.
+
+;; This program is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation; either version 2, or (at
+;; your option) any later version.
+
+;; This program is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Spathoftware Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+
+;;; Commentary:
+
+
+;; Run from terminal make functions-test
+
+
+;;; Code:
+
+
+(autoload 'phps-mode/with-test-buffer "phps-test")
+(autoload 'should "ert")
+
+(defun phps-mode/test-indentation ()
+  "Test for indentation."
+  (phps-mode/with-test-buffer
+   "Bla bla"
+   (goto-char 69)
+   (phps-mode/indent-line)
+   (let ((buffer-contents (buffer-substring-no-properties (point-min) 
(point-max
+ (should (equal buffer-contents  "Bla bla"
+
+  (phps-mode/with-test-buffer
+   "Bla bla"
+   (goto-char 80)
+   (phps-mode/indent-line)
+   (let ((buffer-contents (buffer-substring-no-properties (point-min) 
(point-max
+ (should (equal buffer-contents  "Bla bla"
+
+  (phps-mode/with-test-buffer
+   "Bla bla"
+   (goto-char 98)
+   (phps-mode/indent-line)
+   (let ((buffer-contents (buffer-substring-no-properties (point-min) 
(point-max
+ (should (equal buffer-contents  "Bla bla"
+
+  )
+
+(defun phps-mod/test-functions ()
+  "Run test for functions."
+  (phps-mode/test-indentation))
+
+(phps-mod/test-functions)
+
+(provide 'phps-mod/test-functions)
+
+;;; phps-test-functions.el ends here
diff --git a/phps-test-lexer.el b/phps-test-lexer.el
index 225a426..997b96b 100644
--- a/phps-test-lexer.el
+++ b/phps-test-lexer.el
@@ -37,22 +37,10 @@
 ;;; Code:
 
 
-(autoload 'phps-mode "phps-mode")
+(autoload 'phps-mode/with-test-buffer "phps-test")
 (autoload 'phps-mode/lexer-init "phps-lexer")
-
-(require 'ert)
-
-(defmacro phps-mode/with-test-buffer (source &rest body)
-  "Set up test buffer with SOURCE and BODY."
-  `(let ((test-buffer (generate-new-buffer "test")))
- (switch-to-buffer test-buffer)
- (insert ,source)
- (goto-char 0)
- ;;,(message "\nTesting buffer:\n'%s'\n" source)
- (phps-mode)
- ,@body
- (kill-buffer test-buffer)
- ))
+(autoload 

[elpa] externals/phps-mode 394f7ae 017/405: Fixed issue with empty strings before non-empty strings

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 394f7aed8ac2c47acfdaaed21aae1b31e4e5ab61
Author: Christian Johansson 
Commit: Christian Johansson 

Fixed issue with empty strings before non-empty strings
---
 phps-lexer.el  | 106 ++---
 sample-php-files/class.php |   1 +
 2 files changed, 53 insertions(+), 54 deletions(-)

diff --git a/phps-lexer.el b/phps-lexer.el
index 3e84f52..1e5ce6f 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -447,15 +447,15 @@
((looking-at "return")
 (phps-mode/RETURN_TOKEN 'T_RETURN (match-beginning 0) (match-end 0)))
((looking-at (concat "yield" phps-mode/WHITESPACE "from" 
"[^a-zA-Z0-9_\x80-\xff]"))
-  (phps-mode/RETURN_TOKEN 'T_YIELD_FROM (match-beginning 0) (match-end 0)))
+(phps-mode/RETURN_TOKEN 'T_YIELD_FROM (match-beginning 0) (match-end 0)))
((looking-at "yield")
-  (phps-mode/RETURN_TOKEN 'T_YIELD (match-beginning 0) (match-end 0)))
+(phps-mode/RETURN_TOKEN 'T_YIELD (match-beginning 0) (match-end 0)))
((looking-at "try")
 (phps-mode/RETURN_TOKEN 'T_TRY (match-beginning 0) (match-end 0)))
((looking-at "catch")
-  (phps-mode/RETURN_TOKEN 'T_CATCH (match-beginning 0) (match-end 0)))
+(phps-mode/RETURN_TOKEN 'T_CATCH (match-beginning 0) (match-end 0)))
((looking-at "finally")
-  (phps-mode/RETURN_TOKEN 'T_FINALLY (match-beginning 0) (match-end 0)))
+(phps-mode/RETURN_TOKEN 'T_FINALLY (match-beginning 0) (match-end 0)))
((looking-at "throw")
 (phps-mode/RETURN_TOKEN 'T_THROW (match-beginning 0) (match-end 0)))
((looking-at "if")
@@ -471,7 +471,7 @@
((looking-at "endwhile")
 (phps-mode/RETURN_TOKEN 'T_ENDWHILE (match-beginning 0) (match-end 0)))
((looking-at "do")
-  (phps-mode/RETURN_TOKEN 'T_DO (match-beginning 0) (match-end 0)))
+(phps-mode/RETURN_TOKEN 'T_DO (match-beginning 0) (match-end 0)))
((looking-at "foreach")
 (phps-mode/RETURN_TOKEN 'T_FOREACH (match-beginning 0) (match-end 0)))
((looking-at "endforeach")
@@ -557,7 +557,7 @@
   (phps-mode/RETURN_TOKEN 'T_START_HEREDOC start end)))
 
((looking-at "::")
-  (phps-mode/RETURN_TOKEN 'T_PAAMAYIM_NEKUDOTAYIM (match-beginning 0) 
(match-end 0)))
+(phps-mode/RETURN_TOKEN 'T_PAAMAYIM_NEKUDOTAYIM (match-beginning 0) 
(match-end 0)))
((looking-at "")
 (phps-mode/RETURN_TOKEN 'T_NS_SEPARATOR (match-beginning 0) (match-end 0)))
((looking-at "\\.\\.\\.")
@@ -827,24 +827,23 @@
(data (buffer-substring-no-properties start end))
(found nil))
   (forward-char)
-  (let ((string-start (search-forward-regexp "[^]'" nil t)))
-(if string-start
-(progn
-  ;; (message "Single quoted string %s" 
(buffer-substring-no-properties start string-start))
-  (phps-mode/RETURN_TOKEN 'T_CONSTANT_ENCAPSED_STRING start 
string-start))
+  ;; Handle the '' case
+  (if (looking-at-p "'")
   (progn
-;; Handle the '' case
-(if (looking-at-p "'")
-(progn
-  ;; (message "Empty single quoted string from %s to %s" start 
(+ start 2))
-  (phps-mode/RETURN_TOKEN 'T_CONSTANT_ENCAPSED_STRING start (+ 
start 2))
-  (forward-char))
+;; (message "Empty single quoted string from %s to %s" start (+ 
start 2))
+(phps-mode/RETURN_TOKEN 'T_CONSTANT_ENCAPSED_STRING start (+ start 
2))
+(forward-char))
+(let ((string-start (search-forward-regexp "[^]'" nil t)))
+  (if string-start
   (progn
-;; Unclosed single quotes
-;; (message "Single quoted string never ends..")
-(phps-mode/RETURN_TOKEN 'T_ENCAPSED_AND_WHITESPACE start 
(point-max))
-(phps-mode/MOVE_FORWARD (point-max))
-)))
+;; (message "Single quoted string %s" 
(buffer-substring-no-properties start string-start))
+(phps-mode/RETURN_TOKEN 'T_CONSTANT_ENCAPSED_STRING start 
string-start))
+(progn
+  ;; Unclosed single quotes
+  ;; (message "Single quoted string never ends..")
+  (phps-mode/RETURN_TOKEN 'T_ENCAPSED_AND_WHITESPACE start 
(point-max))
+  (phps-mode/MOVE_FORWARD (point-max))
+  ))
 
;; Double quoted string
((looking-at "\"")
@@ -852,39 +851,38 @@
(end (match-end 0))
(data (buffer-substring-no-properties start end)))
   (forward-char)
-  (let ((string-start (search-forward-regexp (concat
-  "\\([^]\""
-  "\\|\\$" phps-mode/LABEL
-  "\\|\\${" phps-mode/LABEL
-  "\\|{\\$" phps-mode/LABEL 
"\\)")
- nil t)))
-  

[elpa] externals/phps-mode 64a3ca8 014/405: Modified start and end for single and double quoted strings

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 64a3ca8818d3fe043cbed0b96e9d7d3dc0834bec
Author: Christian Johansson 
Commit: Christian Johansson 

Modified start and end for single and double quoted strings
---
 phps-lexer.el  | 8 
 phps-test-lexer.el | 6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/phps-lexer.el b/phps-lexer.el
index 7907b06..0e75bae 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -836,8 +836,8 @@
 ;; Handle the '' case
 (if (looking-at-p "'")
 (progn
-  ;; (message "Empty single quoted string from %s to %s" end 
(+ end 1))
-  (phps-mode/RETURN_TOKEN 'T_CONSTANT_ENCAPSED_STRING end (+ 
end 1))
+  ;; (message "Empty single quoted string from %s to %s" start 
(+ start 2))
+  (phps-mode/RETURN_TOKEN 'T_CONSTANT_ENCAPSED_STRING start (+ 
start 2))
   (forward-char))
   (progn
 ;; Unclosed single quotes
@@ -878,8 +878,8 @@
 ;; Handle the "" case
 (if (looking-at-p "\"")
 (progn
-  ;; (message "Empty double quoted string from %s to %s" end 
(+ end 1))
-  (phps-mode/RETURN_TOKEN 'T_CONSTANT_ENCAPSED_STRING end (+ 
end 1))
+  ;; (message "Empty double quoted string from %s to %s" start 
(+ start 2))
+  (phps-mode/RETURN_TOKEN 'T_CONSTANT_ENCAPSED_STRING start (+ 
start 2))
   (forward-char))
   (progn
 ;; (message "Found no ending quote, skipping to end")
diff --git a/phps-test-lexer.el b/phps-test-lexer.el
index e7d75fb..781668b 100644
--- a/phps-test-lexer.el
+++ b/phps-test-lexer.el
@@ -92,17 +92,17 @@
   (phps-mode/with-test-buffer
" '123');"



[elpa] externals/phps-mode 7fa9fdb 024/405: More unit tests for lexing comments and doc comments

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 7fa9fdbd99677f6c9de02b2e1d676dd303ed
Author: Christian Johansson 
Commit: Christian Johansson 

More unit tests for lexing comments and doc comments
---
 phps-test-lexer.el | 5 +
 1 file changed, 5 insertions(+)

diff --git a/phps-test-lexer.el b/phps-test-lexer.el
index 2e6d918..719988a 100644
--- a/phps-test-lexer.el
+++ b/phps-test-lexer.el
@@ -129,6 +129,11 @@
   '((T_OPEN_TAG 1 . 7) (T_ECHO 7 . 11) (T_ISSET 12 . 17) ("(" 
17 . 18) (T_VARIABLE 18 . 28) ("[" 28 . 29) (T_LNUMBER 29 . 30) ("]" 30 . 31) 
("[" 31 . 32) (T_CONSTANT_ENCAPSED_STRING 32 . 38) ("]" 38 . 39) (")" 39 . 40) 
("?" 41 . 42) (T_CONSTANT_ENCAPSED_STRING 43 . 48) (":" 49 . 50) 
(T_CONSTANT_ENCAPSED_STRING 51 . 55) (";" 55 . 56)
 
   (phps-mode/with-test-buffer
+   ""
+   (should (equal phps-mode/lexer-tokens
+  '((T_OPEN_TAG 1 . 7) (T_ECHO 7 . 11) (T_ISSET 12 . 17) ("(" 
17 . 18) (T_VARIABLE 18 . 28) ("[" 28 . 29) (T_LNUMBER 29 . 30) ("]" 30 . 31) 
("[" 31 . 32) (T_CONSTANT_ENCAPSED_STRING 32 . 38) ("]" 38 . 39) (")" 39 . 40) 
("?" 41 . 42) (T_CONSTANT_ENCAPSED_STRING 43 . 48) (":" 49 . 50) 
(T_CONSTANT_ENCAPSED_STRING 51 . 55) (";" 55 . 56) (T_COMMENT 57 . 75) 
(T_COMMENT 76 . 101) (T_DOC_COMMENT 102 . 134) (T_ECHO 135 . 139) (T_VARIABLE 
140 . 150) (";" 150 . 151) (";" 152 . 154)  [...]
+
+  (phps-mode/with-test-buffer
"

[elpa] externals/phps-mode ce656a5 006/405: More general cleaning up

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit ce656a57256030c3f421c449b6c0b4a252d83998
Author: Christian Johansson 
Commit: Christian Johansson 

More general cleaning up
---
 phps-automation.el   |  8 +++--
 phps-flymake.el  |  3 +-
 phps-font-lock.el| 93 +---
 phps-map.el  |  2 ++
 phps-syntax-table.el |  1 -
 5 files changed, 9 insertions(+), 98 deletions(-)

diff --git a/phps-automation.el b/phps-automation.el
index 3ab13df..46687fc 100644
--- a/phps-automation.el
+++ b/phps-automation.el
@@ -1,8 +1,9 @@
-;;; phps-automation --- Genereate a Wisent Parser file
+;;; phps-automation --- Generate a Wisent Parser file
 
 
 ;;; Commentary:
 
+
 ;;; Uses a parser to convert LALR Yacc grammar to Wisent grammar
 
 ;;; AST should be like this: (root (block (rule (logic
@@ -10,6 +11,7 @@
 
 ;;; Code:
 
+
 (add-to-list 'load-path (expand-file-name 
"~/.emacs.d/emacs-wisent-grammar-converter/"))
 (require 'emacs-wisent-grammar-converter)
 
@@ -28,5 +30,5 @@
   (emacs-wisent-grammar-converter/generate-grammar-from-filename php-yacc-file 
wisent-destination)
   (message "Automation completed"))
 
-(provide 'phps-automation2)
-;;; phps-automation2.el ends here
+(provide 'phps-automation)
+;;; phps-automation.el ends here
diff --git a/phps-flymake.el b/phps-flymake.el
index 6da1421..05dddca 100644
--- a/phps-flymake.el
+++ b/phps-flymake.el
@@ -32,9 +32,8 @@
 
 ;;; Commentary:
 
-;; Please see README.md from the same repository for extended documentation.
 
-;;; Commentary:
+;; Please see README.md from the same repository for extended documentation.
 
 
 ;;; Code:
diff --git a/phps-font-lock.el b/phps-font-lock.el
index ca28b42..7b23db9 100644
--- a/phps-font-lock.el
+++ b/phps-font-lock.el
@@ -32,103 +32,13 @@
 
 ;;; Commentary:
 
-;; Please see README.md from the same repository for extended documentation.
 
-;;; Commentary:
+;; Please see README.md from the same repository for extended documentation.
 
 
 ;;; Code:
 
 
-(defconst phps-mode/keywords
-  (list
- "__halt_compiler"
- "abstract"
- "and"
- "array"
- "as"
- "break"
- "callable"
- "case"
- "catch"
- "class"
- "clone"
- "const"
- "continue"
- "declare"
- "default"
- "die"
- "do"
- "echo"
- "else"
- "elseif"
- "empty"
- "enddeclare"
- "endfor"
- "endforeach"
- "endif"
- "endswitch"
- "endwhile"
- "eval"
- "exit"
- "extends"
- "final"
- "finally"
- "for"
- "foreach"
- "function"
- "global"
- "goto"
- "if"
- "implements"
- "include"
- "include_once"
- "instanceof"
- "insteadof"
- "interface"
- "isset"
- "list"
- "namespace"
- "new"
- "or"
- "print"
- "private"
- "protected"
- "public"
- "require"
- "require_once"
- "return"
- "static"
- "switch"
- "throw"
- "trait"
- "try"
- "unset"
- "use"
- "var"
- "while"
- "xor"
- "yield"
-
- ;; Compile-time constants here
- "__CLASS__"
- "__DIR__"
- "__FILE__"
- "__FUNCTION__"
- "__LINE__"
- "__METHOD__"
- "__NAMESPACE__"
- "__TRAIT__"
-   )
-  "Use list of keywords to build regular expression for syntax highlighting.")
-
-(defconst phps-mode/font-lock-keywords
-  (let ((regex (concat "\\<" (regexp-opt phps-mode/keywords t) "\\>")))
-(list
- `(,regex . font-lock-builtin-face)
- '("\\('\\w*'\\)" . font-lock-variable-name-face)))
-  "Minimal highlighting expressions for major mode.")
-
 (defun phps-mode/font-lock-init ()
   "Apply font-lock."
 
@@ -137,7 +47,6 @@
   ;; This makes it possible to have full control over syntax coloring from the 
lexer
   (set (make-local-variable 'font-lock-defaults) '(nil t))
 
-  ;; (set (make-local-variable 'font-lock-defaults) 
'(phps-mode/font-lock-keywords))
   )
 
 (provide 'phps-mode/font-lock)
diff --git a/phps-map.el b/phps-map.el
index 12320a6..e398e31 100644
--- a/phps-map.el
+++ b/phps-map.el
@@ -30,8 +30,10 @@
 
 ;;; Commentary:
 
+
 ;; Please see README.md from the same repository for extended documentation.
 
+
 ;;; Code:
 
 
diff --git a/phps-syntax-table.el b/phps-syntax-table.el
index 0bd9e61..c35268b 100644
--- a/phps-syntax-table.el
+++ b/phps-syntax-table.el
@@ -65,7 +65,6 @@
 
 (defun phps-mode/syntax-table-init ()
   "Apply syntax table."
-  ;; (setq font-lock-keywords-only t)
   (set-syntax-table phps-mode/syntax-table))
 
 (provide 'phps-mode/syntax-table)



[elpa] externals/phps-mode f3205d5 011/405: Fixed lexing of basic tokens

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit f3205d56c5244a8a6bd36a68a6e5f133cd032d8f
Author: Christian Johansson 
Commit: Christian Johansson 

Fixed lexing of basic tokens
---
 phps-lexer.el  | 8 ++--
 phps-test-lexer.el | 9 +++--
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/phps-lexer.el b/phps-lexer.el
index af9db86..c5713b3 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -146,7 +146,7 @@
 (defvar phps-mode/TABS_AND_SPACES "[ \t]*"
   "Tabs and whitespaces.")
 
-(defvar phps-mode/TOKENS "[;\\:,.()^&+-/*=%!~\\$<>?@]"
+(defvar phps-mode/TOKENS "[][;\\:,\.()|^&+-/*=%!~\\$<>?@]"
   "Tokens.")
 
 (defvar phps-mode/ANY_CHAR ".\\|\n"
@@ -838,7 +838,7 @@
 (phps-mode/RETURN_TOKEN 'T_CONSTANT_ENCAPSED_STRING start (+ 
end 1))
   (progn
 ;; Unclosed single quotes
-(message "Single quoted string never ends..")
+;; (message "Single quoted string never ends..")
 (phps-mode/RETURN_TOKEN 'T_ENCAPSED_AND_WHITESPACE start 
(point-max))
 (phps-mode/MOVE_FORWARD (point-max))
 )))
@@ -896,8 +896,12 @@
((looking-at phps-mode/LABEL)
 (phps-mode/RETURN_TOKEN 'T_STRING (match-beginning 0) (match-end 0)))
 
+   ((looking-at phps-mode/TOKENS)
+(phps-mode/RETURN_TOKEN (match-string 0) (match-beginning 0) (match-end 
0)))
+
((looking-at phps-mode/ANY_CHAR)
 ;; Unexpected character
+;; (message "Unexpected character '%s'" (buffer-substring (match-beginning 
0) (match-end 0)))
 (phps-mode/RETURN_TOKEN 'T_ERROR (match-beginning 0) (point-max))
 (phps-mode/MOVE_FORWARD (point-max)))
 
diff --git a/phps-test-lexer.el b/phps-test-lexer.el
index efdb9af..78a0674 100644
--- a/phps-test-lexer.el
+++ b/phps-test-lexer.el
@@ -117,12 +117,17 @@
   (string-tokens (phps-mode/token-stream-to-string tokens)))
  (should (equal string-tokens " T_OPEN_TAG T_ECHO T_VARIABLE = T_ARRAY ( 
T_CONSTANT_ENCAPSED_STRING T_DOUBLE_ARROW T_CONSTANT_ENCAPSED_STRING ) ;"
 
-  ;; TODO Fix this
+  (phps-mode/with-test-buffer
+   "

[elpa] externals/phps-mode e3a060a 026/405: Handles script breaking single-line comments

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit e3a060acef2c726c2d3c3c3986b7000f6c1caddc
Author: Christian Johansson 
Commit: Christian Johansson 

Handles script breaking single-line comments
---
 phps-lexer.el  | 6 --
 phps-test-lexer.el | 7 +++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/phps-lexer.el b/phps-lexer.el
index 1529dd7..52c2a5a 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -779,13 +779,15 @@
 (let* ((start (match-beginning 0))
(end (match-end 0))
(data (buffer-substring-no-properties start end))
-   (line (buffer-substring-no-properties (line-beginning-position) 
(line-end-position
+   (line (buffer-substring-no-properties end (line-end-position
   (if (string-match "\\?>" line)
   (progn
-(phps-mode/RETURN_TOKEN 'T_COMMENT start (match-end 0))
+;; (message "Found comment 1 from %s to %s %s in %s" end (+ end 
(match-beginning 0)) (match-beginning 0) line)
+(phps-mode/RETURN_TOKEN 'T_COMMENT start (+ end (match-beginning 
0)))
 )
 (progn
   ;; TODO Handle expecting values here
+  ;; (message "Found comment 2 from %s to %s" start 
(line-end-position))
   (phps-mode/RETURN_TOKEN 'T_COMMENT start (line-end-position))
   
 
diff --git a/phps-test-lexer.el b/phps-test-lexer.el
index 62bbe0d..95d592c 100644
--- a/phps-test-lexer.el
+++ b/phps-test-lexer.el
@@ -134,6 +134,13 @@
   '((T_OPEN_TAG 1 . 7) (T_STRING 7 . 17) ("(" 17 . 18) (")" 18 
. 19) (";" 19 . 20)
 
   (phps-mode/with-test-buffer
+   ""
+   (should (equal phps-mode/lexer-tokens
+  '((T_OPEN_TAG 1 . 7) (T_COMMENT 7 . 24) (";" 24 . 26) 
(T_CLOSE_TAG 24 . 26)
+
+
+
+  (phps-mode/with-test-buffer
""
(should (equal phps-mode/lexer-tokens
   '((T_OPEN_TAG 1 . 7) (T_ECHO 7 . 11) (T_ISSET 12 . 17) ("(" 
17 . 18) (T_VARIABLE 18 . 28) ("[" 28 . 29) (T_LNUMBER 29 . 30) ("]" 30 . 31) 
("[" 31 . 32) (T_CONSTANT_ENCAPSED_STRING 32 . 38) ("]" 38 . 39) (")" 39 . 40) 
("?" 41 . 42) (T_CONSTANT_ENCAPSED_STRING 43 . 48) (":" 49 . 50) 
(T_CONSTANT_ENCAPSED_STRING 51 . 55) (";" 55 . 56) (T_COMMENT 57 . 75) 
(T_COMMENT 76 . 101) (T_DOC_COMMENT 102 . 134) (T_ECHO 135 . 139) (T_VARIABLE 
140 . 150) (";" 150 . 151) (";" 152 . 154)  [...]



[elpa] externals/phps-mode 4fa9341 030/405: Started with unit tests for indentation

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 4fa93419dab111cb8fbbb185fc35987ea3c41ee2
Author: Christian Johansson 
Commit: Christian Johansson 

Started with unit tests for indentation
---
 phps-lexer.el  | 28 ++--
 phps-test-lexer.el | 18 ++
 sample-php-files/class.php |  2 +-
 3 files changed, 37 insertions(+), 11 deletions(-)

diff --git a/phps-lexer.el b/phps-lexer.el
index 52c2a5a..979a383 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -1261,6 +1261,7 @@ ANY_CHAR'
   "Return information about point in tokens."
   ;; (message "Point: %s in %s" (point) phps-mode/lexer-tokens)
   (let ((position (point))
+(line-end (line-end-position))
 (in-scripting nil)
 (brace-level 0)
 (parenthesis-level 0)
@@ -1272,19 +1273,26 @@ ANY_CHAR'
   (end (cdr (cdr item
   ;; (message "Token: %s Start: %s End: %s Item: %s" token start end 
item)
 
-  (when (> start position)
+  (when (> start line-end)
 ;; (message "Stopping iteration at: %s %s" start position)
 (throw 'stop-iteration nil))
 
-  (pcase token
-('T_OPEN_TAG (setq in-scripting t))
-('T_OPEN_TAG_WITH_ECHO (setq in-scripting t))
-('T_CLOSE_TAG (setq in-scripting nil))
-("{" (setq brace-level (+ brace-level 1)))
-("}" (setq brace-level (- brace-level 1)))
-("(" (setq parenthesis-level (+ parenthesis-level 1)))
-(")" (setq parenthesis-level (- parenthesis-level 1)))
-(_))
+  ;; When start of token is equal or less to current point
+  (when (<= start position)
+(pcase token
+  ('T_OPEN_TAG (setq in-scripting t))
+  ('T_OPEN_TAG_WITH_ECHO (setq in-scripting t))
+  ('T_CLOSE_TAG (setq in-scripting nil))
+  ("{" (setq brace-level (+ brace-level 1)))
+  ("(" (setq parenthesis-level (+ parenthesis-level 1)))
+  (")" (setq parenthesis-level (- parenthesis-level 1)))
+  (_)))
+
+  ;; When start of token is equal or less to end of curent line
+  (when (<= start line-end)
+(pcase token
+  ("}" (setq brace-level (- brace-level 1)))
+  (_)))
   
   )))
 (let ((data (list in-scripting brace-level parenthesis-level 
inline-function-level)))
diff --git a/phps-test-lexer.el b/phps-test-lexer.el
index 5db8f02..c96499c 100644
--- a/phps-test-lexer.el
+++ b/phps-test-lexer.el
@@ -306,6 +306,23 @@
 
   )
 
+(defun phps-mode/test-indentation ()
+  "Test for indentation."
+  (phps-mode/with-test-buffer
+   "Bla bla"
+   (goto-char 69)
+   (phps-mode/indent-line)
+   (let ((buffer-contents (buffer-substring-no-properties (point-min) 
(point-max
+ (should (equal buffer-contents  "Bla bla")))
+   (goto-char 85)
+   (phps-mode/indent-line)
+   (let ((buffer-contents (buffer-substring-no-properties (point-min) 
(point-max
+ (should (equal buffer-contents  "Bla bla")))
+   (goto-char 98)
+   (phps-mode/indent-line)
+   (let ((buffer-contents (buffer-substring-no-properties (point-min) 
(point-max
+ (should (equal buffer-contents  "Bla bla")
+
 (defun phps-mode/test-lexer ()
   "Run test for lexer."
   ;; (message "-- Running all tests for lexer... --\n")
@@ -316,6 +333,7 @@
   (phps-mode/test-lexer--namespaces)
   (phps-mode/test-lexer--errors)
   (phps-mode/test-lexer--get-point-data)
+  (phps-mode/test-indentation)
   ;; (message "\n-- Ran all tests for lexer. --")
   )
 
diff --git a/sample-php-files/class.php b/sample-php-files/class.php
index fef6bfe..50c292a 100644
--- a/sample-php-files/class.php
+++ b/sample-php-files/class.php
@@ -17,7 +17,7 @@ class MyClass {
 }
 
 public function myMethod2() {
-   echo "Some stuff here 2";
+echo "Some stuff here 2";
 }
 
 public function myMethod3() {



[elpa] externals/phps-mode 5a6a96b 012/405: Added another test

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 5a6a96bbcd32480fdf10f65ac747c9bf6eae419d
Author: Christian Johansson 
Commit: Christian Johansson 

Added another test
---
 phps-test-lexer.el | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/phps-test-lexer.el b/phps-test-lexer.el
index 78a0674..0d329a0 100644
--- a/phps-test-lexer.el
+++ b/phps-test-lexer.el
@@ -106,6 +106,12 @@
  (should (equal string-tokens " T_OPEN_TAG T_ECHO T_VARIABLE = T_ARRAY ( 
T_CONSTANT_ENCAPSED_STRING ) ;"
 
   (phps-mode/with-test-buffer
+   "

[elpa] externals/phps-mode bf59f0a 023/405: More unit tests for getting point lex information

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit bf59f0aab3ef7bad1916dae6efb753c764aa1df4
Author: Christian Johansson 
Commit: Christian Johansson 

More unit tests for getting point lex information
---
 phps-test-lexer.el | 30 ++
 1 file changed, 30 insertions(+)

diff --git a/phps-test-lexer.el b/phps-test-lexer.el
index 3b3059f..2e6d918 100644
--- a/phps-test-lexer.el
+++ b/phps-test-lexer.el
@@ -252,6 +252,36 @@
(goto-char 15)
(should (equal (list nil 0 0 0) (phps-mode/lexer-get-point-data
 
+  (phps-mode/with-test-buffer
+   "Bla 
bla"
+   (goto-char 30)
+   (should (equal (list t 0 0 0) (phps-mode/lexer-get-point-data
+
+  (phps-mode/with-test-buffer
+   "Bla 
bla"
+   (goto-char 50)
+   (should (equal (list nil 0 0 0) (phps-mode/lexer-get-point-data
+
+  (phps-mode/with-test-buffer
+   "Bla bla"
+   (goto-char 60)
+   (should (equal (list t 1 1 0) (phps-mode/lexer-get-point-data
+
+  (phps-mode/with-test-buffer
+   "Bla bla"
+   (goto-char 70)
+   (should (equal (list t 2 0 0) (phps-mode/lexer-get-point-data
+
+  (phps-mode/with-test-buffer
+   "Bla bla"
+   (goto-char 85)
+   (should (equal (list t 1 0 0) (phps-mode/lexer-get-point-data
+
+  (phps-mode/with-test-buffer
+   "Bla bla"
+   (goto-char 100)
+   (should (equal (list nil 0 0 0) (phps-mode/lexer-get-point-data
+
   )
 
 (defun phps-mode/test-lexer ()



[elpa] externals/phps-mode dd8d800 004/405: Using coloring overlay for comments as well

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit dd8d800dd3a2e8588e70638dad733c0fe4737cb5
Author: Christian Johansson 
Commit: Christian Johansson 

Using coloring overlay for comments as well
---
 phps-lexer.el   | 3 +--
 tests/php/class.php | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/phps-lexer.el b/phps-lexer.el
index 4ba9eef..a708d6e 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -189,7 +189,6 @@
   "Move forward to POSITION."
   (setq semantic-lex-end-point position))
 
-;; TODO Use font-lock-syntactic-face-function instead?
 (defun phps-mode/COLOR_SYNTAX (token start end)
   "Syntax coloring for TOKEN from START to END."
   ;; Syntax coloring
@@ -213,7 +212,7 @@
 (overlay-put (make-overlay start end) 'font-lock-face 
'font-lock-variable-name-face))
 
((string= token 'T_COMMENT)
-(add-text-properties start end '(font-lock-face font-lock-comment-face)))
+(overlay-put (make-overlay start end) 'font-lock-face 
'font-lock-comment-face))
 
((string= token 'T_DOC_COMMENT)
 (overlay-put (make-overlay start end) 'font-lock-face 
'font-lock-comment-delimiter-face))
diff --git a/tests/php/class.php b/tests/php/class.php
index e43c12b..05a5e11 100644
--- a/tests/php/class.php
+++ b/tests/php/class.php
@@ -1,7 +1,7 @@
 

[elpa] externals/phps-mode 95e749e 028/405: Started with indentation function

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 95e749e69fbc68b705ade0a453846af47e7fb9ac
Author: Christian Johansson 
Commit: Christian Johansson 

Started with indentation function
---
 phps-functions.el | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/phps-functions.el b/phps-functions.el
index 48aac15..9b8382a 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -38,7 +38,14 @@
 
 (defun phps-mode/indent-line ()
   "Indent line."
-  )
+  (let ((data (phps-mode/lexer-get-point-data)))
+(if (nth 0 data)
+(progn
+  (message "inside scripting %s" data)
+  (indent-line-to (nth 1 data)))
+  (progn
+(message "Outside scripting %s" data)
+(indent-relative)
 
 (defun phps-mode/indent-region ()
   "Indent region."
@@ -47,7 +54,7 @@
 (defun phps-mode/functions-init ()
   "PHP specific init-cleanup routines."
 
-  ;; (set (make-local-variable 'indent-line-function) #'phps-mode/indent-line)
+  (set (make-local-variable 'indent-line-function) #'phps-mode/indent-line)
   ;; (set (make-local-variable 'indent-line-function) 
#'phps-mode/indent-region)
   )
 



[elpa] externals/phps-mode 1b891ea 031/405: More work on indentation and related tests

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 1b891ea83c61fbd3bd745b8fd65186d3c3718ea8
Author: Christian Johansson 
Commit: Christian Johansson 

More work on indentation and related tests
---
 phps-functions.el  |  25 +++--
 phps-lexer.el  | 105 ++---
 phps-test-lexer.el |  50 +++--
 3 files changed, 103 insertions(+), 77 deletions(-)

diff --git a/phps-functions.el b/phps-functions.el
index e6bf6d3..57f59c6 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -38,17 +38,20 @@
 
 (defun phps-mode/indent-line ()
   "Indent line."
-  (save-excursion
-(beginning-of-line)
-(let ((data (phps-mode/lexer-get-point-data)))
-  ;; Are we in scripting?
-  (if (nth 0 data)
-  (let ((indent-level (* (+ (nth 1 data) (nth 2 data)) 4)))
-(message "inside scripting %s, indenting to column %s " data 
indent-level)
-(indent-line-to indent-level))
-(progn
-  (message "Outside scripting %s" data)
-  (indent-relative))
+  (let ((data (phps-mode/lexer-get-point-data)))
+(save-excursion
+  (beginning-of-line)
+  (let ((start (nth 0 data))
+(end (nth 1 data)))
+
+;; Are we in scripting?
+(if (nth 0 start)
+(let ((indent-level (* (+ (nth 1 start) (nth 2 start)) 4)))
+  (message "inside scripting, start: %s, end: %s, indenting to 
column %s " start end indent-level)
+  (indent-line-to indent-level))
+  (progn
+(message "Outside scripting %s" start)
+(indent-relative)))
 
 (defun phps-mode/indent-region ()
   "Indent region."
diff --git a/phps-lexer.el b/phps-lexer.el
index 979a383..da663ec 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -368,12 +368,12 @@
   "Push TOKEN to list with START and END."
   (phps-mode/COLOR_SYNTAX token start end)
 
-  (when (and
- phps-mode/prepend_trailing_brace
- (> end (- (point-max) 2)))
-;; (message "Adding trailing brace")
-(setq phps-mode/prepend_trailing_brace nil)
-(phps-mode/RETURN_TOKEN "}" (- end 1) end))
+  ;; (when (and
+  ;;phps-mode/prepend_trailing_brace
+  ;;(> end (- (point-max) 2)))
+  ;;   ;; (message "Adding trailing brace")
+  ;;   (setq phps-mode/prepend_trailing_brace nil)
+  ;;   (phps-mode/RETURN_TOKEN "}" (- end 1) end))
 
   ;; (message "Added token %s %s %s" token start end)
 
@@ -834,7 +834,7 @@
 (when (string= data ";")
   (setq phps-mode/prepend_trailing_brace t)
   ;; (message "Set flag prepend trailing brace")
-  (setq use-brace t)
+  ;; (setq use-brace t)
   )
 (setq phps-mode/declaring_namespace nil))
   (if use-brace
@@ -1260,45 +1260,58 @@ ANY_CHAR'
 (defun phps-mode/lexer-get-point-data()
   "Return information about point in tokens."
   ;; (message "Point: %s in %s" (point) phps-mode/lexer-tokens)
-  (let ((position (point))
-(line-end (line-end-position))
-(in-scripting nil)
-(brace-level 0)
-(parenthesis-level 0)
-(inline-function-level 0))
-(catch 'stop-iteration
-  (dolist (item phps-mode/lexer-tokens)
-(let ((token (car item))
-  (start (car (cdr item)))
-  (end (cdr (cdr item
-  ;; (message "Token: %s Start: %s End: %s Item: %s" token start end 
item)
-
-  (when (> start line-end)
-;; (message "Stopping iteration at: %s %s" start position)
-(throw 'stop-iteration nil))
-
-  ;; When start of token is equal or less to current point
-  (when (<= start position)
-(pcase token
-  ('T_OPEN_TAG (setq in-scripting t))
-  ('T_OPEN_TAG_WITH_ECHO (setq in-scripting t))
-  ('T_CLOSE_TAG (setq in-scripting nil))
-  ("{" (setq brace-level (+ brace-level 1)))
-  ("(" (setq parenthesis-level (+ parenthesis-level 1)))
-  (")" (setq parenthesis-level (- parenthesis-level 1)))
-  (_)))
-
-  ;; When start of token is equal or less to end of curent line
-  (when (<= start line-end)
-(pcase token
-  ("}" (setq brace-level (- brace-level 1)))
-  (_)))
-  
-  )))
-(let ((data (list in-scripting brace-level parenthesis-level 
inline-function-level)))
-  ;; (message "data: %s" data)
-  data)
-))
+  (save-excursion
+(beginning-of-line)
+(let ((position (point))
+  (line-end (line-end-position))
+  (start-in-scripting nil)
+  (start-brace-level 0)
+  (start-parenthesis-level 0)
+  (start-inline-function-level 0)
+  (end-in-scripting nil)
+  (end-brace-level 0)
+  (end-parenthesis-level 0)
+  (end-inline-function-level 0))
+  (catch 'stop-iteration
+(dolist (item phps-mode/lexer-tokens)
+  (let ((token (car i

[elpa] externals/phps-mode 47440dd 036/405: Added test for decreasing indentation with letters

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 47440ddc6c74a161c7de015bd3132e59a4b9d672
Author: Christian Johansson 
Commit: Christian Johansson 

Added test for decreasing indentation with letters
---
 phps-functions.el  | 3 ++-
 phps-test-functions.el | 9 -
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/phps-functions.el b/phps-functions.el
index 1d26588..cc2bc7a 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -50,7 +50,8 @@
 (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)
+  (when (and (> indent-start indent-end)
+ (looking-at-p "^[][ \t)(}{};]+\\($\\|?>\\)"))
 (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)
diff --git a/phps-test-functions.el b/phps-test-functions.el
index f5f637f..3f6543e 100644
--- a/phps-test-functions.el
+++ b/phps-test-functions.el
@@ -81,13 +81,20 @@
(let ((buffer-contents (buffer-substring-no-properties (point-min) 
(point-max
  (should (equal buffer-contents  "

[elpa] externals/phps-mode a724438 010/405: Handled lexing with empty single and double quote string

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit a7244384cf8b403235b7a1ed51888eadad7b1afa
Author: Christian Johansson 
Commit: Christian Johansson 

Handled lexing with empty single and double quote string
---
 phps-lexer.el  | 39 ++-
 phps-test-lexer.el | 25 +
 2 files changed, 47 insertions(+), 17 deletions(-)

diff --git a/phps-lexer.el b/phps-lexer.el
index 2f104fc..af9db86 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -831,13 +831,17 @@
 (if string-start
 (progn
   ;; (message "Single quoted string %s" (buffer-substring start 
string-start))
-  (phps-mode/RETURN_TOKEN 'T_CONSTANT_ENCAPSED_STRING start (+ 
string-start 1)))
+  (phps-mode/RETURN_TOKEN 'T_CONSTANT_ENCAPSED_STRING start 
string-start))
   (progn
-;; Unclosed single quotes
-;; (message "Single quoted string never ends..")
-(phps-mode/RETURN_TOKEN 'T_ENCAPSED_AND_WHITESPACE start 
(point-max))
-(phps-mode/MOVE_FORWARD (point-max))
-)
+;; Handle the '' case
+(if (looking-at-p "'")
+(phps-mode/RETURN_TOKEN 'T_CONSTANT_ENCAPSED_STRING start (+ 
end 1))
+  (progn
+;; Unclosed single quotes
+(message "Single quoted string never ends..")
+(phps-mode/RETURN_TOKEN 'T_ENCAPSED_AND_WHITESPACE start 
(point-max))
+(phps-mode/MOVE_FORWARD (point-max))
+)))
 
;; Double quoted string
((looking-at "\"")
@@ -862,18 +866,19 @@
 (let ((double-quoted-string (buffer-substring start (+ 
string-start 2
   ;; (message "Double quoted string: %s" 
double-quoted-string)
   (phps-mode/RETURN_TOKEN 'T_CONSTANT_ENCAPSED_STRING 
start (+ string-start 2
-  (progn
-;; (message "Found variable after '%s'" (buffer-substring 
start (point)))
-(phps-mode/BEGIN phps-mode/ST_DOUBLE_QUOTES)
-(phps-mode/RETURN_TOKEN "\"" start (+ start 1))
-(phps-mode/RETURN_TOKEN 'T_ENCAPSED_AND_WHITESPACE (+ 
start 1) string-start)
-)
-))
+(progn
+  ;; (message "Found variable after '%s'" (buffer-substring 
start (point)))
+  (phps-mode/BEGIN phps-mode/ST_DOUBLE_QUOTES)
+  (phps-mode/RETURN_TOKEN "\"" start (+ start 1))
+  (phps-mode/RETURN_TOKEN 'T_ENCAPSED_AND_WHITESPACE (+ start 
1) string-start
   (progn
-;; (message "Found no ending quote, skipping to end")
-(phps-mode/RETURN_TOKEN 'T_ERROR start (point-max))
-(phps-mode/MOVE_FORWARD (point-max))
-)
+;; Handle the "" case
+(if (looking-at-p "\"")
+(phps-mode/RETURN_TOKEN 'T_CONSTANT_ENCAPSED_STRING start (+ 
end 1))
+  (progn
+;; (message "Found no ending quote, skipping to end")
+(phps-mode/RETURN_TOKEN 'T_ERROR start (point-max))
+(phps-mode/MOVE_FORWARD (point-max)
 
((looking-at "[`]")
 ;; (message "Begun backquote at %s-%s" (match-beginning 0) (match-end 0))
diff --git a/phps-test-lexer.el b/phps-test-lexer.el
index 314d47f..efdb9af 100644
--- a/phps-test-lexer.el
+++ b/phps-test-lexer.el
@@ -100,6 +100,31 @@
   "Run test for simple tokens."
 
   (phps-mode/with-test-buffer
+   " '123');"
+   (let* ((tokens phps-mode/lexer-tokens)
+  (string-tokens (phps-mode/token-stream-to-string tokens)))
+ (should (equal string-tokens " T_OPEN_TAG T_ECHO T_VARIABLE = T_ARRAY ( 
T_CONSTANT_ENCAPSED_STRING T_DOUBLE_ARROW T_CONSTANT_ENCAPSED_STRING ) ;"
+
+  ;; TODO Fix this
+  (phps-mode/with-test-buffer
+   "

[elpa] externals/phps-mode d839f8a 029/405: More work on indentation support

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit d839f8aa113d523d50cd8fcc57b1519c283b5293
Author: Christian Johansson 
Commit: Christian Johansson 

More work on indentation support
---
 phps-functions.el  | 18 +++---
 phps-test-lexer.el |  9 +
 2 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/phps-functions.el b/phps-functions.el
index 9b8382a..e6bf6d3 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -38,14 +38,17 @@
 
 (defun phps-mode/indent-line ()
   "Indent line."
-  (let ((data (phps-mode/lexer-get-point-data)))
-(if (nth 0 data)
+  (save-excursion
+(beginning-of-line)
+(let ((data (phps-mode/lexer-get-point-data)))
+  ;; Are we in scripting?
+  (if (nth 0 data)
+  (let ((indent-level (* (+ (nth 1 data) (nth 2 data)) 4)))
+(message "inside scripting %s, indenting to column %s " data 
indent-level)
+(indent-line-to indent-level))
 (progn
-  (message "inside scripting %s" data)
-  (indent-line-to (nth 1 data)))
-  (progn
-(message "Outside scripting %s" data)
-(indent-relative)
+  (message "Outside scripting %s" data)
+  (indent-relative))
 
 (defun phps-mode/indent-region ()
   "Indent region."
@@ -55,6 +58,7 @@
   "PHP specific init-cleanup routines."
 
   (set (make-local-variable 'indent-line-function) #'phps-mode/indent-line)
+  (set (make-local-variable 'tab-width) 8)
   ;; (set (make-local-variable 'indent-line-function) 
#'phps-mode/indent-region)
   )
 
diff --git a/phps-test-lexer.el b/phps-test-lexer.el
index d78df2b..5db8f02 100644
--- a/phps-test-lexer.el
+++ b/phps-test-lexer.el
@@ -141,7 +141,7 @@
   (phps-mode/with-test-buffer
""
(should (equal phps-mode/lexer-tokens
-  '((T_OPEN_TAG 1 . 7) (T_COMMENT 7 . 32) (";" 32 . 34) 
(T_CLOSE_TAG 32 . 34))
+  '((T_OPEN_TAG 1 . 7) (T_COMMENT 7 . 32) (";" 32 . 34) 
(T_CLOSE_TAG 32 . 34)
 
 
   (phps-mode/with-test-buffer
@@ -284,9 +284,10 @@
(should (equal (list nil 0 0 0) (phps-mode/lexer-get-point-data
 
   (phps-mode/with-test-buffer
-   "Bla bla"
-   (goto-char 60)
-   (should (equal (list t 1 1 0) (phps-mode/lexer-get-point-data
+   "Bla bla"
+   ;; (message "Tokens: %s" phps-mode/lexer-tokens)
+   (goto-char 48)
+   (should (equal (list t 1 0 0) (phps-mode/lexer-get-point-data
 
   (phps-mode/with-test-buffer
"Bla bla"



[elpa] externals/phps-mode 8ed0716 022/405: Started with unit tests for getting point lexer data

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 8ed0716dd920d8a8ab7bdf484bc79c656773ceb5
Author: Christian Johansson 
Commit: Christian Johansson 

Started with unit tests for getting point lexer data
---
 phps-lexer.el  | 36 
 phps-test-lexer.el | 13 ++---
 2 files changed, 42 insertions(+), 7 deletions(-)

diff --git a/phps-lexer.el b/phps-lexer.el
index d9b6493..1529dd7 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -1257,10 +1257,38 @@ ANY_CHAR'
 
 (defun phps-mode/lexer-get-point-data()
   "Return information about point in tokens."
-  (message "Point: %s in %s" (point) phps-mode/lexer-tokens)
-  (dolist (item phps-mode/lexer-tokens)
-)
-  )
+  ;; (message "Point: %s in %s" (point) phps-mode/lexer-tokens)
+  (let ((position (point))
+(in-scripting nil)
+(brace-level 0)
+(parenthesis-level 0)
+(inline-function-level 0))
+(catch 'stop-iteration
+  (dolist (item phps-mode/lexer-tokens)
+(let ((token (car item))
+  (start (car (cdr item)))
+  (end (cdr (cdr item
+  ;; (message "Token: %s Start: %s End: %s Item: %s" token start end 
item)
+
+  (when (> start position)
+;; (message "Stopping iteration at: %s %s" start position)
+(throw 'stop-iteration nil))
+
+  (pcase token
+('T_OPEN_TAG (setq in-scripting t))
+('T_OPEN_TAG_WITH_ECHO (setq in-scripting t))
+('T_CLOSE_TAG (setq in-scripting nil))
+("{" (setq brace-level (+ brace-level 1)))
+("}" (setq brace-level (- brace-level 1)))
+("(" (setq parenthesis-level (+ parenthesis-level 1)))
+(")" (setq parenthesis-level (- parenthesis-level 1)))
+(_))
+  
+  )))
+(let ((data (list in-scripting brace-level parenthesis-level 
inline-function-level)))
+  ;; (message "data: %s" data)
+  data)
+))
 
 (defun phps-mode/lex--SETUP (start end)
   "Just prepare other lexers for lexing region START to END."
diff --git a/phps-test-lexer.el b/phps-test-lexer.el
index a45db16..3b3059f 100644
--- a/phps-test-lexer.el
+++ b/phps-test-lexer.el
@@ -239,12 +239,19 @@
 
   )
 
-(defun phps-mode/test-lexer-get-point-data ()
+(defun phps-mode/test-lexer--get-point-data ()
   "Return information about point in tokens."
+
   (phps-mode/with-test-buffer
"Bla 
bla"
+   (goto-char 15)
+   (should (equal (list nil 0 0 0) (phps-mode/lexer-get-point-data
+
   )
 
 (defun phps-mode/test-lexer ()
@@ -256,7 +263,7 @@
   (phps-mode/test-lexer--complex-tokens)
   (phps-mode/test-lexer--namespaces)
   (phps-mode/test-lexer--errors)
-  (phps-mode/test-lexer-get-point-data)
+  (phps-mode/test-lexer--get-point-data)
   ;; (message "\n-- Ran all tests for lexer. --")
   )
 



[elpa] externals/phps-mode 09daec3 052/405: Foundation for incremental lexer and syntax colorer completed

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 09daec397a5ffd17c4a0e852b26bcee7c7bae367
Author: Christian Johansson 
Commit: Christian Johansson 

Foundation for incremental lexer and syntax colorer completed
---
 phps-functions.el |  9 ++---
 phps-lexer.el | 46 --
 2 files changed, 46 insertions(+), 9 deletions(-)

diff --git a/phps-functions.el b/phps-functions.el
index a7b795b..0990be5 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -107,9 +107,12 @@
 (when (and (not phps-mode/buffer-changes--start)
(boundp 'phps-mode/idle-interval))
   (run-with-idle-timer phps-mode/idle-interval nil 
#'phps-mode/run-incremental-lex))
-(setq phps-mode/buffer-changes--start start)
-(message "phps-mode/after-change-functions %s %s %s" start stop length)
-  ))
+(when (or (not phps-mode/buffer-changes--start)
+  (< start phps-mode/buffer-changes--start))
+  ;; (message "Setting %s to %s" phps-mode/buffer-changes--start start)
+  (setq phps-mode/buffer-changes--start start))
+;; (message "phps-mode/after-change-functions %s %s %s" start stop length)
+))
 
 (defun phps-mode/functions-init ()
   "PHP specific init-cleanup routines."
diff --git a/phps-lexer.el b/phps-lexer.el
index 123a3cb..387f306 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -47,6 +47,9 @@
 (defvar phps-mode/lexer-tokens nil
   "Last lexer tokens.")
 
+(defvar phps-mode/lexer-states nil
+  "A list of lists containing start, state and state stack.")
+
 
 ;; SETTINGS
 
@@ -174,8 +177,7 @@
 
 (defun phps-mode/yy_pop_state ()
   "Pop current state from stack."
-  (let* ((old-state (pop phps-mode/state_stack))
- (new-state (car phps-mode/state_stack)))
+  (let ((old-state (pop phps-mode/state_stack)))
 ;; (message "Going back to poppped state %s" old-state)
 ;; (message "Ended state %s, going back to %s" old-state new-state)
 (if old-state
@@ -371,6 +373,9 @@
 
   ;; (message "Added token %s %s %s" token start end)
 
+  ;; Push token start, end, lexer state and state stack to variable
+  (push (list start end phps-mode/STATE phps-mode/state_stack) 
phps-mode/lexer-states)
+
   (semantic-lex-push-token
(semantic-lex-token token start end)))
 
@@ -1334,6 +1339,8 @@ ANY_CHAR'
 (delete-all-overlays)
 (when (boundp 'phps-mode/buffer-changes--start)
   (setq phps-mode/buffer-changes--start nil))
+
+(setq phps-mode/lexer-states nil)
 
 (phps-mode/BEGIN phps-mode/ST_INITIAL)))
 
@@ -1344,10 +1351,37 @@ ANY_CHAR'
 
 (defun phps-mode/run-incremental-lex ()
   "Run incremental lexer based on `phps-mode/buffer-changes--start'."
-  (when (boundp 'phps-mode/buffer-changes--start)
-(semantic-lex-buffer)
-;; TODO (message "Should run incremental lex here %s - %s" 
phps-mode/buffer-changes--start (point-max))
-;; TODO (semantic-lex phps-mode/buffer-changes--start (point-max))
+  (when (and (boundp 'phps-mode/buffer-changes--start)
+ phps-mode/buffer-changes--start
+ phps-mode/lexer-states)
+(let ((state nil)
+  (state-stack nil)
+  (new-states '())
+  (states (nreverse phps-mode/lexer-states))
+  (change-start phps-mode/buffer-changes--start)
+  (previous-token-start nil))
+  ;; (message "Looking for state to rewind to for %s in stack %s" 
change-start states)
+  (catch 'stop-iteration
+(dolist (state-object states)
+  (let ((start (nth 0 state-object))
+(end (nth 1 state-object)))
+(when (< end change-start)
+  (setq state (nth 2 state-object))
+  (setq state-stack (nth 3 state-object))
+  (setq previous-token-start start)
+  (push state-object new-states))
+(when (> start change-start)
+  (throw 'stop-iteration nil)
+  (if (and state
+   state-stack)
+  (progn
+(setq phps-mode/STATE state)
+(setq phps-mode/state_stack state-stack)
+(setq phps-mode/lexer-states new-states)
+;; (message "Rewinding lex to state: %s and stack: %s and states: 
%s and start: %s" state state-stack new-states previous-token-start)
+(semantic-lex previous-token-start (point-max)))
+(display-warning "phps-mode" (format "Found no state to rewind to for 
%s in stack %s" change-start states))
+(semantic-lex-buffer)))
 (setq phps-mode/buffer-changes--start nil)))
 
 (define-lex phps-mode/tags-lexer



[elpa] externals/phps-mode bf633d2 061/405: Added test for indent of final line of doc comment block

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit bf633d2d60859e196a1094a0097aae8c8f973699
Author: Christian Johansson 
Commit: Christian Johansson 

Added test for indent of final line of doc comment block
---
 phps-functions.el  |  8 +---
 phps-test-functions.el | 10 +-
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/phps-functions.el b/phps-functions.el
index 8b20457..8115cf1 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -113,7 +113,10 @@
   (when (string= major-mode "phps-mode")
 (when (and (not phps-mode/buffer-changes--start)
(boundp 'phps-mode/idle-interval))
-  (run-with-idle-timer phps-mode/idle-interval nil 
#'phps-mode/run-incremental-lex))
+  (run-with-idle-timer phps-mode/idle-interval nil #'phps-mode/lex--RUN)
+  ;; TODO Maybe use incremental lexer once it's working
+  ;; (run-with-idle-timer phps-mode/idle-interval nil 
#'phps-mode/run-incremental-lex) 
+  )
 (when (or (not phps-mode/buffer-changes--start)
   (< start phps-mode/buffer-changes--start))
   ;; (message "Setting %s to %s" phps-mode/buffer-changes--start start)
@@ -172,8 +175,7 @@
   (")" (setq start-parenthesis-level (- 
start-parenthesis-level 1)))
   (_)))
 
-  (when (and (> token-end line-end)
- (< token-start line-beginning)
+  (when (and (< token-start line-beginning)
  (eq token 'T_DOC_COMMENT))
 (setq line-in-doc-comment t))
 
diff --git a/phps-test-functions.el b/phps-test-functions.el
index 17cced3..1ead7e7 100644
--- a/phps-test-functions.el
+++ b/phps-test-functions.el
@@ -108,6 +108,14 @@
  (should (equal buffer-contents  "

[elpa] externals/phps-mode be46d9c 044/405: Added lexer autoload to functions

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit be46d9ca6ad12013b53164969f17c7ecd056d209
Author: Christian Johansson 
Commit: Christian Johansson 

Added lexer autoload to functions
---
 phps-functions.el | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/phps-functions.el b/phps-functions.el
index 052405e..7bdfe26 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -36,6 +36,8 @@
 ;;; Code:
 
 
+(autoload 'phps-mode/lexer-get-point-data "phps-lexer")
+
 (defun phps-mode/indent-line ()
   "Indent line."
   (let ((data (phps-mode/lexer-get-point-data)))
@@ -66,7 +68,8 @@
 
   (set (make-local-variable 'indent-line-function) #'phps-mode/indent-line)
 
-  (when phps-mode/use-psr-2
+  (when (and (boundp 'phps-mode/use-psr-2)
+ phps-mode/use-psr-2)
 
 ;; PSR-2 : Code MUST use an indent of 4 spaces
 (set (make-local-variable 'tab-width) 4)



[elpa] externals/phps-mode c64b3b4 008/405: More work on lexer tests

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit c64b3b402ad8ccc2771313927f935e9cb7cdfc2e
Author: Christian Johansson 
Commit: Christian Johansson 

More work on lexer tests
---
 phps-lexer.el| 42 +++---
 phps-syntax-table.el |  1 +
 phps-test-lexer.el   | 16 +++-
 3 files changed, 31 insertions(+), 28 deletions(-)

diff --git a/phps-lexer.el b/phps-lexer.el
index a708d6e..18179d2 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -158,7 +158,7 @@
 (defun phps-mode/BEGIN (state)
   "Begin STATE."
   (setq phps-mode/STATE state)
-  ;; (message "Begun state %s" state)
+  (message "Begun state %s" state)
   )
 
 ;; _yy_push_state
@@ -170,7 +170,7 @@
 (if (not phps-mode/state_stack)
 (setq phps-mode/state_stack (list old-state))
   (push old-state phps-mode/state_stack))
-;; (message "Added state %s to stack" old-state)
+(message "Added state %s to stack" old-state)
 )
   (phps-mode/BEGIN state))
 
@@ -178,8 +178,8 @@
   "Pop current state from stack."
   (let* ((old-state (pop phps-mode/state_stack))
  (new-state (car phps-mode/state_stack)))
-;; (message "Going back to poppped state %s" old-state)
-;; (message "Ended state %s, going back to %s" old-state new-state)
+(message "Going back to poppped state %s" old-state)
+(message "Ended state %s, going back to %s" old-state new-state)
 (if old-state
 (phps-mode/BEGIN old-state)
   (display-warning "phps-mode" "PHPs Lexer Error - Going back to nil?"))
@@ -362,19 +362,21 @@
 
 (defun phps-mode/RETURN_TOKEN (token start end)
   "Push TOKEN to list with START and END."
-
   (phps-mode/COLOR_SYNTAX token start end)
 
   (when (and
-   phps-mode/prepend_trailing_brace
-   (> end (- (point-max) 2)))
-;; (message "Adding trailing brace")
+ phps-mode/prepend_trailing_brace
+ (> end (- (point-max) 2)))
+(message "Adding trailing brace")
 (setq phps-mode/prepend_trailing_brace nil)
 (phps-mode/RETURN_TOKEN "}" (- end 1) end))
 
   (semantic-lex-push-token
-   (semantic-lex-token token start end))
+   (semantic-lex-token token start end)))
 
+;; TODO Figure out what this does
+(defun phps-mode/SKIP_TOKEN (token start end)
+  "Skip TOKEN to list with START and END."
   )
 
 
@@ -390,29 +392,31 @@
 (let ((start (match-beginning 0))
   (end (match-end 0)))
   (phps-mode/BEGIN phps-mode/ST_IN_SCRIPTING)
-  (if phps-mode/PARSER_MODE
-  (phps-mode/RETURN_TOKEN 'T_ECHO start end))
-(phps-mode/RETURN_TOKEN 'T_OPEN_TAG_WITH_ECHO start end)
-  ))
+  (message "Starting scripting after "
+   ""
(let* ((tokens (semantic-lex-buffer))
   (string-tokens (phps-mode/token-stream-to-string tokens)))
- (should (equal string-tokens " T_OPEN_TAG T_EXIT ; ; T_CLOSE_TAG"
+ (should (equal string-tokens " T_OPEN_TAG T_VARIABLE = T_LNUMBER ; T_EXIT 
T_VARIABLE ; ; T_CLOSE_TAG"
 
   (phps-mode/with-test-buffer
""
@@ -104,7 +103,6 @@
"

[elpa] externals/phps-mode b437374 040/405: Fixed bug in parsing of object parameters inside double quoted string

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit b437374df6aea5643e49ae489beb29592d9ba9f5
Author: Christian Johansson 
Commit: Christian Johansson 

Fixed bug in parsing of object parameters inside double quoted string
---
 phps-lexer.el  |  7 ---
 phps-test-lexer.el | 12 ++--
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/phps-lexer.el b/phps-lexer.el
index 61ad818..8fb5694 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -891,7 +891,7 @@
 ;; (message "Double quoted string: %s" 
double-quoted-string)
 (phps-mode/RETURN_TOKEN 'T_CONSTANT_ENCAPSED_STRING 
start (+ string-start 2
   (progn
-(message "Found variable after '%s'" 
(buffer-substring-no-properties start string-start))
+;; (message "Found variable after '%s'" 
(buffer-substring-no-properties start string-start))
 (phps-mode/BEGIN phps-mode/ST_DOUBLE_QUOTES)
 (phps-mode/RETURN_TOKEN "\"" start (+ start 1))
 (phps-mode/RETURN_TOKEN 'T_ENCAPSED_AND_WHITESPACE (+ 
start 1) string-start
@@ -986,7 +986,8 @@
 
((looking-at (concat "\\$" phps-mode/LABEL "->" "[a-zA-Z_\x80-\xff]"))
 (phps-mode/yy_push_state phps-mode/ST_LOOKING_FOR_PROPERTY)
-(phps-mode/RETURN_TOKEN 'T_VARIABLE (match-beginning 0) (match-end 0)))
+(forward-char -3)
+(phps-mode/RETURN_TOKEN 'T_VARIABLE (match-beginning 0) (- (match-end 0) 
3)))
 
((looking-at (concat "\\$" phps-mode/LABEL "\\["))
 (phps-mode/yy_push_state phps-mode/ST_VAR_OFFSET)
@@ -1001,7 +1002,7 @@
 
((looking-at "[\"]")
 (phps-mode/BEGIN phps-mode/ST_IN_SCRIPTING)
-(message "Ended double-quote at %s" (match-beginning 0))
+;; (message "Ended double-quote at %s" (match-beginning 0))
 (phps-mode/RETURN_TOKEN "\"" (match-beginning 0) (match-end 0)))
 
((looking-at phps-mode/ANY_CHAR)
diff --git a/phps-test-lexer.el b/phps-test-lexer.el
index 3147afd..aabd220 100644
--- a/phps-test-lexer.el
+++ b/phps-test-lexer.el
@@ -217,19 +217,19 @@
(should (equal phps-mode/lexer-tokens
   '((T_OPEN_TAG 1 . 7) (T_VARIABLE 7 . 12) (T_OBJECT_OPERATOR 
12 . 14) (T_STRING 14 . 19) (";" 19 . 20) (";" 21 . 23) (T_CLOSE_TAG 21 . 
23)
 
-  ;; TODO Fix this, produces invalid tokens
   (phps-mode/with-test-buffer
"posts WHERE ID = 
'\".$id.\"'\"; ?>"
-   (message "Tokens 1: %s" phps-mode/lexer-tokens)
+   ;; (message "Tokens 1: %s" phps-mode/lexer-tokens)
(should (equal phps-mode/lexer-tokens
-  '((T_OPEN_TAG 1 . 7) (T_VARIABLE 7 . 11) ("=" 12 . 13) ("\"" 
14 . 15) (T_ENCAPSED_AND_WHITESPACE 15 . 39) (T_VARIABLE 39 . 47) (T_STRING 47 
. 51) (T_CONSTANT_ENCAPSED_STRING 51 . 64) ("\"" 64 . 65) ("." 65 . 66) 
(T_VARIABLE 66 . 69) ("." 69 . 70) (T_CONSTANT_ENCAPSED_STRING 70 . 73) (";" 73 
. 74) (";" 75 . 77) (T_CLOSE_TAG 75 . 77)
+  '((T_OPEN_TAG 1 . 7) (T_VARIABLE 7 . 11) ("=" 12 . 13) ("\"" 
14 . 15) (T_ENCAPSED_AND_WHITESPACE 15 . 39) (T_VARIABLE 39 . 44) 
(T_OBJECT_OPERATOR 44 . 46) (T_STRING 46 . 51) (T_CONSTANT_ENCAPSED_STRING 51 . 
64) ("\"" 64 . 65) ("." 65 . 66) (T_VARIABLE 66 . 69) ("." 69 . 70) 
(T_CONSTANT_ENCAPSED_STRING 70 . 73) (";" 73 . 74) (";" 75 . 77) (T_CLOSE_TAG 
75 . 77)
 
-  ;; TODO Fix this, produces invalid tokens
   (phps-mode/with-test-buffer
"get_var(\"SELECT post_parent FROM $wpdb->posts WHERE ID = 
'\".$id.\"'\"); ?>"
-   (message "Tokens 2: %s" phps-mode/lexer-tokens)
+   ;; (message "Tokens 2: %s" phps-mode/lexer-tokens)
(should (equal phps-mode/lexer-tokens
-  '((T_OPEN_TAG 1 . 7) (T_VARIABLE 7 . 12) (T_OBJECT_OPERATOR 
12 . 14) (T_STRING 14 . 21) ("(" 21 . 22) ("\"" 22 . 23) 
(T_ENCAPSED_AND_WHITESPACE 23 . 47) (T_VARIABLE 47 . 54) (T_OBJECT_OPERATOR 54 
. 56) (T_STRING 56 . 59) (T_CONSTANT_ENCAPSED_STRING 59 . 72) ("\"" 72 . 73) 
("." 73 . 74) (T_VARIABLE 74 . 77) ("." 77 . 78) (T_CONSTANT_ENCAPSED_STRING 78 
. 81) (")" 81 . 82) (";" 82 . 83) (";" 84 . 86) (T_CLOSE_TAG 84 . 86)
+  '((T_OPEN_TAG 1 . 7) (T_VARIABLE 7 . 12) (T_OBJECT_OPERATOR 
12 . 14) (T_STRING 14 . 21) ("(" 21 . 22) ("\"" 22 . 23) 
(T_ENCAPSED_AND_WHITESPACE 23 . 47) (T_VARIABLE 47 . 52) (T_OBJECT_OPERATOR 52 
. 54) (T_STRING 54 . 59) (T_CONSTANT_ENCAPSED_STRING 59 . 72) ("\"" 72 . 73) 
("." 73 . 74) (T_VARIABLE 74 . 77) ("." 77 . 78) (T_CONSTANT_ENCAPSED_STRING 78 
. 81) (")" 81 . 82) (";" 82 . 83) (";" 84 . 86) (T_CLOSE_TAG 84 . 86)
+
+  ;; TODO Test object properties inside heredoc, nowdocs strings
 
   )
 



[elpa] externals/phps-mode 31ca9d5 007/405: More cleaning up

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 31ca9d5506e2c5ee5705da54816d84e2311ca2b7
Author: Christian Johansson 
Commit: Christian Johansson 

More cleaning up
---
 README.md|  20 ++-
 phps-keywords.wy | 400 ---
 2 files changed, 18 insertions(+), 402 deletions(-)

diff --git a/README.md b/README.md
index d29d10b..6853e33 100644
--- a/README.md
+++ b/README.md
@@ -4,12 +4,28 @@ An Emacs major mode for PHP scripting language which aims at 
making a full seman
 
 ## Goals
 
-With current progress estimates
+With current progress estimates:
 
 * Flycheck support (100%)
 * Lexer based on official PHP re2c lexer (90%)
 * Syntax coloring based on lexer tokens (90%)
-* Wisent LALR parser based on official PHP yac parser automatically converter 
(60%)
+* Wisent LALR parser based on official PHP yacc parser automatically converted 
(60%)
 * Flymake support (0%)
 * Full integration with Emacs Semantic subsystem (0%)
 * PSR based indentation (0%)
+
+## Unit testing
+
+Not ready yet.
+
+### Lexer
+
+``` bash
+make test-lexer
+```
+
+### Parser
+
+``` bash
+make test-parser
+```
diff --git a/phps-keywords.wy b/phps-keywords.wy
deleted file mode 100644
index d39eecc..000
--- a/phps-keywords.wy
+++ /dev/null
@@ -1,400 +0,0 @@
-;;; KEYWORDS
-;; -
-;; Keyword terminals
-;; -
-
-;; Generate a keyword analyzer
-;; https://secure.php.net/manual/en/reserved.keywords.php
-;; https://secure.php.net/manual/en/language.constants.predefined.php
-
-%type   ;;syntax "\\(\\sw\\|\\s_\\)+" matchdatatype keyword
-
-%keyword __CLASS__ "__CLASS__"
-%put __CLASS__ summary
-"The class name. The class name includes the namespace it was declared in 
(e.g. Foo\\Bar)."
-
-%keyword __CONSTRUCT "__construct"
-%put __CONSTRUCT summary
-"Class constructor method"
-
-%keyword __DIR__ "__DIR__"
-%put __DIR__ summary
-"The directory of the file."
-
-%keyword __FILE__ "__FILE__"
-%put __FILE__ summary
-"The full path and filename of the file with symlinks resolved."
-
-%keyword __FUNCTION__ "__FUNCTION__"
-%put __FUNCTION__ summary
-"The current function name."
-
-%keyword __LINE__ "__LINE__"
-%put __LINE__ summary
-"The current line number of the file."
-
-%keyword __METHOD__ "__METHOD__"
-%put __METHOD__ summary
-"The current method name."
-
-%keyword __NAMESPACE__ "__NAMESPACE__"
-%put __NAMESPACE__ summary
-"The current namespace name."
-
-%keyword __TRAIT__ "__TRAIT__"
-%put __TRAIT__ summary
-"The trait name. The trait name includes the namespace it was declared in 
(e.g. Foo\\Bar)."
-
-%keyword HALT_COMPILER "__halt_compiler"
-%put HALT_COMPILER summary
-"Halts the execution of the compiler. This can be useful to embed data in PHP 
scripts, like the installation files."
-
-%keyword ABSTRACT "abstract"
-%put ABSTRACT summary
-"Class|Method declaration modifier: abstract {class |}  ..." 
;; TODO Methods too?
-
-%keyword AND2 "and"
-%put AND2 summary
-" and "
-
-%keyword ARRAY "array"
-%put ARRAY summary
-"array()"
-
-%keyword AS "as"
-%put AS summary
-"foreach( as  as "
-
-%keyword BREAK"break"
-%put BREAK summary
-"break[ ];"
-
-%keyword CALLABLE "callable"
-%put CALLABLE summary
-"callable $"
-
-%keyword CASE "case"
-%put CASE summary
-"switch() {case :  ... }"
-
-%keyword CATCH"catch"
-%put CATCH summary
-"try {} catch() {} ... "
-
-%keyword CLASS"class"
-%put CLASS summary
-"Class declaration: class  {  }"
-
-%keyword CLONE"clone"
-%put CLONE summary
-" = clone ;"
-
-%keyword CONST"const"
-%put CONST summary
-"const  = ;"
-
-%keyword CONTINUE "continue"
-%put CONTINUE summary
-"continue[ ];"
-
-%keyword DECLARE  "declare"
-%put DECLARE summary
-"declare () {  }"
-
-%keyword DEFAULT  "default"
-%put DEFAULT summary
-"switch() { case  { ... } default: {  } }"
-
-%keyword DIE   "die"
-%put DIE summary
-"die([]);"
-
-%keyword DO   "do"
-%put DO summary
-"do {  } while ();"
-
-%keyword ECHO   "echo"
-%put ECHO summary
-"echo ;"
-
-%keyword ELSE "else"
-%put ELSE summary
-"if () {  } else {  }"
-
-%keyword ELSEIF "elseif"
-%put ELSEIF summary
-"if () {  } elseif {  }"
-
-%keyword EMPTY "empty"
-%put EMPTY summary
-"empty(): bool"
-
-%keyword ENDDECLARE "enddeclare"
-%put ENDDECLARE summary
-"declare():  enddeclare;"
-
-%keyword ENDFOR "endfor"
-%put ENDFOR summary
-"for (; ; ): ; endfor;"
-
-%keyword ENDFOREACH "endforeach"
-%put ENDFOREACH summary
-"foreach ( as ): ; endforeach;"
-
-%keyword ENDIF "endif"
-%put ENDIF summary
-"if (): ; endif;"
-
-%keyword ENDSWITCH "endswitch"
-%put ENDSWITCH summary
-"switch (): ; endswitch;"
-
-%keyword ENDWHILE "endwhile"
-%put ENDWHILE summary
-"while (): ; endwhile;"
-
-%keyword EVAL "eval"
-%put EVAL summary
-"eval()"
-
-%keyword EXIT "exit"
-%put EXIT summary
-"exit[ ];"

[elpa] externals/phps-mode 79040dc 005/405: Some cleaning up

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 79040dcdb9427d618a215e0a1610647fc624183d
Author: Christian Johansson 
Commit: Christian Johansson 

Some cleaning up
---
 phps-semantic.el   | 481 +
 phps-tags.el   |  66 
 {tests/php => sample-php-files}/class.php  |   0
 {tests/php => sample-php-files}/functions.php  |   4 +
 {tests/php => sample-php-files}/interfaces.php |   0
 {tests/php => sample-php-files}/namespace.php  |   0
 sample-php-files/namespaces.php|  21 ++
 tests/php/namespaces.php   |  19 -
 8 files changed, 40 insertions(+), 551 deletions(-)

diff --git a/phps-semantic.el b/phps-semantic.el
index 0f6d4ac..0840283 100644
--- a/phps-semantic.el
+++ b/phps-semantic.el
@@ -1,488 +1,37 @@
 ;;; phps-mode/phps-semantic.el --- Semantic functions for PHP
 
-;;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
-
-;; Author: David Ponce 
+;; Copyright (C) 2017 Christian Johansson
 
 ;; This file is not part of GNU Emacs.
 
-;; GNU Emacs is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
+;; This program is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation; either version 2, or (at
+;; your option) any later version.
 
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
+;; This program is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs.  If not, see .
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Spathoftware Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
 
 ;;; Commentary:
 
-;; Make similar to 
/Users/christianjohansson/Documents/emacs/nextstep/Emacs.app/Contents/Resources/lisp/cedet/semantic/java.el.gz
-;;
-;; Common function for PHP parsers.
 
 ;;; Code:
+
+
 (require 'semantic)
 (require 'semantic/ctxt)
 (require 'semantic/doc)
 (require 'semantic/format)
 
-(eval-when-compile
-  (require 'semantic/find)
-  (require 'semantic/dep))
-
-;;; Lexical analysis
-;; TODO Verify this syntax
-(defconst semantic-php-number-regexp
-  (eval-when-compile
-(concat "\\("
-"\\<[0-9]+[.][0-9]+\\([eE][-+]?[0-9]+\\)?[fFdD]?\\>"
-"\\|"
-"\\<[0-9]+[.][eE][-+]?[0-9]+[fFdD]?\\>"
-"\\|"
-"\\<[0-9]+[.][fFdD]\\>"
-"\\|"
-"\\<[0-9]+[.]"
-"\\|"
-"[.][0-9]+\\([eE][-+]?[0-9]+\\)?[fFdD]?\\>"
-"\\|"
-"\\<[0-9]+[eE][-+]?[0-9]+[fFdD]?\\>"
-"\\|"
-"\\<0[xX][0-9a-fA-F]+[lL]?\\>"
-"\\|"
-"\\<[0-9]+[lLfFdD]?\\>"
-"\\)"
-))
-  "Lexer regexp to match PHP number terminals.
-Following is the specification of PHP number literals.
-
-DECIMAL_LITERAL:
-[1-9][0-9]*
-  ;
-HEX_LITERAL:
-0[xX][0-9a-fA-F]+
-  ;
-OCTAL_LITERAL:
-0[0-7]*
-  ;
-INTEGER_LITERAL:
-[lL]?
-  | [lL]?
-  | [lL]?
-  ;
-EXPONENT:
-[eE][+-]?[09]+
-  ;
-FLOATING_POINT_LITERAL:
-[0-9]+[.][0-9]*?[fFdD]?
-  | [.][0-9]+?[fFdD]?
-  | [0-9]+[fFdD]?
-  | [0-9]+?[fFdD]
-  ;")
-
-;;; Parsing
-
-;; TODO Verify this
-(defsubst semantic-php-dim (id)
-  "Split ID string into a pair (NAME . DIM).
-NAME is ID without trailing brackets: \"[]\".
-DIM is the dimension of NAME deduced from the number of trailing
-brackets, or 0 if there is no trailing brackets."
-  (let ((dim (string-match "\\(\\[]\\)+\\'" id)))
-(if dim
-(cons (substring id 0 dim)
-  (/ (length (match-string 0 id)) 2))
-  (cons id 0
-
-;; TODO Verify this
-(defsubst semantic-php-type (tag)
-  "Return the type of TAG, taking care of array notation."
-  (let ((type (semantic-tag-type tag))
-(dim  (semantic-tag-get-attribute tag :dereference)))
-(when dim
-  (while (> dim 0)
-(setq type (concat type "[]")
-  dim (1- dim
-type))
-
-;; TODO Verify this, how about ::?
-(defun semantic-php-expand-tag (tag)
-  "Expand compound declarations found in TAG into separate tags.
-TAG contains compound declarations when its class is `variable', and
-its name is a list of elements (NAME START . END), where NAME is a
-compound variable name, and START/END are the bou

[elpa] externals/phps-mode c6e5255 038/405: Merge branch 'master' of https://github.com/cjohansson/emacs-phps-mode

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit c6e52554c95ad38923f178a89225f0a21489fcbe
Merge: 6776468 47440dd
Author: Christian Johansson 
Commit: Christian Johansson 

Merge branch 'master' of https://github.com/cjohansson/emacs-phps-mode



[elpa] externals/phps-mode 7d0cd36 002/405: Updated goals

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 7d0cd36dbe9e5b837b79392a82501634ea66e70c
Author: Christian Johansson 
Commit: Christian Johansson 

Updated goals
---
 README.md | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/README.md b/README.md
index 04ba636..d29d10b 100644
--- a/README.md
+++ b/README.md
@@ -6,8 +6,10 @@ An Emacs major mode for PHP scripting language which aims at 
making a full seman
 
 With current progress estimates
 
+* Flycheck support (100%)
 * Lexer based on official PHP re2c lexer (90%)
 * Syntax coloring based on lexer tokens (90%)
 * Wisent LALR parser based on official PHP yac parser automatically converter 
(60%)
+* Flymake support (0%)
 * Full integration with Emacs Semantic subsystem (0%)
 * PSR based indentation (0%)



[elpa] externals/phps-mode 5c0568b 033/405: Added some basic unit tests for indentation

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 5c0568bac426fb2724a7741293f9040c1fdb431d
Author: Christian Johansson 
Commit: Christian Johansson 

Added some basic unit tests for indentation
---
 phps-test-functions.el | 14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/phps-test-functions.el b/phps-test-functions.el
index c25f820..891c541 100644
--- a/phps-test-functions.el
+++ b/phps-test-functions.el
@@ -42,6 +42,7 @@
 
 (defun phps-mode/test-indentation ()
   "Test for indentation."
+
   (phps-mode/with-test-buffer
"Bla bla"
(goto-char 69)
@@ -50,23 +51,28 @@
  (should (equal buffer-contents  "Bla bla"
 
   (phps-mode/with-test-buffer
-   "Bla bla"
-   (goto-char 80)
+   "Bla bla"
+   
+   (goto-char 75)
(phps-mode/indent-line)
(let ((buffer-contents (buffer-substring-no-properties (point-min) 
(point-max
- (should (equal buffer-contents  "Bla bla"
+ (should (equal buffer-contents  "Bla bla"
 
   (phps-mode/with-test-buffer
"Bla bla"
+
(goto-char 98)
(phps-mode/indent-line)
(let ((buffer-contents (buffer-substring-no-properties (point-min) 
(point-max
- (should (equal buffer-contents  "Bla bla"
+ (should (equal buffer-contents  "Bla bla"
 
   )
 
 (defun phps-mod/test-functions ()
   "Run test for functions."
+  (setq-default indent-tabs-mode nil)
+  (setq-default tab-width 4)
+  (setq-default c-basic-indent 4)
   (phps-mode/test-indentation))
 
 (phps-mod/test-functions)



[elpa] externals/phps-mode de771b5 019/405: Added more unit tests

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit de771b5dd89820d1b98eb90b3a687b19b468320b
Author: Christian Johansson 
Commit: Christian Johansson 

Added more unit tests
---
 phps-test-lexer.el | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/phps-test-lexer.el b/phps-test-lexer.el
index 781668b..b2744cc 100644
--- a/phps-test-lexer.el
+++ b/phps-test-lexer.el
@@ -115,6 +115,17 @@
   '((T_OPEN_TAG 1 . 7) (T_VARIABLE 7 . 11) ("=" 12 . 13) ("[" 
14 . 15) ("]" 15 . 16) (";" 16 . 17)
 
   (phps-mode/with-test-buffer
+   "

[elpa] externals/phps-mode c625217 042/405: Added flag for PSR-2 white-space settings

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit c625217d81227b31c09cf37fd34758f9c402163b
Author: Christian Johansson 
Commit: Christian Johansson 

Added flag for PSR-2 white-space settings
---
 phps-functions.el  | 18 ++
 phps-mode.el   |  3 +++
 phps-syntax-table.el   | 10 ++
 phps-test-functions.el |  3 ---
 4 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/phps-functions.el b/phps-functions.el
index cc2bc7a..9c67d3a 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -47,8 +47,8 @@
 
 ;; Are we in scripting?
 (if in-scripting
-(let* ((indent-start (* (+ (nth 1 start) (nth 2 start)) 4))
-   (indent-end (* (+ (nth 1 end) (nth 2 end)) 4))
+(let* ((indent-start (* (+ (nth 1 start) (nth 2 start)) tab-width))
+   (indent-end (* (+ (nth 1 end) (nth 2 end)) tab-width))
(indent-diff 0))
   (when (and (> indent-start indent-end)
  (looking-at-p "^[][ \t)(}{};]+\\($\\|?>\\)"))
@@ -57,7 +57,7 @@
   (message "inside scripting, start: %s, end: %s, indenting to 
column %s " start end indent-level)
   (indent-line-to indent-level))
   (progn
-(message "Outside scripting %s" start)
+;; (message "Outside scripting %s" start)
 ;; (indent-relative)
 ))
 
@@ -69,7 +69,17 @@
   "PHP specific init-cleanup routines."
 
   (set (make-local-variable 'indent-line-function) #'phps-mode/indent-line)
-  (set (make-local-variable 'tab-width) 8)
+
+  (when phps-mode/use-psr-2
+
+;; PSR-2 : Code MUST use an indent of 4 spaces
+(set (make-local-variable 'tab-width) 4)
+
+;; PSR-2 : MUST NOT use tabs for indenting
+(set (make-local-variable 'indent-tabs-mode) nil)
+
+)
+
   ;; (set (make-local-variable 'indent-line-function) 
#'phps-mode/indent-region)
   )
 
diff --git a/phps-mode.el b/phps-mode.el
index 65542f7..0d5c19d 100644
--- a/phps-mode.el
+++ b/phps-mode.el
@@ -57,6 +57,9 @@
 (autoload 'phps-mode/tags-init "phps-tags")
 (autoload 'phps-mode/semantic-init "phps-semantic")
 
+(defvar phps-mode/use-psr-2 t
+  "Whether to use PSR-2 guidelines for white-space or not.")
+
 (define-derived-mode phps-mode prog-mode "PHPs"
   "Major mode for PHP with Semantic integration."
 
diff --git a/phps-syntax-table.el b/phps-syntax-table.el
index 6cbdecd..b482143 100644
--- a/phps-syntax-table.el
+++ b/phps-syntax-table.el
@@ -43,12 +43,14 @@
   (let ((phps-mode/syntax-table (make-syntax-table)))
 
 ;; This is added so entity names with underscores can be more easily 
parsed as one word
-(modify-syntax-entry ?_ "w" phps-mode/syntax-table)
+
+;; Treat underscore as a punctuation
+(modify-syntax-entry ?_ "." phps-mode/syntax-table)
 
 ;; Improve parsing of  as words
-(modify-syntax-entry ?? "w" phps-mode/syntax-table)
-(modify-syntax-entry ?< "w" phps-mode/syntax-table)
-(modify-syntax-entry ?> "w" phps-mode/syntax-table)
+;;(modify-syntax-entry ?? "w" phps-mode/syntax-table)
+;;(modify-syntax-entry ?< "w" phps-mode/syntax-table)
+;;(modify-syntax-entry ?> "w" phps-mode/syntax-table)
 
 ;; (modify-syntax-entry ?_ "w" phps-mode/syntax-table)
 
diff --git a/phps-test-functions.el b/phps-test-functions.el
index 3f6543e..003ea4d 100644
--- a/phps-test-functions.el
+++ b/phps-test-functions.el
@@ -99,9 +99,6 @@
 
 (defun phps-mod/test-functions ()
   "Run test for functions."
-  (setq-default indent-tabs-mode nil)
-  (setq-default tab-width 4)
-  (setq-default c-basic-indent 4)
   (phps-mode/test-indentation))
 
 (phps-mod/test-functions)



[elpa] externals/phps-mode be078dc 020/405: Updated readme

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit be078dc411b8567573caf1a46700f3e5a5deeb70
Author: Christian Johansson 
Commit: Christian Johansson 

Updated readme
---
 README.md | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index 6853e33..090c8de 100644
--- a/README.md
+++ b/README.md
@@ -7,12 +7,12 @@ An Emacs major mode for PHP scripting language which aims at 
making a full seman
 With current progress estimates:
 
 * Flycheck support (100%)
-* Lexer based on official PHP re2c lexer (90%)
-* Syntax coloring based on lexer tokens (90%)
+* Lexer based on official PHP re2c lexer (100%)
+* Syntax coloring based on lexer tokens (100%)
+* PSR based indentation based on lexer tokens (0%)
 * Wisent LALR parser based on official PHP yacc parser automatically converted 
(60%)
 * Flymake support (0%)
 * Full integration with Emacs Semantic subsystem (0%)
-* PSR based indentation (0%)
 
 ## Unit testing
 



[elpa] externals/phps-mode 3ea8c64 003/405: Added license

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 3ea8c640f82388910d0318d3e8c7756e6f3a2c67
Author: Christian Johansson 
Commit: Christian Johansson 

Added license
---
 LICENSE | 674 
 1 file changed, 674 insertions(+)

diff --git a/LICENSE b/LICENSE
new file mode 100644
index 000..94a9ed0
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,674 @@
+GNU GENERAL PUBLIC LICENSE
+   Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. 
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+Preamble
+
+  The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.  We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors.  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+  To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights.  Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received.  You must make sure that they, too, receive
+or can get the source code.  And you must show them these terms so they
+know their rights.
+
+  Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+  For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software.  For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+  Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so.  This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software.  The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable.  Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products.  If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+  Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary.  To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+   TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to any copyrightable work licensed under this
+License.  Each licensee is addressed as "you".  "Licensees" and
+"recipients" may be individuals or organizations.
+
+  To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy.  The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+  A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+  To "propagate" a work means to do anything with it that, without
+permission, would make you dir

[elpa] externals/phps-mode c040358 046/405: Point lexer token information makes more sense

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit c040358b555a1e157b055da5c7a1b7e08d2718ae
Author: Christian Johansson 
Commit: Christian Johansson 

Point lexer token information makes more sense
---
 phps-lexer.el  | 28 
 phps-test-lexer.el | 18 ++
 2 files changed, 34 insertions(+), 12 deletions(-)

diff --git a/phps-lexer.el b/phps-lexer.el
index 39d745e..42ab914 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -1268,24 +1268,33 @@ ANY_CHAR'
   (start-brace-level 0)
   (start-parenthesis-level 0)
   (start-inline-function-level 0)
-  (start-token-number -1)
+  (start-token-number nil)
   (end-in-scripting nil)
   (end-brace-level 0)
   (end-parenthesis-level 0)
   (end-inline-function-level 0)
-  (end-token-number -1))
+  (end-token-number nil)
+  (found-line-tokens nil))
   (catch 'stop-iteration
 (dolist (item phps-mode/lexer-tokens)
   (let ((token (car item))
-(start (car (cdr item
+(start (car (cdr item)))
+(end (cdr (cdr item
 ;; (message "Token: %s Start: %s End: %s Item: %s" token start end 
item)
 
 (when (> start line-end)
   ;; (message "Stopping iteration at: %s %s" start position)
   (throw 'stop-iteration nil))
 
+(when (and (not found-line-tokens)
+   (>= start position)
+   (<= end line-end))
+  (setq found-line-tokens t))
+
 ;; When start of token is equal or less to current point
-(when (< start position)
+(when (<= end position)
+  (when (null start-token-number)
+(setq start-token-number -1))
   (setq start-token-number (+ start-token-number 1))
   (pcase token
 ('T_OPEN_TAG (setq start-in-scripting t))
@@ -1298,7 +1307,9 @@ ANY_CHAR'
 (_)))
 
 ;; When start of token is equal or less to end of curent line
-(when (< start line-end)
+(when (<= start line-end)
+  (when (null end-token-number)
+(setq end-token-number -1))
   (setq end-token-number (+ end-token-number 1))
   (pcase token
 ('T_OPEN_TAG (setq end-in-scripting t))
@@ -1311,10 +1322,11 @@ ANY_CHAR'
 (_)))
 
 )))
-  (let ((data (list (list start-in-scripting start-brace-level 
start-parenthesis-level start-inline-function-level start-token-number) (list 
end-in-scripting end-brace-level end-parenthesis-level 
end-inline-function-level end-token-number
+  (let ((data (list (list start-in-scripting start-brace-level 
start-parenthesis-level start-inline-function-level nil) (list end-in-scripting 
end-brace-level end-parenthesis-level end-inline-function-level nil
+(when found-line-tokens
+  (setq data (list (list start-in-scripting start-brace-level 
start-parenthesis-level start-inline-function-level start-token-number) (list 
end-in-scripting end-brace-level end-parenthesis-level 
end-inline-function-level end-token-number
 ;; (message "data: %s" data)
-data)
-  )))
+data
 
 (defun phps-mode/lex--SETUP (start end)
   "Just prepare other lexers for lexing region START to END."
diff --git a/phps-test-lexer.el b/phps-test-lexer.el
index 0897a08..8eb8ed3 100644
--- a/phps-test-lexer.el
+++ b/phps-test-lexer.el
@@ -279,17 +279,27 @@
   (phps-mode/with-test-buffer
"Bla 
bla"
(goto-char 15)
-   (should (equal (list (list nil 0 0 0 -1) (list nil 0 0 0 5)) 
(phps-mode/lexer-get-point-data
+   (should (equal (list (list nil 0 0 0 nil) (list nil 0 0 0 5)) 
(phps-mode/lexer-get-point-data
+
+  (phps-mode/with-test-buffer
+   "\nBla 
bla"
+   (goto-char 50)
+   (should (equal (list (list nil 0 0 0 nil) (list nil 0 0 0 nil)) 
(phps-mode/lexer-get-point-data
+
+  (phps-mode/with-test-buffer
+   "Bla bla"
+   (goto-char 15)
+   (should (equal (list (list nil 0 0 0 nil) (list nil 0 0 0 nil)) 
(phps-mode/lexer-get-point-data
 
   (phps-mode/with-test-buffer
"Bla 
bla"
(goto-char 30)
-   (should (equal (list (list nil 0 0 0 -1) (list nil 0 0 0 5)) 
(phps-mode/lexer-get-point-data
+   (should (equal (list (list nil 0 0 0 nil) (list nil 0 0 0 5)) 
(phps-mode/lexer-get-point-data
 
   (phps-mode/with-test-buffer
"Bla 
bla"
(goto-char 50)
-   (should (equal (list (list nil 0 0 0 -1) (list nil 0 0 0 5)) 
(phps-mode/lexer-get-point-data
+   (should (equal (list (list nil 0 0 0 nil) (list nil 0 0 0 5)) 
(phps-mode/lexer-get-point-data
 
   (phps-mode/with-test-buffer
"Bla bla"
@@ -311,7 +321,7 @@
"Bla bla"

(goto-char 100)
-   (should (equal (list (list nil 0 0 0 -1) (list nil 0 0 0 17)) 
(phps-mode/lexer-get-point-data
+   (should (eq

[elpa] externals/phps-mode 3202213 025/405: Added another unit test for lexer

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 32022133af3e8471e8cd384137ad5784b67488fe
Author: Christian Johansson 
Commit: Christian Johansson 

Added another unit test for lexer
---
 phps-test-lexer.el | 5 +
 1 file changed, 5 insertions(+)

diff --git a/phps-test-lexer.el b/phps-test-lexer.el
index 719988a..62bbe0d 100644
--- a/phps-test-lexer.el
+++ b/phps-test-lexer.el
@@ -129,6 +129,11 @@
   '((T_OPEN_TAG 1 . 7) (T_ECHO 7 . 11) (T_ISSET 12 . 17) ("(" 
17 . 18) (T_VARIABLE 18 . 28) ("[" 28 . 29) (T_LNUMBER 29 . 30) ("]" 30 . 31) 
("[" 31 . 32) (T_CONSTANT_ENCAPSED_STRING 32 . 38) ("]" 38 . 39) (")" 39 . 40) 
("?" 41 . 42) (T_CONSTANT_ENCAPSED_STRING 43 . 48) (":" 49 . 50) 
(T_CONSTANT_ENCAPSED_STRING 51 . 55) (";" 55 . 56)
 
   (phps-mode/with-test-buffer
+   ""
(should (equal phps-mode/lexer-tokens
   '((T_OPEN_TAG 1 . 7) (T_ECHO 7 . 11) (T_ISSET 12 . 17) ("(" 
17 . 18) (T_VARIABLE 18 . 28) ("[" 28 . 29) (T_LNUMBER 29 . 30) ("]" 30 . 31) 
("[" 31 . 32) (T_CONSTANT_ENCAPSED_STRING 32 . 38) ("]" 38 . 39) (")" 39 . 40) 
("?" 41 . 42) (T_CONSTANT_ENCAPSED_STRING 43 . 48) (":" 49 . 50) 
(T_CONSTANT_ENCAPSED_STRING 51 . 55) (";" 55 . 56) (T_COMMENT 57 . 75) 
(T_COMMENT 76 . 101) (T_DOC_COMMENT 102 . 134) (T_ECHO 135 . 139) (T_VARIABLE 
140 . 150) (";" 150 . 151) (";" 152 . 154)  [...]



[elpa] externals/phps-mode 94492c4 048/405: Added changes tracking to functions from lexer

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 94492c4780ec9df2b678569b2292bf4518e867f4
Author: Christian Johansson 
Commit: Christian Johansson 

Added changes tracking to functions from lexer
---
 phps-functions.el  | 16 
 phps-lexer.el  | 13 -
 phps-test-functions.el |  6 --
 3 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/phps-functions.el b/phps-functions.el
index 54e021c..bcd50ce 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -36,6 +36,9 @@
 ;;; Code:
 
 
+(defvar phps-mode/buffer-changes--start nil
+  "Start of buffer changes, nil if none.")
+
 (autoload 'phps-mode/lexer-get-point-data "phps-lexer")
 
 (defun phps-mode/indent-line ()
@@ -93,6 +96,15 @@
   "Indent region."
   )
 
+;; TODO This function should track between what min and max region a specific 
buffer has been modified and then re-run lexer for that region when editor is 
idle, maybe use (buffer-name))
+;; maybe use 'auto-save-hook for this
+(defun phps-mode/after-change-functions (start stop length)
+  "Track buffer change from START to STOP with length LENGTH."
+  (when (string= major-mode "phps-mode")
+(setq phps-mode/buffer-changes--start start)
+(message "phps-mode/after-change-functions %s %s %s" start stop length)
+  ))
+
 (defun phps-mode/functions-init ()
   "PHP specific init-cleanup routines."
 
@@ -109,6 +121,10 @@
 
 )
 
+  (set (make-local-variable 'phps-mode/buffer-changes--start) nil)
+
+  (add-hook 'after-change-functions #'phps-mode/after-change-functions)
+
   ;; (set (make-local-variable 'indent-line-function) 
#'phps-mode/indent-region)
   )
 
diff --git a/phps-lexer.el b/phps-lexer.el
index 42ab914..37e1c56 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -47,9 +47,6 @@
 (defvar phps-mode/lexer-tokens nil
   "Last lexer tokens.")
 
-(defvar phps-mode/buffer-changes--start nil
-  "Start of buffer changes, nil if none.")
-
 
 ;; SETTINGS
 
@@ -1335,15 +1332,6 @@ ANY_CHAR'
 (setq phps-mode/buffer-changes--start nil)
 (phps-mode/BEGIN phps-mode/ST_INITIAL)))
 
-;; TODO This function should track between what min and max region a specific 
buffer has been modified and then re-run lexer for that region when editor is 
idle, maybe use (buffer-name))
-;; maybe use 'auto-save-hook for this
-(defun phps-mode/after-change-functions (start stop length)
-  "Track buffer change from START to STOP with length LENGTH."
-  (when (string= major-mode "phps-mode")
-(setq phps-mode/buffer-changes--start start)
-(message "phps-mode/after-change-functions %s %s %s" start stop length)
-  ))
-
 (defun phps-mode/lex--RUN ()
   "Run lexer."
   (interactive)
@@ -1371,7 +1359,6 @@ ANY_CHAR'
 (setq semantic-lex-syntax-table phps-mode/syntax-table))
   (setq semantic-lex-analyzer #'phps-mode/tags-lexer)
   (add-hook 'semantic-lex-reset-functions #'phps-mode/lex--SETUP)
-  (add-hook 'after-change-functions #'phps-mode/after-change-functions)
   (phps-mode/lex--RUN))
 
 (provide 'phps-mode/lexer)
diff --git a/phps-test-functions.el b/phps-test-functions.el
index 644f916..9635bc0 100644
--- a/phps-test-functions.el
+++ b/phps-test-functions.el
@@ -40,7 +40,7 @@
 (autoload 'phps-mode/with-test-buffer "phps-test")
 (autoload 'should "ert")
 
-(defun phps-mode/test-indentation ()
+(defun phps-mode/test-indent-line ()
   "Test for indentation."
 
   (phps-mode/with-test-buffer
@@ -99,9 +99,11 @@
 
   )
 
+;; TODO Add tests for all examples here: https://www.php-fig.org/psr/psr-2/
+
 (defun phps-mod/test-functions ()
   "Run test for functions."
-  (phps-mode/test-indentation))
+  (phps-mode/test-indent-line))
 
 (phps-mod/test-functions)
 



[elpa] externals/phps-mode 184dfa5 034/405: Indentation outside PHP now does nothing

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 184dfa5494652263df2f2d244edebaf4eda26530
Author: Christian Johansson 
Commit: Christian Johansson 

Indentation outside PHP now does nothing
---
 phps-functions.el  | 3 ++-
 phps-test-functions.el | 8 
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/phps-functions.el b/phps-functions.el
index 57f59c6..677d19a 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -51,7 +51,8 @@
   (indent-line-to indent-level))
   (progn
 (message "Outside scripting %s" start)
-(indent-relative)))
+;; (indent-relative)
+))
 
 (defun phps-mode/indent-region ()
   "Indent region."
diff --git a/phps-test-functions.el b/phps-test-functions.el
index 891c541..350c0cd 100644
--- a/phps-test-functions.el
+++ b/phps-test-functions.el
@@ -66,6 +66,14 @@
(let ((buffer-contents (buffer-substring-no-properties (point-min) 
(point-max
  (should (equal buffer-contents  "Bla bla"
 
+  (phps-mode/with-test-buffer
+   "\nBla bla"
+
+   (goto-char 110)
+   (phps-mode/indent-line)
+   (let ((buffer-contents (buffer-substring-no-properties (point-min) 
(point-max
+ (should (equal buffer-contents  "\nBla bla"
+
   )
 
 (defun phps-mod/test-functions ()



[elpa] externals/phps-mode 795053b 013/405: Lexer unit tests using start and ends as well

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 795053b284c93cb2793f402dcbf224c46544db83
Author: Christian Johansson 
Commit: Christian Johansson 

Lexer unit tests using start and ends as well
---
 phps-lexer.el  |  10 +++-
 phps-test-lexer.el | 158 ++---
 2 files changed, 73 insertions(+), 95 deletions(-)

diff --git a/phps-lexer.el b/phps-lexer.el
index c5713b3..7907b06 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -835,7 +835,10 @@
   (progn
 ;; Handle the '' case
 (if (looking-at-p "'")
-(phps-mode/RETURN_TOKEN 'T_CONSTANT_ENCAPSED_STRING start (+ 
end 1))
+(progn
+  ;; (message "Empty single quoted string from %s to %s" end 
(+ end 1))
+  (phps-mode/RETURN_TOKEN 'T_CONSTANT_ENCAPSED_STRING end (+ 
end 1))
+  (forward-char))
   (progn
 ;; Unclosed single quotes
 ;; (message "Single quoted string never ends..")
@@ -874,7 +877,10 @@
   (progn
 ;; Handle the "" case
 (if (looking-at-p "\"")
-(phps-mode/RETURN_TOKEN 'T_CONSTANT_ENCAPSED_STRING start (+ 
end 1))
+(progn
+  ;; (message "Empty double quoted string from %s to %s" end 
(+ end 1))
+  (phps-mode/RETURN_TOKEN 'T_CONSTANT_ENCAPSED_STRING end (+ 
end 1))
+  (forward-char))
   (progn
 ;; (message "Found no ending quote, skipping to end")
 (phps-mode/RETURN_TOKEN 'T_ERROR start (point-max))
diff --git a/phps-test-lexer.el b/phps-test-lexer.el
index 0d329a0..e7d75fb 100644
--- a/phps-test-lexer.el
+++ b/phps-test-lexer.el
@@ -54,45 +54,35 @@
  (kill-buffer test-buffer)
  ))
 
-(defun phps-mode/token-stream-to-string (token-stream)
-  "Return a string from a TOKEN-STREAM."
-  (let ((return ""))
-(dolist (item token-stream)
-  (setq return (concat return (format " %s" (car item)
-return))
+(defun phps-mode/token-stream-to-string (IGNORE))
 
 (defun phps-mode/test-lexer--script-boundaries ()
   "Run test for lexer."
 
   (phps-mode/with-test-buffer
""
-   (let* ((tokens phps-mode/lexer-tokens)
-  (string-tokens (phps-mode/token-stream-to-string tokens)))
- (should (equal string-tokens " T_OPEN_TAG T_VARIABLE = T_LNUMBER ; T_EXIT 
T_VARIABLE ; ; T_CLOSE_TAG"
+   (should (equal phps-mode/lexer-tokens
+  '((T_OPEN_TAG 1 . 7) (T_VARIABLE 7 . 11) ("=" 11 . 12) 
(T_LNUMBER 12 . 13) (";" 13 . 14) (T_EXIT 15 . 19) (T_VARIABLE 20 . 24) (";" 24 
. 25) (";" 26 . 28) (T_CLOSE_TAG 26 . 28)
 
   (phps-mode/with-test-buffer
""
-   (let* ((tokens phps-mode/lexer-tokens)
-  (string-tokens (phps-mode/token-stream-to-string tokens)))
- (should (equal string-tokens " T_OPEN_TAG T_EXIT ; ; T_CLOSE_TAG"
+   (should (equal phps-mode/lexer-tokens
+  '((T_OPEN_TAG 1 . 7) (T_EXIT 7 . 11) (";" 11 . 12) (";" 13 . 
15) (T_CLOSE_TAG 13 . 15)
 
   (phps-mode/with-test-buffer
""
-   (let* ((tokens phps-mode/lexer-tokens)
-  (string-tokens (phps-mode/token-stream-to-string tokens)))
- (should (equal string-tokens " T_OPEN_TAG T_EXIT ; ; T_CLOSE_TAG"
+   (should (equal phps-mode/lexer-tokens
+  '((T_OPEN_TAG 1 . 7) (T_EXIT 7 . 11) (";" 11 . 12) (";" 13 . 
15) (T_CLOSE_TAG 13 . 15)
 
   (phps-mode/with-test-buffer
"blabla\n\n \t\n\n"
-   (let* ((tokens phps-mode/lexer-tokens)
-  (string-tokens (phps-mode/token-stream-to-string tokens)))
- (should (equal string-tokens " T_OPEN_TAG T_EXIT ; ; T_CLOSE_TAG"
+   (should (equal phps-mode/lexer-tokens
+  '((T_OPEN_TAG 35 . 41) (T_EXIT 41 . 45) (";" 45 . 46) (";" 
47 . 50) (T_CLOSE_TAG 47 . 50)
 
   (phps-mode/with-test-buffer
"\n\n \techo 
\"Blaha\";\n\n"
-   (let* ((tokens phps-mode/lexer-tokens)
-  (string-tokens (phps-mode/token-stream-to-string tokens)))
- (should (equal string-tokens " T_OPEN_TAG T_EXIT ; T_CLOSE_TAG T_OPEN_TAG 
T_EXIT ; T_CLOSE_TAG"
+   (should (equal phps-mode/lexer-tokens
+  '((T_OPEN_TAG 39 . 45) (T_EXIT 47 . 51) (";" 51 . 54) 
(T_CLOSE_TAG 51 . 54) (T_OPEN_TAG 78 . 84) (T_EXIT 84 . 88) (";" 89 . 91) 
(T_CLOSE_TAG 89 . 91)
 
   )
 
@@ -101,45 +91,38 @@
 
   (phps-mode/with-test-buffer
" '123');"
-   (let* ((tokens phps-mode/lexer-tokens)
-  (string-tokens (phps-mode/token-stream-to-string tokens)))
- (should (equal string-tokens " T_OPEN_TAG T_ECHO T_VARIABLE = T_ARRAY ( 
T_CONSTANT_ENCAPSED_STRING T_DOUBLE_ARROW T_CONSTANT_ENCAPSED_STRING ) ;"
+   (should (equal phps-mode/lexer-tokens
+  '((T_OPEN_TAG 1 . 7) (T_ECHO 7 . 11) (T_VARIABLE 12 . 16) 
("=" 17 . 18) (T_ARRAY 19 . 24) ("(" 24 . 25) (T_CONSTANT_ENCAPSED_STRING 25 . 
30) (T_DOUBLE_ARROW 31 . 33) (T_CONSTANT_ENCAPSED_STRING 34 . 39) (")" 39 . 40) 
(";" 40 

[elpa] externals/phps-mode e1b7160 053/405: (newline-and-indent) now working

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit e1b71600d5a1b1c488d2ec15fec0af9ecd6112c6
Author: Christian Johansson 
Commit: Christian Johansson 

(newline-and-indent) now working
---
 phps-functions.el | 97 +++
 1 file changed, 48 insertions(+), 49 deletions(-)

diff --git a/phps-functions.el b/phps-functions.el
index 0990be5..85efa86 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -41,58 +41,57 @@
 
 (autoload 'phps-mode/lexer-get-point-data "phps-lexer")
 
-;; TODO Should also format white-space inside the line, i.e. after function 
declarations
+;; TODO Should also format white-space inside the line, i.e. after function 
declarations?
+;; TODO Should indent doc blocks with 1 space
 (defun phps-mode/indent-line ()
   "Indent line."
   (let ((data (phps-mode/lexer-get-point-data)))
-(save-excursion
-  (beginning-of-line)
-  (let* ((start (nth 0 data))
- (end (nth 1 data))
- (in-scripting (nth 0 start)))
-
-;; Are we in scripting?
-(when in-scripting
-  (let ((start-bracket-level (nth 1 start))
-(start-parenthesis-level (nth 2 start))
-(start-token-number (nth 4 start))
-(end-bracket-level (nth 1 end))
-(end-parenthesis-level (nth 2 end))
-(end-token-number (nth 4 end)))
-(let* ((indent-start (+ start-bracket-level 
start-parenthesis-level))
-   (indent-end (+ end-bracket-level end-parenthesis-level))
-   (indent-level indent-start))
-  ;; (message "indent-start %s, indent-end %s" indent-start 
indent-end)
-  (when (and
- (boundp 'phps-mode/lexer-tokens)
- (> indent-start indent-end))
-(let ((token-number start-token-number)
-  (valid-tokens t))
-  ;; (message "token start %s, token end %s" 
start-token-number end-token-number)
-  (while (and valid-tokens
-  (<= token-number end-token-number))
-(let ((token (car (nth token-number 
phps-mode/lexer-tokens)))
-  (token-start (car (cdr (nth token-number 
phps-mode/lexer-tokens)
-  (when (and valid-tokens
- (>= token-start (point))
- (not (or
-   (string= token "{")
-   (string= token "}")
-   (string= token "(")
-   (string= token ")")
-   (string= token "[")
-   (string= token "]")
-   (string= token ";")
-   (eq token 'T_CLOSE_TAG
-;; (message "Token %s - %s in %s was invalid" token 
token-number phps-mode/lexer-tokens)
-(setq valid-tokens nil)))
-(setq token-number (+ token-number 1)))
-  (when valid-tokens
-;; (message "Tokens was valid, decreasing indent %s - %s" 
(line-beginning-position) (line-end-position))
-(setq indent-level (- indent-level (- indent-start 
indent-end))
-  ;; (message "inside scripting, start: %s, end: %s, indenting to 
column %s " start end indent-level)
-  (indent-line-to (* indent-level tab-width))
-  (phps-mode/run-incremental-lex
+(let* ((start (nth 0 data))
+   (end (nth 1 data))
+   (in-scripting (nth 0 start)))
+
+  ;; Are we in scripting?
+  (when in-scripting
+(let ((start-bracket-level (nth 1 start))
+  (start-parenthesis-level (nth 2 start))
+  (start-token-number (nth 4 start))
+  (end-bracket-level (nth 1 end))
+  (end-parenthesis-level (nth 2 end))
+  (end-token-number (nth 4 end)))
+  (let* ((indent-start (+ start-bracket-level start-parenthesis-level))
+ (indent-end (+ end-bracket-level end-parenthesis-level))
+ (indent-level indent-start))
+;; (message "indent-start %s, indent-end %s" indent-start 
indent-end)
+(when (and
+   (boundp 'phps-mode/lexer-tokens)
+   (> indent-start indent-end))
+  (let ((token-number start-token-number)
+(valid-tokens t))
+;; (message "token start %s, token end %s" start-token-number 
end-token-number)
+(while (and valid-tokens
+(<= token-number end-token-number))
+  (let ((token (car (nth token-number phps-mode/lexer-tokens)))
+(token-start (car (cdr (nth token-number 
phps-mode/lexer-tokens)

[elpa] branch externals/phps-mode created (now f5c2072)

2019-07-13 Thread Stefan Monnier
monnier pushed a change to branch externals/phps-mode.

at  f5c2072   Updated copyright for inclusion in ELPA

This branch includes the following new commits:

   new  3837d9c   My initial commit
   new  7d0cd36   Updated goals
   new  3ea8c64   Added license
   new  dd8d800   Using coloring overlay for comments as well
   new  79040dc   Some cleaning up
   new  ce656a5   More general cleaning up
   new  31ca9d5   More cleaning up
   new  c64b3b4   More work on lexer tests
   new  41c4fbb   Lexer unit tests now working
   new  a724438   Handled lexing with empty single and double quote string
   new  f3205d5   Fixed lexing of basic tokens
   new  5a6a96b   Added another test
   new  795053b   Lexer unit tests using start and ends as well
   new  64a3ca8   Modified start and end for single and double quoted 
strings
   new  b3a6308   Added hook for resetting lexer variables
   new  c4a8ca5   Free lexer tokens does not have properties anymore
   new  394f7ae   Fixed issue with empty strings before non-empty strings
   new  2475734   Improved logic for single quoted strings
   new  de771b5   Added more unit tests
   new  be078dc   Updated readme
   new  abcfd01   Started with function to gather current point data
   new  8ed0716   Started with unit tests for getting point lexer data
   new  bf59f0a   More unit tests for getting point lex information
   new  7fa9fdb   More unit tests for lexing comments and doc comments
   new  3202213   Added another unit test for lexer
   new  e3a060a   Handles script breaking single-line comments
   new  f6e3ce4   Added another test for comments
   new  95e749e   Started with indentation function
   new  d839f8a   More work on indentation support
   new  4fa9341   Started with unit tests for indentation
   new  1b891ea   More work on indentation and related tests
   new  9d3f644   Separated indentation tests for lexer tests
   new  5c0568b   Added some basic unit tests for indentation
   new  184dfa5   Indentation outside PHP now does nothing
   new  efcefde   Added support for closing parenthesis and braces
   new  47440dd   Added test for decreasing indentation with letters
   new  6776468   Started worked with adding references to tokens from 
point meta information
   new  c6e5255   Merge branch 'master' of 
https://github.com/cjohansson/emacs-phps-mode
   new  feb5724   Various debug work
   new  b437374   Fixed bug in parsing of object parameters inside double 
quoted string
   new  7161184   Handles stacked states better
   new  c625217   Added flag for PSR-2 white-space settings
   new  4b4a375   Using lexical bindings for all files
   new  be46d9c   Added lexer autoload to functions
   new  e36d477   token-number from point now is the same format as (nth)
   new  c040358   Point lexer token information makes more sense
   new  a259292   Changed indentation function to work solely on tokens
   new  94492c4   Added changes tracking to functions from lexer
   new  4098f46   Started with incremental lexer
   new  b629c4b   Updated comments and TODOs
   new  da1d1de   Temporary lexer after change until other work is ready
   new  09daec3   Foundation for incremental lexer and syntax colorer 
completed
   new  e1b7160   (newline-and-indent) now working
   new  990d3dd   Added test for indentation of multiple-line doc comment
   new  dd80d27   Started work on detecting doc comment blocks
   new  3f4c344   Fixed detection of doc comment blocks
   new  67f9a7a   Moved lexer-get-point-data to functions
   new  0ca9fe8   Detection of point inside doc comment block improved
   new  8aa1ab6   Another test for getting point data inside doc block
   new  3824abf   Resolved indent with trailing parenthesis
   new  bf633d2   Added test for indent of final line of doc comment block
   new  a61cb8b   Fixed issue with doc comment indentation
   new  ba8165a   Fixed bug with brace count not including braces inside 
double quoted strings
   new  90d059c   Fixed bug in incremental lexer logic
   new  6c597fb   Updated readme
   new  86ec35f   Incremental lexer working somewhat
   new  99dfc68   Incremental-lexer deletes affected overlays
   new  1be9270   Updated README
   new  27cd705   Updated readme
   new  58300fd   More updates of readme
   new  236f05e   Updated makefile to not use hard-coded path to emacs
   new  f4cd90e   Updated readme and makefile for running all tests
   new  c57fb5b   Improved indentation of trailing opening brace
   new  ec71e15   Fixed bug where token-numbers are not defined
   new  e57f1e1   Skipping indentation if it's already correct
   new  5e30a65   Added TODO items
   new  287d934   Updated comments are made un-tested function for moving 
to

[elpa] externals/phps-mode 6776468 037/405: Started worked with adding references to tokens from point meta information

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 6776468629623218fd69c4df6b285b6e6bf6ba2a
Author: Christian Johansson 
Commit: Christian Johansson 

Started worked with adding references to tokens from point meta information
---
 phps-functions.el  |  3 ++-
 phps-lexer.el  | 15 ---
 phps-test-functions.el |  9 -
 phps-test-lexer.el | 18 ++
 4 files changed, 32 insertions(+), 13 deletions(-)

diff --git a/phps-functions.el b/phps-functions.el
index 1d26588..cc2bc7a 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -50,7 +50,8 @@
 (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)
+  (when (and (> indent-start indent-end)
+ (looking-at-p "^[][ \t)(}{};]+\\($\\|?>\\)"))
 (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)
diff --git a/phps-lexer.el b/phps-lexer.el
index da663ec..8c545d4 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -47,6 +47,9 @@
 (defvar phps-mode/lexer-tokens nil
   "Last lexer tokens.")
 
+(defvar phps-mode/buffer-changes--start nil
+  "Start of buffer changes, nil if none.")
+
 
 ;; SETTINGS
 
@@ -1268,10 +1271,12 @@ ANY_CHAR'
   (start-brace-level 0)
   (start-parenthesis-level 0)
   (start-inline-function-level 0)
+  (start-token-number 0)
   (end-in-scripting nil)
   (end-brace-level 0)
   (end-parenthesis-level 0)
-  (end-inline-function-level 0))
+  (end-inline-function-level 0)
+  (end-token-number 0))
   (catch 'stop-iteration
 (dolist (item phps-mode/lexer-tokens)
   (let ((token (car item))
@@ -1285,6 +1290,7 @@ ANY_CHAR'
 
 ;; When start of token is equal or less to current point
 (when (< start position)
+  (setq start-token-number (+ start-token-number 1))
   (pcase token
 ('T_OPEN_TAG (setq start-in-scripting t))
 ('T_OPEN_TAG_WITH_ECHO (setq start-in-scripting t))
@@ -1297,6 +1303,7 @@ ANY_CHAR'
 
 ;; When start of token is equal or less to end of curent line
 (when (< start line-end)
+  (setq end-token-number (+ end-token-number 1))
   (pcase token
 ('T_OPEN_TAG (setq end-in-scripting t))
 ('T_OPEN_TAG_WITH_ECHO (setq end-in-scripting t))
@@ -1308,7 +1315,7 @@ ANY_CHAR'
 (_)))
 
 )))
-  (let ((data (list (list start-in-scripting start-brace-level 
start-parenthesis-level start-inline-function-level) (list end-in-scripting 
end-brace-level end-parenthesis-level end-inline-function-level
+  (let ((data (list (list start-in-scripting start-brace-level 
start-parenthesis-level start-inline-function-level start-token-number) (list 
end-in-scripting end-brace-level end-parenthesis-level 
end-inline-function-level end-token-number
 ;; (message "data: %s" data)
 data)
   )))
@@ -1317,6 +1324,7 @@ ANY_CHAR'
   "Just prepare other lexers for lexing region START to END."
   (when (eq start 1)
 ;; (message "SETUP %s %s" start end)
+(setq phps-mode/buffer-changes--start nil)
 (phps-mode/BEGIN phps-mode/ST_INITIAL)))
 
 ;; TODO This function should track between what min and max region a specific 
buffer has been modified and then re-run lexer for that region when editor is 
idle, maybe use (buffer-name))
@@ -1324,7 +1332,8 @@ ANY_CHAR'
 (defun phps-mode/after-change-functions (start stop length)
   "Track buffer change from START to STOP with length LENGTH."
   (when (string= major-mode "phps-mode")
-;; (message "phps-mode/after-change-functions %s %s %s" start stop length)
+(setq phps-mode/buffer-changes--start start)
+(message "phps-mode/after-change-functions %s %s %s" start stop length)
   ))
 
 (defun phps-mode/lex--RUN ()
diff --git a/phps-test-functions.el b/phps-test-functions.el
index f5f637f..3f6543e 100644
--- a/phps-test-functions.el
+++ b/phps-test-functions.el
@@ -81,13 +81,20 @@
(let ((buffer-contents (buffer-substring-no-properties (point-min) 
(point-max
  (should (equal buffer-contents  "Bla 
bla"
(goto-char 15)
-   (should (equal (list (list nil 0 0 0) (list nil 0 0 0)) 
(phps-mode/lexer-get-point-data
+   (should (equal (list (list nil 0 0 0 0) (list nil 0 0 0 6)) 
(phps-mode/lexer-get-point-data
 
   (phps-mode/with-test-buffer
"Bla 
bla"
(goto-char 30)
-   (should (equal (list (list nil 0 0 0) (list nil 0 0 0)) 
(phps-mode/lexer-get-point-data
+   (should (equal (list (list nil 0 0 0 0) (list nil 0 0 0 6)) 
(phps-mode/lexer-get-poin

[elpa] externals/phps-mode 41c4fbb 009/405: Lexer unit tests now working

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 41c4fbb46383378aa0e6a96ccbb9b9a9633c5da6
Author: Christian Johansson 
Commit: Christian Johansson 

Lexer unit tests now working
---
 phps-lexer.el| 104 ---
 phps-syntax-table.el |   7 +++-
 phps-test-lexer.el   |  54 +-
 3 files changed, 73 insertions(+), 92 deletions(-)

diff --git a/phps-lexer.el b/phps-lexer.el
index 18179d2..2f104fc 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -44,6 +44,10 @@
 ;; Make sure `semantic-lex-syntax-modifications' is correct since lexer is 
dependent on Emacs syntax-table
 
 
+(defvar phps-mode/lexer-tokens nil
+  "Last lexer tokens.")
+
+
 ;; SETTINGS
 
 
@@ -158,7 +162,7 @@
 (defun phps-mode/BEGIN (state)
   "Begin STATE."
   (setq phps-mode/STATE state)
-  (message "Begun state %s" state)
+  ;; (message "Begun state %s" state)
   )
 
 ;; _yy_push_state
@@ -170,7 +174,7 @@
 (if (not phps-mode/state_stack)
 (setq phps-mode/state_stack (list old-state))
   (push old-state phps-mode/state_stack))
-(message "Added state %s to stack" old-state)
+;; (message "Added state %s to stack" old-state)
 )
   (phps-mode/BEGIN state))
 
@@ -178,8 +182,8 @@
   "Pop current state from stack."
   (let* ((old-state (pop phps-mode/state_stack))
  (new-state (car phps-mode/state_stack)))
-(message "Going back to poppped state %s" old-state)
-(message "Ended state %s, going back to %s" old-state new-state)
+;; (message "Going back to poppped state %s" old-state)
+;; (message "Ended state %s, going back to %s" old-state new-state)
 (if old-state
 (phps-mode/BEGIN old-state)
   (display-warning "phps-mode" "PHPs Lexer Error - Going back to nil?"))
@@ -356,7 +360,7 @@
 (overlay-put (make-overlay start end) 'font-lock-face 
'font-lock-constant-face))
 
((string= token 'T_ERROR)
-(overlay-put (make-overlay start end)  'font-lock-face 
'font-lock-warning-face))
+(overlay-put (make-overlay start end) 'font-lock-face 
'font-lock-warning-face))
 
))
 
@@ -367,10 +371,12 @@
   (when (and
  phps-mode/prepend_trailing_brace
  (> end (- (point-max) 2)))
-(message "Adding trailing brace")
+;; (message "Adding trailing brace")
 (setq phps-mode/prepend_trailing_brace nil)
 (phps-mode/RETURN_TOKEN "}" (- end 1) end))
 
+  ;; (message "Added token %s %s %s" token start end)
+
   (semantic-lex-push-token
(semantic-lex-token token start end)))
 
@@ -392,7 +398,7 @@
 (let ((start (match-beginning 0))
   (end (match-end 0)))
   (phps-mode/BEGIN phps-mode/ST_IN_SCRIPTING)
-  (message "Starting scripting after  b" phps-mode-syntax-table)
-
-(setq semantic-lex-syntax-table phps-mode-syntax-table))
-
+  (when (boundp 'phps-mode/syntax-table)
+(setq semantic-lex-syntax-table phps-mode/syntax-table))
   (phps-mode/BEGIN phps-mode/ST_INITIAL)
-
-  (setq
-
-   ;; Syntax table modifications
-   ;; TODO Understand this
-   ;; semantic-lex-syntax-modifications
-   ;; '(
-   ;;   (?= ".")
-   ;;   (?& ".")
-   ;;   (?+ ".")
-   ;;   (?- ".")
-   ;;   (?| ".")
-   ;;   (?< ".")
-   ;;   (?> ".")
-   ;;   (?% ".")
-   ;;   (?' "\"")
-   ;;   (?\" "\"")
-   ;;   (?` "\"")
-   ;;   (?_ "w")
-   ;;   (?$ "_")
-   ;;   (?/ ". 124b")
-   ;;   (?* ". 23")
-   ;;   (?\n "> b")
-   ;;   (?# "< b"))
-
-   ;; Lexical analysis
-   semantic-lex-analyzer 'phps-mode/tags-lexer
-
-   )
-
-  (semantic-lex-buffer)
-
-  )
+  (setq semantic-lex-analyzer #'phps-mode/tags-lexer)
+  (setq phps-mode/lexer-tokens (semantic-lex-buffer)))
 
 (provide 'phps-mode/lexer)
 
diff --git a/phps-syntax-table.el b/phps-syntax-table.el
index cfe63ed..6cbdecd 100644
--- a/phps-syntax-table.el
+++ b/phps-syntax-table.el
@@ -43,7 +43,12 @@
   (let ((phps-mode/syntax-table (make-syntax-table)))
 
 ;; This is added so entity names with underscores can be more easily 
parsed as one word
-(modify-syntax-entry ?_ "_" phps-mode/syntax-table)
+(modify-syntax-entry ?_ "w" phps-mode/syntax-table)
+
+;; Improve parsing of  as words
+(modify-syntax-entry ?? "w" phps-mode/syntax-table)
+(modify-syntax-entry ?< "w" phps-mode/syntax-table)
+(modify-syntax-entry ?> "w" phps-mode/syntax-table)
 
 ;; (modify-syntax-entry ?_ "w" phps-mode/syntax-table)
 
diff --git a/phps-test-lexer.el b/phps-test-lexer.el
index 50dcd56..314d47f 100644
--- a/phps-test-lexer.el
+++ b/phps-test-lexer.el
@@ -66,31 +66,31 @@
 
   (phps-mode/with-test-buffer
""
-   (let* ((tokens (semantic-lex-buffer))
+   (let* ((tokens phps-mode/lexer-tokens)
   (string-tokens (phps-mode/token-stream-to-string tokens)))
  (should (equal string-tokens " T_OPEN_TAG T_VARIABLE = T_LNUMBER ; T_EXIT 
T_VARIABLE ; ; T_CLOSE_TAG"
 
   (phps-mode/with-test-buffer
""
-   (let* ((tokens (semantic-lex-buffer))
+   (let* ((tokens phps-mode/lexer-tokens)
   (string-tokens (phps-mode/token-stream-to-st

[elpa] externals/phps-mode 2475734 018/405: Improved logic for single quoted strings

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 247573451cb3e96b0f7e2cdc2b6248c55881def9
Author: Christian Johansson 
Commit: Christian Johansson 

Improved logic for single quoted strings
---
 phps-lexer.el  | 47 --
 sample-php-files/class.php |  1 +
 2 files changed, 30 insertions(+), 18 deletions(-)

diff --git a/phps-lexer.el b/phps-lexer.el
index 1e5ce6f..58c704b 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -431,6 +431,24 @@
 
))
 
+(defun phps-modex/lex--get-next-unescaped (character)
+  "Find where next un-escaped CHARACTER comes, if none is found return nil."
+  ;; (message "phps-modex/lex--get-next-unescaped(%s)" character)
+  (let ((escaped nil)
+(pos nil))
+(while (and (not pos)
+(< (point) (point-max)))
+  (progn
+;; (message "Setting forward one %s vs %s" (point) (point-max))
+(forward-char)
+(if (and (not escaped)
+ (looking-at-p character))
+(setq pos (+ (point) 1))
+  (if (looking-at-p "")
+  (setq escaped (not escaped))
+(setq escaped nil)
+pos))
+
 (define-lex-analyzer phps-mode/lex--ST_IN_SCRIPTING
   ""
   (= phps-mode/STATE phps-mode/ST_IN_SCRIPTING)
@@ -825,25 +843,18 @@
 (let* ((start (match-beginning 0))
(end (match-end 0))
(data (buffer-substring-no-properties start end))
-   (found nil))
-  (forward-char)
-  ;; Handle the '' case
-  (if (looking-at-p "'")
+   (found nil)
+   (un-escaped-end (phps-modex/lex--get-next-unescaped "'")))
+  (if un-escaped-end
   (progn
-;; (message "Empty single quoted string from %s to %s" start (+ 
start 2))
-(phps-mode/RETURN_TOKEN 'T_CONSTANT_ENCAPSED_STRING start (+ start 
2))
-(forward-char))
-(let ((string-start (search-forward-regexp "[^]'" nil t)))
-  (if string-start
-  (progn
-;; (message "Single quoted string %s" 
(buffer-substring-no-properties start string-start))
-(phps-mode/RETURN_TOKEN 'T_CONSTANT_ENCAPSED_STRING start 
string-start))
-(progn
-  ;; Unclosed single quotes
-  ;; (message "Single quoted string never ends..")
-  (phps-mode/RETURN_TOKEN 'T_ENCAPSED_AND_WHITESPACE start 
(point-max))
-  (phps-mode/MOVE_FORWARD (point-max))
-  ))
+;; (message "Single quoted string %s" 
(buffer-substring-no-properties start un-escaped-end))
+(phps-mode/RETURN_TOKEN 'T_CONSTANT_ENCAPSED_STRING start 
un-escaped-end))
+(progn
+  ;; Unclosed single quotes
+  ;; (message "Single quoted string never ends..")
+  (phps-mode/RETURN_TOKEN 'T_ENCAPSED_AND_WHITESPACE start (point-max))
+  (phps-mode/MOVE_FORWARD (point-max))
+  
 
;; Double quoted string
((looking-at "\"")
diff --git a/sample-php-files/class.php b/sample-php-files/class.php
index 7862e0b..3fa7bf4 100644
--- a/sample-php-files/class.php
+++ b/sample-php-files/class.php
@@ -25,6 +25,7 @@ class MyClass {
 $this->var = '';
 }
 $this->var = 'abc';
+$this->var = '\\';
 }
 
 }



[elpa] externals/phps-mode 3824abf 060/405: Resolved indent with trailing parenthesis

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 3824abf1a70e064e95b952a8412934af0840c3c6
Author: Christian Johansson 
Commit: Christian Johansson 

Resolved indent with trailing parenthesis
---
 phps-functions.el  | 9 +
 phps-test-functions.el | 4 
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/phps-functions.el b/phps-functions.el
index 497a0fd..8b20457 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -39,8 +39,7 @@
 (defvar phps-mode/buffer-changes--start nil
   "Start of buffer changes, nil if none.")
 
-;; TODO Should also format white-space inside the line, i.e. after function 
declarations?
-;; TODO Should indent doc blocks with 1 space
+;; TODO Also format white-space inside the line, i.e. after function 
declarations?
 (defun phps-mode/indent-line ()
   "Indent line."
   (let ((data (phps-mode/get-point-data)))
@@ -73,9 +72,11 @@
 (while (and valid-tokens
 (<= token-number end-token-number))
   (let ((token (car (nth token-number phps-mode/lexer-tokens)))
-(token-start (car (cdr (nth token-number 
phps-mode/lexer-tokens)
+(token-start (car (cdr (nth token-number 
phps-mode/lexer-tokens
+(token-end (cdr (cdr (nth token-number 
phps-mode/lexer-tokens)
 (when (and valid-tokens
-   (>= token-start (point))
+   (or (>= token-start (point))
+   (>= token-end (point)))
(not (or
  (string= token "{")
  (string= token "}")
diff --git a/phps-test-functions.el b/phps-test-functions.el
index 5b695cc..17cced3 100644
--- a/phps-test-functions.el
+++ b/phps-test-functions.el
@@ -186,6 +186,10 @@
(goto-char 50)
(should (equal (list (list t 0 0 0 nil nil) (list t 0 0 0 nil nil)) 
(phps-mode/get-point-data
 
+  (phps-mode/with-test-buffer
+   "https://www.php-fig.org/psr/psr-2/



[elpa] externals/phps-mode b629c4b 050/405: Updated comments and TODOs

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit b629c4b916653f490c383db9c13443ec38c45bf8
Author: Christian Johansson 
Commit: Christian Johansson 

Updated comments and TODOs
---
 phps-functions.el | 3 ++-
 phps-lexer.el | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/phps-functions.el b/phps-functions.el
index 8b1538d..2ca33aa 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -10,7 +10,7 @@
 
 ;; Package-Requires: ((emacs "24"))
 
-;; Copyright (C) 2017 Christian Johansson
+;; Copyright (C) 2018 Christian Johansson
 
 ;; This file is not part of GNU Emacs.
 
@@ -113,6 +113,7 @@
 (defun phps-mode/functions-init ()
   "PHP specific init-cleanup routines."
 
+  ;; indent-region will call this on each line of region
   (set (make-local-variable 'indent-line-function) #'phps-mode/indent-line)
 
   (when (and (boundp 'phps-mode/use-psr-2)
diff --git a/phps-lexer.el b/phps-lexer.el
index 04b0edd..78919e3 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -1325,6 +1325,7 @@ ANY_CHAR'
 ;; (message "data: %s" data)
 data
 
+;; TODO Need to store lexer state and stack at each changing point of buffer 
to be able to rewind lexer
 (defun phps-mode/lex--SETUP (start end)
   "Just prepare other lexers for lexing region START to END."
   (when (and (eq start 1)



[elpa] externals/phps-mode 58300fd 070/405: More updates of readme

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 58300fd90bb3e5b35400c015ed5372dd6e76a1d7
Author: Christian Johansson 
Commit: Christian Johansson 

More updates of readme
---
 README.md | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/README.md b/README.md
index 506b1d6..a15bc0e 100644
--- a/README.md
+++ b/README.md
@@ -20,21 +20,27 @@ With current progress estimates:
 
 ## Unit tests
 
-Not ready yet.
+Not fully ready yet.
 
 ### Lexer
 
+Emacs24+ path need to be updated in Makefile first.
+
 ``` bash
 make test-lexer
 ```
 
 ### Parser
 
+Not ready yet.
+
 ``` bash
 make test-parser
 ```
 
-### Indentation
+### Functions
+
+Emacs24+ path need to be updated in Makefile first.
 
 ``` bash
 make test-functions
@@ -45,9 +51,8 @@ make test-functions
 Download to `~/.emacs.d/phps-mode/` and then add this to your init file:
 
 ``` emacs-lisp
-(add-to-list 'load-path "~/.emacs.d/phps-mode/")
+(add-to-list 'load-path (expand-file-name "~/.emacs.d/phps-mode/"))
 (use-package phps-mode
-:mode ("\\.php\\'" "\\.phtml\\'")
-)
+:mode ("\\.php\\'" "\\.phtml\\'"))
 ```
 



[elpa] externals/phps-mode abcfd01 021/405: Started with function to gather current point data

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit abcfd01b57d7a05896ef699c78db4087c75eea03
Author: Christian Johansson 
Commit: Christian Johansson 

Started with function to gather current point data
---
 README.md  |  3 ++-
 phps-functions.el  | 11 ---
 phps-lexer.el  | 22 +-
 phps-test-lexer.el | 13 ++---
 sample-php-files/class.php |  5 +
 5 files changed, 42 insertions(+), 12 deletions(-)

diff --git a/README.md b/README.md
index 090c8de..51e9237 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,8 @@ With current progress estimates:
 * Flycheck support (100%)
 * Lexer based on official PHP re2c lexer (100%)
 * Syntax coloring based on lexer tokens (100%)
-* PSR based indentation based on lexer tokens (0%)
+* Incremental lexer and syntax coloring after changes (0%)
+* PSR based indentation based on lexer tokens (20%)
 * Wisent LALR parser based on official PHP yacc parser automatically converted 
(60%)
 * Flymake support (0%)
 * Full integration with Emacs Semantic subsystem (0%)
diff --git a/phps-functions.el b/phps-functions.el
index 2366c43..48aac15 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -38,20 +38,17 @@
 
 (defun phps-mode/indent-line ()
   "Indent line."
-  (save-excursion
-(move-beginning-of-line nil)
-)
   )
 
 (defun phps-mode/indent-region ()
-  "Indent region.")
+  "Indent region."
+  )
 
 (defun phps-mode/functions-init ()
   "PHP specific init-cleanup routines."
 
-  ;; (set (make-local-variable 'indent-line-function) 'phps-mode/indent-line)
-  ;; (set (make-local-variable 'indent-line-function) 'phps-mode/indent-region)
-
+  ;; (set (make-local-variable 'indent-line-function) #'phps-mode/indent-line)
+  ;; (set (make-local-variable 'indent-line-function) 
#'phps-mode/indent-region)
   )
 
 
diff --git a/phps-lexer.el b/phps-lexer.el
index 58c704b..d9b6493 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -1255,12 +1255,31 @@ ANY_CHAR'
 
))
 
+(defun phps-mode/lexer-get-point-data()
+  "Return information about point in tokens."
+  (message "Point: %s in %s" (point) phps-mode/lexer-tokens)
+  (dolist (item phps-mode/lexer-tokens)
+)
+  )
+
 (defun phps-mode/lex--SETUP (start end)
   "Just prepare other lexers for lexing region START to END."
   (when (eq start 1)
 ;; (message "SETUP %s %s" start end)
 (phps-mode/BEGIN phps-mode/ST_INITIAL)))
 
+;; TODO This function should track between what min and max region a specific 
buffer has been modified and then re-run lexer for that region when editor is 
idle, maybe use (buffer-name))
+;; maybe use 'auto-save-hook for this
+(defun phps-mode/after-change-functions (start stop length)
+  "Track buffer change from START to STOP with length LENGTH."
+  (when (string= major-mode "phps-mode")
+;; (message "phps-mode/after-change-functions %s %s %s" start stop length)
+  ))
+
+(defun phps-mode/lex--RUN ()
+  "Run lexer."
+  (interactive)
+  (setq phps-mode/lexer-tokens (semantic-lex-buffer)))
 
 (define-lex phps-mode/tags-lexer
   "Lexer that handles PHP buffers."
@@ -1284,7 +1303,8 @@ ANY_CHAR'
 (setq semantic-lex-syntax-table phps-mode/syntax-table))
   (setq semantic-lex-analyzer #'phps-mode/tags-lexer)
   (add-hook 'semantic-lex-reset-functions #'phps-mode/lex--SETUP)
-  (setq phps-mode/lexer-tokens (semantic-lex-buffer)))
+  (add-hook 'after-change-functions #'phps-mode/after-change-functions)
+  (phps-mode/lex--RUN))
 
 (provide 'phps-mode/lexer)
 
diff --git a/phps-test-lexer.el b/phps-test-lexer.el
index b2744cc..a45db16 100644
--- a/phps-test-lexer.el
+++ b/phps-test-lexer.el
@@ -54,8 +54,6 @@
  (kill-buffer test-buffer)
  ))
 
-(defun phps-mode/token-stream-to-string (IGNORE))
-
 (defun phps-mode/test-lexer--script-boundaries ()
   "Run test for lexer."
 
@@ -239,7 +237,15 @@
(should (equal phps-mode/lexer-tokens
   '((T_OPEN_TAG 1 . 7) (T_START_HEREDOC 7 . 16) (T_ERROR 16 . 
55)
 
-)
+  )
+
+(defun phps-mode/test-lexer-get-point-data ()
+  "Return information about point in tokens."
+  (phps-mode/with-test-buffer
+   "var = '\\';
 }
 
+public function heres_more_information() {
+$var = '23ac';
+$var2 = '123';
+}
+
 }



[elpa] externals/phps-mode b3a6308 015/405: Added hook for resetting lexer variables

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit b3a6308dc46105ee450866f97f2d16e25d5744c2
Author: Christian Johansson 
Commit: Christian Johansson 

Added hook for resetting lexer variables
---
 phps-lexer.el | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/phps-lexer.el b/phps-lexer.el
index 0e75bae..3fc860e 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -1246,6 +1246,12 @@ ANY_CHAR'
 
))
 
+(defun phps-mode/lex--SETUP (start end)
+  "Just prepare other lexers for lexing region START to END."
+  (when (eq start 1)
+;; (message "SETUP %s %s" start end)
+(phps-mode/BEGIN phps-mode/ST_INITIAL)))
+
 
 (define-lex phps-mode/tags-lexer
   "Lexer that handles PHP buffers."
@@ -1267,8 +1273,8 @@ ANY_CHAR'
   "Initialize lexer."
   (when (boundp 'phps-mode/syntax-table)
 (setq semantic-lex-syntax-table phps-mode/syntax-table))
-  (phps-mode/BEGIN phps-mode/ST_INITIAL)
   (setq semantic-lex-analyzer #'phps-mode/tags-lexer)
+  (add-hook 'semantic-lex-reset-functions #'phps-mode/lex--SETUP)
   (setq phps-mode/lexer-tokens (semantic-lex-buffer)))
 
 (provide 'phps-mode/lexer)



[elpa] externals/phps-mode e36d477 045/405: token-number from point now is the same format as (nth)

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit e36d477d299b177e45104d8a87266d28bd49dd6a
Author: Christian Johansson 
Commit: Christian Johansson 

token-number from point now is the same format as (nth)
---
 phps-lexer.el  |  7 +++
 phps-test-lexer.el | 16 
 2 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/phps-lexer.el b/phps-lexer.el
index c281b93..39d745e 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -1268,17 +1268,16 @@ ANY_CHAR'
   (start-brace-level 0)
   (start-parenthesis-level 0)
   (start-inline-function-level 0)
-  (start-token-number 0)
+  (start-token-number -1)
   (end-in-scripting nil)
   (end-brace-level 0)
   (end-parenthesis-level 0)
   (end-inline-function-level 0)
-  (end-token-number 0))
+  (end-token-number -1))
   (catch 'stop-iteration
 (dolist (item phps-mode/lexer-tokens)
   (let ((token (car item))
-(start (car (cdr item)))
-(end (cdr (cdr item
+(start (car (cdr item
 ;; (message "Token: %s Start: %s End: %s Item: %s" token start end 
item)
 
 (when (> start line-end)
diff --git a/phps-test-lexer.el b/phps-test-lexer.el
index db5fb53..0897a08 100644
--- a/phps-test-lexer.el
+++ b/phps-test-lexer.el
@@ -274,44 +274,44 @@
   (phps-mode/with-test-buffer
"Bla 
bla"
(goto-char 15)
-   (should (equal (list (list nil 0 0 0 0) (list nil 0 0 0 6)) 
(phps-mode/lexer-get-point-data
+   (should (equal (list (list nil 0 0 0 -1) (list nil 0 0 0 5)) 
(phps-mode/lexer-get-point-data
 
   (phps-mode/with-test-buffer
"Bla 
bla"
(goto-char 30)
-   (should (equal (list (list nil 0 0 0 0) (list nil 0 0 0 6)) 
(phps-mode/lexer-get-point-data
+   (should (equal (list (list nil 0 0 0 -1) (list nil 0 0 0 5)) 
(phps-mode/lexer-get-point-data
 
   (phps-mode/with-test-buffer
"Bla 
bla"
(goto-char 50)
-   (should (equal (list (list nil 0 0 0 0) (list nil 0 0 0 6)) 
(phps-mode/lexer-get-point-data
+   (should (equal (list (list nil 0 0 0 -1) (list nil 0 0 0 5)) 
(phps-mode/lexer-get-point-data
 
   (phps-mode/with-test-buffer
"Bla bla"
;; (message "Tokens: %s" phps-mode/lexer-tokens)
(goto-char 48)
-   (should (equal (list (list t 1 0 0 6) (list nil 0 0 0 18)) 
(phps-mode/lexer-get-point-data
+   (should (equal (list (list t 1 0 0 5) (list nil 0 0 0 17)) 
(phps-mode/lexer-get-point-data
 
   (phps-mode/with-test-buffer
"Bla bla"
(goto-char 72)
-   (should (equal (list (list t 2 0 0 11) (list t 2 0 0 14)) 
(phps-mode/lexer-get-point-data
+   (should (equal (list (list t 2 0 0 10) (list t 2 0 0 13)) 
(phps-mode/lexer-get-point-data
 
   (phps-mode/with-test-buffer
"Bla bla"
(goto-char 84)
-   (should (equal (list (list t 2 0 0 14) (list t 1 0 0 15)) 
(phps-mode/lexer-get-point-data
+   (should (equal (list (list t 2 0 0 13) (list t 1 0 0 14)) 
(phps-mode/lexer-get-point-data
 
   (phps-mode/with-test-buffer
"Bla bla"

(goto-char 100)
-   (should (equal (list (list nil 0 0 0 0) (list nil 0 0 0 18)) 
(phps-mode/lexer-get-point-data
+   (should (equal (list (list nil 0 0 0 -1) (list nil 0 0 0 17)) 
(phps-mode/lexer-get-point-data
 
   )
 



[elpa] externals/phps-mode 7161184 041/405: Handles stacked states better

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 7161184dfe6e001481649e7b689c50db113177dd
Author: Christian Johansson 
Commit: Christian Johansson 

Handles stacked states better
---
 phps-lexer.el | 16 +---
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/phps-lexer.el b/phps-lexer.el
index 8fb5694..2a2c9d1 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -169,17 +169,11 @@
   )
 
 ;; _yy_push_state
-(defun phps-mode/yy_push_state (state)
-  "Add STATE to stack and then begin state."
-  (let ((old-state (car phps-mode/state_stack)))
-(when (not old-state)
-  (setq old-state phps-mode/STATE))
-(if (not phps-mode/state_stack)
-(setq phps-mode/state_stack (list old-state))
-  (push old-state phps-mode/state_stack))
-;; (message "Added state %s to stack" old-state)
-)
-  (phps-mode/BEGIN state))
+(defun phps-mode/yy_push_state (new-state)
+  "Add NEW-STATE to stack and then begin state."
+  (push phps-mode/STATE phps-mode/state_stack)
+  ;; (message "Added state %s to stack" old-state)
+  (phps-mode/BEGIN new-state))
 
 (defun phps-mode/yy_pop_state ()
   "Pop current state from stack."



[elpa] externals/phps-mode f6e3ce4 027/405: Added another test for comments

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit f6e3ce4b8e09d7e199d79b82bd291681eb0ce36c
Author: Christian Johansson 
Commit: Christian Johansson 

Added another test for comments
---
 phps-test-lexer.el | 4 
 1 file changed, 4 insertions(+)

diff --git a/phps-test-lexer.el b/phps-test-lexer.el
index 95d592c..d78df2b 100644
--- a/phps-test-lexer.el
+++ b/phps-test-lexer.el
@@ -138,6 +138,10 @@
(should (equal phps-mode/lexer-tokens
   '((T_OPEN_TAG 1 . 7) (T_COMMENT 7 . 24) (";" 24 . 26) 
(T_CLOSE_TAG 24 . 26)
 
+  (phps-mode/with-test-buffer
+   ""
+   (should (equal phps-mode/lexer-tokens
+  '((T_OPEN_TAG 1 . 7) (T_COMMENT 7 . 32) (";" 32 . 34) 
(T_CLOSE_TAG 32 . 34))
 
 
   (phps-mode/with-test-buffer



[elpa] externals/phps-mode c4a8ca5 016/405: Free lexer tokens does not have properties anymore

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit c4a8ca59f82cc3005439c6dbf6259f2065b65354
Author: Christian Johansson 
Commit: Christian Johansson 

Free lexer tokens does not have properties anymore
---
 phps-lexer.el  | 60 +++---
 sample-php-files/class.php | 13 +-
 2 files changed, 42 insertions(+), 31 deletions(-)

diff --git a/phps-lexer.el b/phps-lexer.el
index 3fc860e..3e84f52 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -533,7 +533,7 @@
((looking-at (concat "<<<" phps-mode/TABS_AND_SPACES "\\(" phps-mode/LABEL 
"\\|'" phps-mode/LABEL "'\\|\"" phps-mode/LABEL "\"\\)" phps-mode/NEWLINE))
 (let* ((start (match-beginning 0))
(end (match-end 0))
-   (data (buffer-substring (match-beginning 1) (match-end 1)))
+   (data (buffer-substring-no-properties (match-beginning 1) 
(match-end 1)))
(heredoc_label))
 
   ;; Determine if it's HEREDOC or NOWDOC and extract label here
@@ -548,7 +548,7 @@
   (phps-mode/BEGIN phps-mode/ST_HEREDOC)))
 
   ;; Check for ending label on the next line
-  (when (string= (buffer-substring end (+ end (length heredoc_label))) 
heredoc_label)
+  (when (string= (buffer-substring-no-properties end (+ end (length 
heredoc_label))) heredoc_label)
 (phps-mode/BEGIN phps-mode/ST_END_HEREDOC))
 
   (push heredoc_label phps-mode/heredoc_label_stack)
@@ -706,7 +706,7 @@
((looking-at phps-mode/BNUM)
 (let* ((start (match-beginning 0))
(end (match-end 0))
-   (data (buffer-substring (+ start 2) end))
+   (data (buffer-substring-no-properties (+ start 2) end))
(long-number (string-to-number data 2)))
   ;; (message "Binary number %s from %s" long-number data)
   (if (> long-number phps-mode/long-limit)
@@ -716,7 +716,7 @@
((looking-at phps-mode/HNUM)
 (let* ((start (match-beginning 0))
(end (match-end 0))
-   (data (buffer-substring (+ start 2) end))
+   (data (buffer-substring-no-properties (+ start 2) end))
(long-number (string-to-number data 16)))
   ;; (message "Hexadecimal number %s from %s" long-number data)
   (if (> long-number phps-mode/long-limit)
@@ -727,14 +727,14 @@
 (looking-at phps-mode/DNUM))
 (let* ((start (match-beginning 0))
(end (match-end 0))
-   (data (buffer-substring start end)))
+   (data (buffer-substring-no-properties start end)))
   ;; (message "Exponent/double at: %s" data)
   (phps-mode/RETURN_TOKEN 'T_DNUMBER start end)))
 
((looking-at phps-mode/LNUM)
 (let* ((start (match-beginning 0))
(end (match-end 0))
-   (data (string-to-number (buffer-substring start end
+   (data (string-to-number (buffer-substring-no-properties start 
end
   ;; (message "Long number: %d" data)
   (if (> data phps-mode/long-limit)
   (phps-mode/RETURN_TOKEN 'T_DNUMBER start end)
@@ -760,8 +760,8 @@
((looking-at "\\(//\\|#\\)")
 (let* ((start (match-beginning 0))
(end (match-end 0))
-   (data (buffer-substring start end))
-   (line (buffer-substring (line-beginning-position) 
(line-end-position
+   (data (buffer-substring-no-properties start end))
+   (line (buffer-substring-no-properties (line-beginning-position) 
(line-end-position
   (if (string-match "\\?>" line)
   (progn
 (phps-mode/RETURN_TOKEN 'T_COMMENT start (match-end 0))
@@ -774,7 +774,7 @@
((looking-at (concat "/\\*\\*" phps-mode/WHITESPACE))
 (let* ((start (match-beginning 0))
(end (match-end 0))
-   (data (buffer-substring start end)))
+   (data (buffer-substring-no-properties start end)))
   (let ((string-start (search-forward "*/" nil t))
 position)
 (if string-start
@@ -788,7 +788,7 @@
((looking-at "/\\*")
 (let* ((start (match-beginning 0))
(end (match-end 0))
-   (data (buffer-substring start end)))
+   (data (buffer-substring-no-properties start end)))
   (let ((string-start (search-forward "*/" nil t))
 position)
 (if string-start
@@ -807,7 +807,7 @@
((looking-at phps-mode/TOKENS)
 (let* ((start (match-beginning 0))
(end (match-end 0))
-   (data (buffer-substring start end))
+   (data (buffer-substring-no-properties start end))
(use-brace nil))
   ;; (message "Found token '%s'" data)
   (when phps-mode/declaring_namespace
@@ -824,13 +824,13 @@
((looking-at "'")
 (let* ((start (match-beginning 0))
(end (match-end 0))
-   (data (buffer-substring start end))
+   (data (buffer-substring-no-properties start end))
(found nil))
   (forward-char)
   (let ((string-start (search-forward-regexp "[^]'" nil t)))
 (if string-start
 (progn
- 

[elpa] externals/phps-mode 6c597fb 065/405: Updated readme

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 6c597fb30d3d66af1b83f0da11754dec7263df48
Author: Christian Johansson 
Commit: Christian Johansson 

Updated readme
---
 README.md | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/README.md b/README.md
index 8f8fc3e..927b753 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
 # PHPs - Experiment with a Semantic Mode for Emacs
 
-An Emacs major mode for PHP scripting language which aims at making a full 
semantic integration. Currently at experimental stage.
+An Emacs major mode for PHP scripting language which aims at making a full 
semantic integration. Currently at *usable* stage.
 
 ## Goals
 
@@ -9,11 +9,11 @@ With current progress estimates:
 * Flycheck support (100%)
 * Lexer based on official PHP re2c lexer (100%)
 * Syntax coloring based on lexer tokens (100%)
-* Incremental lexer and syntax coloring after changes (0%)
-* PSR based indentation based on lexer tokens (50%)
+* PSR based indentation based on lexer tokens (90%)
 * Wisent LALR parser based on official PHP yacc parser automatically converted 
(60%)
+* Incremental lexer and syntax coloring after changes (50%)
+* Full integration with Emacs Semantic subsystem (30%)
 * Flymake support (0%)
-* Full integration with Emacs Semantic subsystem (0%)
 
 ## Unit tests
 
@@ -36,3 +36,6 @@ make test-parser
 ``` bash
 make test-functions
 ```
+
+## Installation
+



[elpa] externals/phps-mode efcefde 035/405: Added support for closing parenthesis and braces

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit efcefde38812c77f851c197254e1f83d97656f92
Author: Christian Johansson 
Commit: Christian Johansson 

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  "Bla bla"
+ (should (equal buffer-contents  "Bla bla"
 
   (phps-mode/with-test-buffer
"\nBla bla"
@@ -74,6 +74,20 @@
(let ((buffer-contents (buffer-substring-no-properties (point-min) 
(point-max
  (should (equal buffer-contents  "\nBla bla"
 
+  (phps-mode/with-test-buffer
+   "

[elpa] externals/phps-mode cd1fdee 106/405: *** empty log message ***

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit cd1fdeeb27604883a0699ee3996508adcdc8d755
Author: Christian Johansson 
Commit: Christian Johansson 

*** empty log message ***
---
 Makefile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index ef6b8fa..43a21c1 100644
--- a/Makefile
+++ b/Makefile
@@ -23,12 +23,12 @@ tests: clean test-functions test-lexer test-parser
 
 .PHONY: test-functions
 test-functions:
-   $(EMACS_CMD) -l phps-test-functions.el
+   $(EMACS_CMD) -l phps-mode-test-functions.el
 
 .PHONY: test-lexer
 test-lexer:
-   $(EMACS_CMD) -l phps-test-lexer.el
+   $(EMACS_CMD) -l phps-mode-test-lexer.el
 
 .PHONY: test-parser
 test-parser:
-   $(EMACS_CMD) -l phps-test-parser.el
+   $(EMACS_CMD) -l phps-mode-test-parser.el



[elpa] externals/phps-mode 86ec35f 066/405: Incremental lexer working somewhat

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 86ec35fb8b7b9e301e702d13c792ba6c4bed107d
Author: Christian Johansson 
Commit: Christian Johansson 

Incremental lexer working somewhat
---
 phps-functions.el | 14 ++
 phps-lexer.el | 39 +++
 2 files changed, 41 insertions(+), 12 deletions(-)

diff --git a/phps-functions.el b/phps-functions.el
index fe7ded9..6c4a67b 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -40,6 +40,7 @@
   "Start of buffer changes, nil if none.")
 
 ;; TODO Also format white-space inside the line, i.e. after function 
declarations?
+;; TODO Support inline function indentation
 (defun phps-mode/indent-line ()
   "Indent line."
   (let ((data (phps-mode/get-point-data)))
@@ -101,7 +102,12 @@
   ;; (message "Indenting to %s" indent-sum)
   ;; (message "inside scripting, start: %s, end: %s, indenting to 
column %s " start end indent-level)
   (indent-line-to indent-sum)
-  (phps-mode/run-incremental-lex
+  (let ((line-start (line-beginning-position)))
+(when (or (not phps-mode/buffer-changes--start)
+  (< line-start phps-mode/buffer-changes--start))
+  ;; (message "Setting changes start from %s to %s" 
phps-mode/buffer-changes--start start)
+  (setq phps-mode/buffer-changes--start line-start))
+(phps-mode/run-incremental-lex)
 
 ;; TODO Implement this?
 (defun phps-mode/indent-region ()
@@ -114,13 +120,13 @@
   (when (string= major-mode "phps-mode")
 (when (and (not phps-mode/buffer-changes--start)
(boundp 'phps-mode/idle-interval))
-  (run-with-idle-timer phps-mode/idle-interval nil #'phps-mode/lex--RUN)
+  ;; (run-with-idle-timer phps-mode/idle-interval nil #'phps-mode/lex--RUN)
   ;; TODO Maybe use incremental lexer once it's working
-  ;; (run-with-idle-timer phps-mode/idle-interval nil 
#'phps-mode/run-incremental-lex) 
+  (run-with-idle-timer phps-mode/idle-interval nil 
#'phps-mode/run-incremental-lex) 
   )
 (when (or (not phps-mode/buffer-changes--start)
   (< start phps-mode/buffer-changes--start))
-  ;; (message "Setting %s to %s" phps-mode/buffer-changes--start start)
+  ;; (message "Setting start of changes from %s to %s" 
phps-mode/buffer-changes--start start)
   (setq phps-mode/buffer-changes--start start))
 ;; (message "phps-mode/after-change-functions %s %s %s" start stop length)
 ))
diff --git a/phps-lexer.el b/phps-lexer.el
index dfca7c2..bd0a586 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -1262,9 +1262,9 @@ ANY_CHAR'
 ;; TODO Need to store lexer state and stack at each changing point of buffer 
to be able to rewind lexer
 (defun phps-mode/lex--SETUP (start end)
   "Just prepare other lexers for lexing region START to END."
+  (message "phps-mode/lex--SETUP %s %s" start end)
   (when (and (eq start 1)
  end)
-;; (message "SETUP %s %s" start end)
 (delete-all-overlays)
 (when (boundp 'phps-mode/buffer-changes--start)
   (setq phps-mode/buffer-changes--start nil))
@@ -1288,8 +1288,12 @@ ANY_CHAR'
   (new-states '())
   (states (nreverse phps-mode/lexer-states))
   (change-start phps-mode/buffer-changes--start)
-  (previous-token-start nil))
+  (previous-token-start nil)
+  (tokens phps-mode/lexer-tokens))
   ;; (message "Looking for state to rewind to for %s in stack %s" 
change-start states)
+
+  ;; Find state and state stack before point of change
+  ;; also determine were previous token to change starts
   (catch 'stop-iteration
 (dolist (state-object states)
   (let ((start (nth 0 state-object))
@@ -1301,14 +1305,33 @@ ANY_CHAR'
   (push state-object new-states))
 (when (> start change-start)
   (throw 'stop-iteration nil)
+
   (if (and state
state-stack)
-  (progn
-(setq phps-mode/STATE state)
-(setq phps-mode/state_stack state-stack)
-(setq phps-mode/lexer-states new-states)
-;; (message "Rewinding lex to state: %s and stack: %s and states: 
%s and start: %s" state state-stack new-states previous-token-start)
-(setq phps-mode/lexer-tokens (semantic-lex previous-token-start 
(point-max
+  (let ((old-tokens '()))
+
+;; Build new list of tokens before point of change
+(catch 'stop-iteration
+  (dolist (token tokens)
+(let ((start (car (cdr token
+  (if (< start previous-token-start)
+  (push token old-tokens)
+(throw 'stop-iteration nil)
+
+(setq old-tokens (nreverse old-tokens))
+
+(let* ((new-tokens (semantic-lex previous-token-start (point-max)))
+  

[elpa] externals/phps-mode c57fb5b 073/405: Improved indentation of trailing opening brace

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit c57fb5b22f8fdfb3efa2a11a97a59ad1e6ab7851
Author: Christian Johansson 
Commit: Christian Johansson 

Improved indentation of trailing opening brace
---
 phps-functions.el  | 19 ++-
 phps-lexer.el  |  2 +-
 phps-test-functions.el | 10 --
 phps-test-parser.el|  4 ++--
 4 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/phps-functions.el b/phps-functions.el
index 6c4a67b..c792c0a 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -69,13 +69,23 @@
(> indent-start indent-end))
   (let ((token-number start-token-number)
 (valid-tokens t)
+(last-token-is-open-brace nil)
 (tokens phps-mode/lexer-tokens))
 ;; (message "token start %s, token end %s" start-token-number 
end-token-number)
+
+;; Interate tokens in line and check if all are valid
 (while (and valid-tokens
 (<= token-number end-token-number))
   (let ((token (car (nth token-number tokens)))
 (token-start (car (cdr (nth token-number tokens
 (token-end (cdr (cdr (nth token-number tokens)
+
+;; Check if last token is open brace
+(when (and (= token-number end-token-number)
+   (string= token "{"))
+  (setq last-token-is-open-brace t))
+
+;; Check if current token is not one of the valid tokens
 (when (and valid-tokens
(or (>= token-start (point))
(>= token-end (point)))
@@ -90,9 +100,16 @@
  (eq token 'T_CLOSE_TAG
   ;; (message "Token %s - %s in %s was invalid" token 
token-number tokens)
   (setq valid-tokens nil)))
+
   (setq token-number (+ token-number 1)))
+
 (when valid-tokens
   ;; (message "Tokens was valid, decreasing indent %s - %s" 
(line-beginning-position) (line-end-position))
+
+  ;; If last token is a opening brace indent line one lesser 
column
+  (when last-token-is-open-brace
+(setq indent-end (- indent-end 1)))
+
   (setq indent-level (- indent-level (- indent-start 
indent-end))
 
 (when in-doc-comment
@@ -122,7 +139,7 @@
(boundp 'phps-mode/idle-interval))
   ;; (run-with-idle-timer phps-mode/idle-interval nil #'phps-mode/lex--RUN)
   ;; TODO Maybe use incremental lexer once it's working
-  (run-with-idle-timer phps-mode/idle-interval nil 
#'phps-mode/run-incremental-lex) 
+  (run-with-idle-timer phps-mode/idle-interval nil 
#'phps-mode/run-incremental-lex)
   )
 (when (or (not phps-mode/buffer-changes--start)
   (< start phps-mode/buffer-changes--start))
diff --git a/phps-lexer.el b/phps-lexer.el
index 2baabc1..70359c0 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -1337,7 +1337,7 @@ ANY_CHAR'
 
   ;; TODO Here clear all tokens after previous-token-start and add 
new tokens to stack
   ))
-(display-warning "phps-mode" (format "Found no state to rewind to for 
%s in stack %s" change-start states))
+;; (display-warning "phps-mode" (format "Found no state to rewind to 
for %s in stack %s, buffer point max: %s" change-start states (point-max)))
 (phps-mode/lex--RUN)))
 (setq phps-mode/buffer-changes--start nil)))
 
diff --git a/phps-test-functions.el b/phps-test-functions.el
index b4ef345..c24b35b 100644
--- a/phps-test-functions.el
+++ b/phps-test-functions.el
@@ -54,7 +54,6 @@
 
   (phps-mode/with-test-buffer
"Bla bla"
-   
(goto-char 75)
(phps-mode/indent-line)
(let ((buffer-contents (buffer-substring-no-properties (point-min) 
(point-max
@@ -62,7 +61,6 @@
 
   (phps-mode/with-test-buffer
"Bla bla"
-
(goto-char 98)
(phps-mode/indent-line)
(let ((buffer-contents (buffer-substring-no-properties (point-min) 
(point-max
@@ -131,6 +129,14 @@
(let ((buffer-contents (buffer-substring-no-properties (point-min) 
(point-max
  (should (equal buffer-contents "id}\",'__return_empty_array'\n);"
 
+  (phps-mode/with-test-buffer
+   "

[elpa] externals/phps-mode 89b12ab 084/405: Added autoloads and fixed bug with assigning variable

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 89b12abf79bbb31d78f404915af35b5746ea186c
Author: Christian Johansson 
Commit: Christian Johansson 

Added autoloads and fixed bug with assigning variable
---
 phps-functions.el | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/phps-functions.el b/phps-functions.el
index 3312a9b..84e3df9 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -35,6 +35,9 @@
 
 ;;; Code:
 
+(autoload 'phps-mode/run-incremental-lex "phps-lexer")
+(autoload 'phps-mode/move-lexer-tokens "phps-lexer")
+(autoload 'phps-mode/move-lexer-states "phps-lexer")
 
 (defvar phps-mode/buffer-changes--start nil
   "Start of buffer changes, nil if none.")
@@ -119,7 +122,7 @@
   (setq indent-adjust 1))
 
 (let ((indent-sum (+ (* indent-level tab-width) indent-adjust))
-  current-indentation (current-indentation))
+  (current-indentation (current-indentation)))
 
   (when (null current-indentation)
 (setq current-indentation 0))



[elpa] externals/phps-mode 7688cd7 111/405: Got incremental lexer working after renaming again

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 7688cd726aca4bcd6178a5c11932169305c54cc4
Author: Christian Johansson 
Commit: Christian Johansson 

Got incremental lexer working after renaming again
---
 phps-mode-functions.el | 20 
 phps-mode-lexer.el | 14 +++---
 2 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index cea1ff5..788781c 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -50,12 +50,12 @@
 (let ((start-curly-bracket-level (nth 1 start))
   (start-round-bracket-level (nth 2 start))
   (start-square-bracket-level (nth 3 start))
-  (start-inline-function-level (nth 4 start))
+  (_start-inline-function-level (nth 4 start))
   (start-token-number (nth 5 start))
   (end-curly-bracket-level (nth 1 end))
   (end-round-bracket-level (nth 2 end))
   (end-square-bracket-level (nth 3 end))
-  (end-inline-function-level (nth 4 end))
+  (_end-inline-function-level (nth 4 end))
   (end-token-number (nth 5 end))
   (in-doc-comment (nth 6 start)))
   (let* ((indent-start (+ start-curly-bracket-level 
start-round-bracket-level start-square-bracket-level))
@@ -174,19 +174,23 @@
   )
 
 ;; TODO Fix flycheck error here
-(defun phps-mode-functions-after-change (start stop length)
+(defun phps-mode-functions-after-change (start _stop _length)
   "Track buffer change from START to STOP with length LENGTH."
   (when (string= major-mode "phps-mode")
+
+;; If we haven't scheduled incremental lexer before - do it
 (when (and (not phps-mode-functions-buffer-changes-start)
-   (boundp 'phps-mode-idle-interval))
-  ;; (run-with-idle-timer phps-mode-idle-interval nil 
#'phps-mode-lexer-run)
-  ;; TODO Maybe use incremental lexer once it's working
-  (run-with-idle-timer phps-mode-idle-interval nil 
#'phps-mode-lexer-run-incremental)
-  )
+   (boundp 'phps-mode-idle-interval)
+   phps-mode-idle-interval)
+  ;; (message "Enqueued incremental lexer")
+  (run-with-idle-timer phps-mode-idle-interval nil 
#'phps-mode-lexer-run-incremental))
+
+;; When point of change is not set or when start of new changes precedes 
old change - update the point
 (when (or (not phps-mode-functions-buffer-changes-start)
   (< start phps-mode-functions-buffer-changes-start))
   ;; (message "Setting start of changes from %s to %s" 
phps-mode-functions-buffer-changes-start start)
   (setq phps-mode-functions-buffer-changes-start start))
+
 ;; (message "phps-mode-functions-after-change %s %s %s" start stop length)
 ))
 
diff --git a/phps-mode-lexer.el b/phps-mode-lexer.el
index 8b0079a..3fd2a42 100644
--- a/phps-mode-lexer.el
+++ b/phps-mode-lexer.el
@@ -380,7 +380,7 @@
(semantic-lex-token token start end)))
 
 ;; TODO Figure out what this does
-(defun phps-mode-lexer-SKIP_TOKEN (token start end)
+(defun phps-mode-lexer-SKIP_TOKEN (_token _start _end)
   "Skip TOKEN to list with START and END."
   )
 
@@ -793,7 +793,7 @@
((looking-at (concat "/\\*\\*" phps-mode-lexer-WHITESPACE))
 (let* ((start (match-beginning 0))
(end (match-end 0))
-   (data (buffer-substring-no-properties start end)))
+   (_data (buffer-substring-no-properties start end)))
   (let ((string-start (search-forward "*/" nil t))
 position)
 (if string-start
@@ -1326,14 +1326,14 @@ ANY_CHAR'
 
 (defun phps-mode-lexer-run-incremental ()
   "Run incremental lexer based on `phps-mode-lexer-buffer-changes--start'."
-  (when (and (boundp 'phps-mode-lexer-buffer-changes--start)
- phps-mode-lexer-buffer-changes--start
+  (when (and (boundp 'phps-mode-functions-buffer-changes-start)
+ phps-mode-functions-buffer-changes-start
  phps-mode-lexer-states)
 (let ((state nil)
   (state-stack nil)
   (new-states '())
   (states (nreverse phps-mode-lexer-states))
-  (change-start phps-mode-lexer-buffer-changes--start)
+  (change-start phps-mode-functions-buffer-changes-start)
   (previous-token-start nil)
   (tokens phps-mode-lexer-tokens))
   ;; (message "Looking for state to rewind to for %s in stack %s" 
change-start states)
@@ -1368,7 +1368,7 @@ ANY_CHAR'
 
 ;; Delete all overlays from point of change to end of buffer
 (dolist (overlay (overlays-in previous-token-start (point-max)))
-(delete-overlay overlay))
+  (delete-overlay overlay))
 
 (let* ((new-tokens (semantic-lex previous-token-start (point-max)))
(appended-tokens (append old-tokens new-tokens)))
@@ -1385,7 +1385,7 @@ ANY_CHAR'
   ))
 ;; (display-warning "phps-mode" (format "Found

[elpa] externals/phps-mode ec71e15 074/405: Fixed bug where token-numbers are not defined

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit ec71e150c7a973510febe2794c93ecf430561025
Author: Christian Johansson 
Commit: Christian Johansson 

Fixed bug where token-numbers are not defined
---
 phps-functions.el  |  4 +++-
 sample-php-files/class.php | 12 
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/phps-functions.el b/phps-functions.el
index c792c0a..4020428 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -66,7 +66,9 @@
 ;; When bracket count at start is larger than bracket count at end
 (when (and
(boundp 'phps-mode/lexer-tokens)
-   (> indent-start indent-end))
+   (> indent-start indent-end)
+   start-token-number
+   end-token-number)
   (let ((token-number start-token-number)
 (valid-tokens t)
 (last-token-is-open-brace nil)
diff --git a/sample-php-files/class.php b/sample-php-files/class.php
index 730480e..891b7e7 100644
--- a/sample-php-files/class.php
+++ b/sample-php-files/class.php
@@ -25,6 +25,18 @@ class MyClass
 if (!empty($this->var)) {
 $this->var = '';
 }
+if (empty(
+$this->var
+)) {
+$this->var = 'abc';
+}
+if (empty(
+$this->var
+) && !empty($this->var)
+) {
+$this->var = 'abc123';
+}
+
 $this->var = 'abc';
 $this->var = '\\';
 }



[elpa] externals/phps-mode 236f05e 071/405: Updated makefile to not use hard-coded path to emacs

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 236f05ea1fabff2f805f25f9dd7972c73a9852dd
Author: Christian Johansson 
Commit: Christian Johansson 

Updated makefile to not use hard-coded path to emacs
---
 Makefile  | 16 +++-
 README.md |  8 +++-
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/Makefile b/Makefile
index 64b18c6..89a64ee 100644
--- a/Makefile
+++ b/Makefile
@@ -1,29 +1,35 @@
-EMACS = "/Users/christianjohansson/Documents/emacs/src/emacs"
+EMACS = emacs
+ifdef emacs
+   EMACS = $(emacs)
+endif
 EMACS_CMD := $(EMACS) -Q -batch -L .
 
 EL  := phps-mode.el phps-wy.el
 ELC := $(EL:.el=.elc)
 
+.PHONY: clean
 clean:
rm -f $(ELC)
 
+.PHONE: compile
 compile:
$(ELC)
 
 %.elc: %.el
$(EMACS_CMD) -f batch-byte-compile $<
 
-test:
+.PHONY: tests
+tests:
clean test-functions test-lexer test-parser
 
+.PHONY: test-functions
 test-functions:
$(EMACS_CMD) -l phps-test-functions.el
 
+.PHONY: test-lexer
 test-lexer:
$(EMACS_CMD) -l phps-test-lexer.el
 
-
+.PHONY: test-parser
 test-parser:
$(EMACS_CMD) -l phps-test-parser.el
-
-.PHONY: clean compile test test-functions test-lexer test-parser
diff --git a/README.md b/README.md
index a15bc0e..2cfd7c6 100644
--- a/README.md
+++ b/README.md
@@ -20,11 +20,11 @@ With current progress estimates:
 
 ## Unit tests
 
-Not fully ready yet.
+If you have emacs at a customized location prefix the commands with your path, 
i.e.
 
-### Lexer
+`export emacs="~~/Documents/emacs/src/emacs" && make test-lexer`
 
-Emacs24+ path need to be updated in Makefile first.
+### Lexer
 
 ``` bash
 make test-lexer
@@ -40,8 +40,6 @@ make test-parser
 
 ### Functions
 
-Emacs24+ path need to be updated in Makefile first.
-
 ``` bash
 make test-functions
 ```



[elpa] externals/phps-mode 94d4814 078/405: Added test for moving lexer tokens

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 94d48149a0e9f32a459bae52b931fe75864594fe
Author: Christian Johansson 
Commit: Christian Johansson 

Added test for moving lexer tokens
---
 phps-lexer.el  |  6 +++---
 phps-test-lexer.el | 11 +++
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/phps-lexer.el b/phps-lexer.el
index 8e41347..3382a00 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -1293,10 +1293,10 @@ ANY_CHAR'
 (if (> token-start start)
 (let ((new-token-start (+ token-start diff))
   (new-token-end (+ token-end diff)))
-  (push `(,token-symbol ,new-token-start ,new-token-end) 
new-tokens)
-  (push token new-tokens))
+  (push `(,token-symbol ,new-token-start . ,new-token-end) 
new-tokens))
+  (push token new-tokens))
 
-  new-tokens)))
+new-tokens))
 
 (defun phps-mode/run-incremental-lex ()
   "Run incremental lexer based on `phps-mode/buffer-changes--start'."
diff --git a/phps-test-lexer.el b/phps-test-lexer.el
index d152f6c..9056461 100644
--- a/phps-test-lexer.el
+++ b/phps-test-lexer.el
@@ -40,6 +40,7 @@
 (autoload 'phps-mode/with-test-buffer "phps-test")
 (autoload 'phps-mode/lexer-init "phps-lexer")
 (autoload 'phps-mode/lexer-get-point-data "phps-lexer")
+(autoload 'phps-mode/move-lexer-tokens "phps-lexer")
 (autoload 'should "ert")
 
 (defun phps-mode/test-lexer--script-boundaries ()
@@ -268,6 +269,15 @@
 
   )
 
+(defun phps-mode/test-move-lexer-tokens ()
+  "Run test for move lexer tokens."
+
+  (should (equal
+   '((T_OPEN_TAG 1 . 7) (T_START_HEREDOC 7 . 16) (T_ERROR 21 . 60))
+   (phps-mode/move-lexer-tokens '((T_OPEN_TAG 1 . 7) (T_START_HEREDOC 
7 . 16) (T_ERROR 16 . 55)) 8 5)))
+
+  )
+
 (defun phps-mode/test-lexer ()
   "Run test for lexer."
   ;; (message "-- Running all tests for lexer... --\n")
@@ -277,6 +287,7 @@
   (phps-mode/test-lexer--complex-tokens)
   (phps-mode/test-lexer--namespaces)
   (phps-mode/test-lexer--errors)
+  (phps-mode/test-move-lexer-tokens)
   ;; (message "\n-- Ran all tests for lexer. --")
   )
 



[elpa] externals/phps-mode 6ac718c 104/405: Removed non-breaking space from syntax table

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 6ac718c6c9a7664c8cbf6b4d8b3ed4b5e3646ba8
Author: Christian Johansson 
Commit: Christian Johansson 

Removed non-breaking space from syntax table
---
 phps-syntax-table.el | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/phps-syntax-table.el b/phps-syntax-table.el
index e98ccb0..da065c0 100644
--- a/phps-syntax-table.el
+++ b/phps-syntax-table.el
@@ -46,11 +46,7 @@
 
 
 ;; WHITE-SPACE
-
-
-;; Treat non-breaking spaces as white-space
-(modify-syntax-entry ?\xa0 " " phps-mode/syntax-table)
-
+
 ;; Treat spaces as white-space
 (modify-syntax-entry ?\s  " " phps-mode/syntax-table)
 



[elpa] externals/phps-mode 8c919ac 087/405: Added failing indentation test

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 8c919ac9efc191ddf1b34a868c65eca158cc64ee
Author: Christian Johansson 
Commit: Christian Johansson 

Added failing indentation test
---
 README.md  | 11 ++-
 phps-test-functions.el |  8 
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index dcfe3b5..9ed7f01 100644
--- a/README.md
+++ b/README.md
@@ -10,13 +10,14 @@ With current progress estimates:
 * Lexer based on official PHP re2c lexer (100%)
 * Syntax coloring based on lexer tokens (100%)
 * PSR based indentation based on lexer tokens (90%)
+* Incremental lexer and syntax coloring after buffer changes (75%)
 * Wisent LALR parser based on official PHP yacc parser automatically converted 
(60%)
-* Incremental lexer and syntax coloring after buffer changes (50%)
 * Full integration with Emacs Semantic subsystem (30%)
 * Flymake support (0%)
 * PSR-2 auto-formatting tool based on lexer tokens (0%)
 * Add to MELPA (0%)
 * Add to ELPA (0%)
+* Travis support (0%)
 
 ## Unit tests
 
@@ -44,6 +45,14 @@ make test-parser
 make test-functions
 ```
 
+### Integration tests
+
+Not working yet
+
+``` bash
+make test-integration
+```
+
 ### All tests
 
 ``` bash
diff --git a/phps-test-functions.el b/phps-test-functions.el
index f348e4d..cd7711a 100644
--- a/phps-test-functions.el
+++ b/phps-test-functions.el
@@ -145,6 +145,14 @@
(let ((buffer-contents (buffer-substring-no-properties (point-min) 
(point-max
  (should (equal buffer-contents  "var\n) && 
!empty($this->var)\n) {\n$this->var = 'abc123';\n}\n"
 
+  (phps-mode/with-test-buffer
+   "var = 'abc123';\n} else 
{\n$this->var = 'def456';\n}\n"
+   (goto-char 68)
+   (phps-mode/indent-line)
+   ;; (message "Tokens %s point %s" phps-mode/lexer-tokens (point))
+   (let ((buffer-contents (buffer-substring-no-properties (point-min) 
(point-max
+ (should (equal buffer-contents "var = 'abc123';\n} else {\n$this->var = 'def456';\n}\n"
+
 
   )
 



[elpa] externals/phps-mode e340279 082/405: Added unit tests for moving lexer-state positions

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit e340279f93bf060ed76568e15d00bd306cf411c3
Author: Christian Johansson 
Commit: Christian Johansson 

Added unit tests for moving lexer-state positions
---
 phps-lexer.el  | 41 +++--
 phps-test-lexer.el | 53 +
 2 files changed, 80 insertions(+), 14 deletions(-)

diff --git a/phps-lexer.el b/phps-lexer.el
index 18ee244..0478323 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -1284,8 +1284,23 @@ ANY_CHAR'
 
 (defun phps-mode/get-moved-lexer-states (states start diff)
   "Return moved lexer STATES after (or equal to) START with modification DIFF."
-  ;; TODO Implement this
-  )
+  (let ((old-states states)
+(new-states '()))
+(when old-states
+
+  ;; Iterate through states add states before start start unchanged and 
the others modified with diff
+  (dolist (state-object (nreverse old-states))
+(let ((state-start (nth 0 state-object))
+  (state-end (nth 1 state-object))
+  (state-symbol (nth 2 state-object))
+  (state-stack (nth 3 state-object)))
+  (if (>= state-start start)
+(let ((new-state-start (+ state-start diff))
+  (new-state-end (+ state-end diff)))
+  (push (list new-state-start new-state-end state-symbol 
state-stack) new-states))
+(push state-object new-states)
+
+new-states))
 
 (defun phps-mode/lexer-move-lexer-tokens (start diff)
   "Update tokens with moved lexer tokens after or equal to START with 
modification DIFF."
@@ -1296,18 +1311,16 @@ ANY_CHAR'
   (let ((new-tokens '()))
 (when old-tokens
 
-  ;; Iterate over all tokens, add those that are to be left unchanged and
-  ;; add modified ones that are to be changed.
-  (catch 'stop-iteration
-(dolist (token (nreverse old-tokens))
-  (let ((token-symbol (car token))
-(token-start (car (cdr token)))
-(token-end (cdr (cdr token
-(if (>= token-start start)
-(let ((new-token-start (+ token-start diff))
-  (new-token-end (+ token-end diff)))
-  (push `(,token-symbol ,new-token-start . ,new-token-end) 
new-tokens))
-  (push token new-tokens))
+  ;; Iterate over all tokens, add those that are to be left unchanged and 
add modified ones that should be changed.
+  (dolist (token (nreverse old-tokens))
+(let ((token-symbol (car token))
+  (token-start (car (cdr token)))
+  (token-end (cdr (cdr token
+  (if (>= token-start start)
+  (let ((new-token-start (+ token-start diff))
+(new-token-end (+ token-end diff)))
+(push `(,token-symbol ,new-token-start . ,new-token-end) 
new-tokens))
+(push token new-tokens)
 
 new-tokens))
 
diff --git a/phps-test-lexer.el b/phps-test-lexer.el
index e2401d5..629b17d 100644
--- a/phps-test-lexer.el
+++ b/phps-test-lexer.el
@@ -294,6 +294,58 @@
 
   )
 
+(defun phps-mode/test-get-moved-lexer-states ()
+  "Run test for get moved lexer states."
+
+  (should (equal
+   '((68 76 1 '(1))
+ (10 67 1 '(1))
+ (1 7 1 '(1)))
+   
+   (phps-mode/get-moved-lexer-states
+'((66 74 1 '(1))
+  (8 65 1 '(1))
+  (1 7 1 '(1)))
+7
+2)))
+
+  (should (equal
+   '((67 75 1 '(1))
+ (9 66 1 '(1))
+ (2 8 1 '(1)))
+   
+   (phps-mode/get-moved-lexer-states
+'((66 74 1 '(1))
+  (8 65 1 '(1))
+  (1 7 1 '(1)))
+0
+1)))
+
+  (should (equal
+   '((66 74 1 '(1))
+ (8 65 1 '(1))
+ (1 7 1 '(1)))
+   
+   (phps-mode/get-moved-lexer-states
+'((66 74 1 '(1))
+  (8 65 1 '(1))
+  (1 7 1 '(1)))
+100
+1)))
+
+  (should (equal
+   '((64 72 1 '(1))
+ (6 63 1 '(1))
+ (1 7 1 '(1)))
+   
+   (phps-mode/get-moved-lexer-states
+'((66 74 1 '(1))
+  (8 65 1 '(1))
+  (3 9 1 '(1)))
+3
+-2)))
+  )
+
 (defun phps-mode/test-lexer ()
   "Run test for lexer."
   ;; (message "-- Running all tests for lexer... --\n")
@@ -304,6 +356,7 @@
   (phps-mode/test-lexer--namespaces)
   (phps-mode/test-lexer--errors)
   (phps-mode/test-get-moved-lexer-tokens)
+  (phps-mode/test-get-moved-lexer-states)
   ;; (message "\n-- Ran all tests for lexer. --")
   )
 



[elpa] externals/phps-mode 67f9a7a 057/405: Moved lexer-get-point-data to functions

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 67f9a7a235eb1f78a75e18b378ce9a08fb87178d
Author: Christian Johansson 
Commit: Christian Johansson 

Moved lexer-get-point-data to functions
---
 phps-functions.el  | 81 --
 phps-lexer.el  | 76 --
 phps-test-functions.el | 68 ++
 phps-test-lexer.el | 67 -
 4 files changed, 146 insertions(+), 146 deletions(-)

diff --git a/phps-functions.el b/phps-functions.el
index 85efa86..03b1119 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -39,13 +39,11 @@
 (defvar phps-mode/buffer-changes--start nil
   "Start of buffer changes, nil if none.")
 
-(autoload 'phps-mode/lexer-get-point-data "phps-lexer")
-
 ;; TODO Should also format white-space inside the line, i.e. after function 
declarations?
 ;; TODO Should indent doc blocks with 1 space
 (defun phps-mode/indent-line ()
   "Indent line."
-  (let ((data (phps-mode/lexer-get-point-data)))
+  (let ((data (phps-mode/get-point-data)))
 (let* ((start (nth 0 data))
(end (nth 1 data))
(in-scripting (nth 0 start)))
@@ -113,6 +111,83 @@
 ;; (message "phps-mode/after-change-functions %s %s %s" start stop length)
 ))
 
+(defun phps-mode/get-point-data ()
+  "Return information about point in tokens."
+  ;; (message "Point: %s in %s" (point) phps-mode/lexer-tokens)
+  (when (boundp 'phps-mode/lexer-tokens)
+(save-excursion
+  (beginning-of-line)
+  (let ((position (point))
+(line-end (line-end-position))
+(start-in-scripting nil)
+(start-brace-level 0)
+(start-parenthesis-level 0)
+(start-inline-function-level 0)
+(start-token-number nil)
+(end-in-scripting nil)
+(end-brace-level 0)
+(end-parenthesis-level 0)
+(end-inline-function-level 0)
+(end-token-number nil)
+(line-in-doc-comment nil)
+(found-line-tokens nil))
+(catch 'stop-iteration
+  (dolist (item phps-mode/lexer-tokens)
+(let ((token (car item))
+  (token-start (car (cdr item)))
+  (token-end (cdr (cdr item
+  ;; (message "Token: %s Start: %s End: %s Item: %s" token start 
end item)
+
+  (when (> token-start line-end)
+;; (message "Stopping iteration at: %s %s" start position)
+(throw 'stop-iteration nil))
+
+  (when (and (not found-line-tokens)
+ (>= token-start position)
+ (<= token-end line-end))
+(setq found-line-tokens t))
+
+  ;; When end of token is equal or less to current point
+  (when (<= token-end position)
+(when (null start-token-number)
+  (setq start-token-number -1))
+(setq start-token-number (+ start-token-number 1))
+(pcase token
+  ('T_OPEN_TAG (setq start-in-scripting t))
+  ('T_OPEN_TAG_WITH_ECHO (setq start-in-scripting t))
+  ('T_CLOSE_TAG (setq start-in-scripting nil))
+  ('T_DOC_COMMENT (setq line-in-doc-comment nil))
+  ("}" (setq start-brace-level (- start-brace-level 1)))
+  ("{" (setq start-brace-level (+ start-brace-level 1)))
+  ("(" (setq start-parenthesis-level (+ 
start-parenthesis-level 1)))
+  (")" (setq start-parenthesis-level (- 
start-parenthesis-level 1)))
+  (_)))
+
+  ;; When start of token is equal or less to end of curent line
+  (when (<= token-start line-end)
+(when (null end-token-number)
+  (setq end-token-number -1))
+(setq end-token-number (+ end-token-number 1))
+(setq line-in-doc-comment nil)
+(pcase token
+  ('T_OPEN_TAG (setq end-in-scripting t))
+  ('T_OPEN_TAG_WITH_ECHO (setq end-in-scripting t))
+  ('T_CLOSE_TAG (setq end-in-scripting nil))
+  ('T_DOC_COMMENT (setq line-in-doc-comment t))
+  ("}" (setq end-brace-level (- end-brace-level 1)))
+  ("{" (setq end-brace-level (+ end-brace-level 1)))
+  ("(" (setq end-parenthesis-level (+ end-parenthesis-level 
1)))
+  (")" (setq end-parenthesis-level (- end-parenthesis-level 
1)))
+  (_)))
+  
+  )))
+(when (not found-line-tokens)
+  (setq start-token-number nil)
+  (setq end-token-number nil))
+(let ((data (list (list start-in-scripting start-brace-level 
start-parenthesis-level start-inline-function-level start-token-number 
line-in-doc-comment) (list end-in-scripti

[elpa] externals/phps-mode 69ced0d 090/405: Added another unit test for failed indentation

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 69ced0da4969bb69bc5c0aebfb9f830a91cc5e37
Author: Christian Johansson 
Commit: Christian Johansson 

Added another unit test for failed indentation
---
 phps-test-functions.el | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/phps-test-functions.el b/phps-test-functions.el
index ec7e899..f9974a6 100644
--- a/phps-test-functions.el
+++ b/phps-test-functions.el
@@ -162,6 +162,13 @@
  (should (equal buffer-contents "var = 'abc123';\n} else if (mySeconCondition()) {\n$this->var = 
'def456';\n}\n"
 
   (phps-mode/with-test-buffer
+   " 'abc',\n),\n
$var2\n);\n"
+   (goto-char 50)
+   (phps-mode/indent-line)
+   (let ((buffer-contents (buffer-substring-no-properties (point-min) 
(point-max
+ (should (equal buffer-contents " 'abc',\n),\n$var2\n);\n"
+
+  (phps-mode/with-test-buffer
"getHead()\n->getTail();\n"
(goto-char 35)
(phps-mode/indent-line)



[elpa] externals/phps-mode e30ac0c 083/405: Started implementation of moving lexer and state position when

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit e30ac0ca253b6d96970eb44fe0d4571f8414c1d0
Author: Christian Johansson 
Commit: Christian Johansson 

Started implementation of moving lexer and state position when
indenting to save time
---
 phps-functions.el | 27 +--
 phps-lexer.el |  2 +-
 2 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/phps-functions.el b/phps-functions.el
index 9e5c2d5..3312a9b 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -40,7 +40,7 @@
   "Start of buffer changes, nil if none.")
 
 ;; TODO Also format white-space inside the line, i.e. after function 
declarations?
-;; TODO Support inline function indentation
+;; TODO Support inline function indentations
 (defun phps-mode/indent-line ()
   "Indent line."
   (let ((data (phps-mode/get-point-data)))
@@ -121,9 +121,12 @@
 (let ((indent-sum (+ (* indent-level tab-width) indent-adjust))
   current-indentation (current-indentation))
 
+  (when (null current-indentation)
+(setq current-indentation 0))
+
   ;; Only continue if current indentation is wrong
   (when (not (equal indent-sum current-indentation))
-(let ((indent-diff (- current-indentation indent-sum)))
+(let ((indent-diff (- indent-sum current-indentation)))
   ;; (message "Indenting to %s current column %s" indent-sum 
(current-indentation))
   ;; (message "inside scripting, start: %s, end: %s, indenting 
to column %s " start end indent-level)
 
@@ -131,16 +134,20 @@
 
   ;; TODO When indent is changed the trailing tokens just need 
to adjust their token positions, this will improve speed of indent-region a lot
   ;; TODO Lexer states need to be moved as well
-
   (let ((line-start (line-beginning-position)))
-
-;; Set point of change if it's not set or if it's larger 
than current point
-(when (or (not phps-mode/buffer-changes--start)
-  (< line-start phps-mode/buffer-changes--start))
-  ;; (message "Setting changes start from %s to %s" 
phps-mode/buffer-changes--start start)
-  (setq phps-mode/buffer-changes--start line-start))
+(phps-mode/move-lexer-tokens line-start indent-diff)
+(phps-mode/move-lexer-states line-start indent-diff)
+(message "Moving tokens and states %s, %s to %s" 
indent-diff current-indentation indent-sum)
 
-(phps-mode/run-incremental-lex)))
+;; ;; Set point of change if it's not set or if it's 
larger than current point
+;; (when (or (not phps-mode/buffer-changes--start)
+;;   (< line-start 
phps-mode/buffer-changes--start))
+;;   ;; (message "Setting changes start from %s to %s" 
phps-mode/buffer-changes--start start)
+;;   (setq phps-mode/buffer-changes--start line-start))
+
+;; (phps-mode/run-incremental-lex)
+
+))
 
 ;; TODO Implement this?
 (defun phps-mode/indent-region ()
diff --git a/phps-lexer.el b/phps-lexer.el
index 0478323..33bb126 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -1302,7 +1302,7 @@ ANY_CHAR'
 
 new-states))
 
-(defun phps-mode/lexer-move-lexer-tokens (start diff)
+(defun phps-mode/move-lexer-tokens (start diff)
   "Update tokens with moved lexer tokens after or equal to START with 
modification DIFF."
   (setq phps-mode/lexer-tokens (phps-mode/get-moved-lexer-tokens 
phps-mode/lexer-tokens start diff)))
 



[elpa] externals/phps-mode a10cc79 085/405: Debugging a indentation case

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit a10cc79d825a81991da4eaa24ce5294ee237b85f
Author: Christian Johansson 
Commit: Christian Johansson 

Debugging a indentation case
---
 phps-functions.el  | 23 +++
 phps-test-functions.el | 14 --
 2 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/phps-functions.el b/phps-functions.el
index 84e3df9..543996c 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -46,7 +46,8 @@
 ;; TODO Support inline function indentations
 (defun phps-mode/indent-line ()
   "Indent line."
-  (let ((data (phps-mode/get-point-data)))
+  (let ((data (phps-mode/get-point-data))
+(line-start (line-beginning-position)))
 (let* ((start (nth 0 data))
(end (nth 1 data))
(in-scripting (nth 0 start)))
@@ -64,12 +65,12 @@
  (indent-end (+ end-bracket-level end-parenthesis-level))
  (indent-level indent-start)
  (indent-adjust 0))
-;; (message "indent-start %s, indent-end %s" indent-start 
indent-end)
+(message "indent-start %s, indent-end %s" indent-start indent-end)
 
 ;; When bracket count at start is larger than bracket count at end
 (when (and
(boundp 'phps-mode/lexer-tokens)
-   (> indent-start indent-end)
+   (not (equal indent-start indent-end))
start-token-number
end-token-number)
   (let ((token-number start-token-number)
@@ -92,8 +93,8 @@
 
 ;; Check if current token is not one of the valid tokens
 (when (and valid-tokens
-   (or (>= token-start (point))
-   (>= token-end (point)))
+   (or (>= token-start line-start)
+   (>= token-end line-start))
(not (or
  (string= token "{")
  (string= token "}")
@@ -103,13 +104,13 @@
  (string= token "]")
  (string= token ";")
  (eq token 'T_CLOSE_TAG
-  ;; (message "Token %s - %s in %s was invalid" token 
token-number tokens)
+  (message "Token %s - %s in %s was invalid, line start 
%s" token token-number tokens line-start)
   (setq valid-tokens nil)))
 
   (setq token-number (+ token-number 1)))
 
 (when valid-tokens
-  ;; (message "Tokens was valid, decreasing indent %s - %s" 
(line-beginning-position) (line-end-position))
+  (message "Tokens was valid, decreasing indent %s - %s" 
(line-beginning-position) (line-end-position))
 
   ;; If last token is a opening brace indent line one lesser 
column
   (when last-token-is-open-brace
@@ -135,12 +136,10 @@
 
   (indent-line-to indent-sum)
 
-  ;; TODO When indent is changed the trailing tokens just need 
to adjust their token positions, this will improve speed of indent-region a lot
-  ;; TODO Lexer states need to be moved as well
-  (let ((line-start (line-beginning-position)))
+;; When indent is changed the trailing tokens and states 
just need to adjust their positions, this will improve speed of indent-region a 
lot
 (phps-mode/move-lexer-tokens line-start indent-diff)
 (phps-mode/move-lexer-states line-start indent-diff)
-(message "Moving tokens and states %s, %s to %s" 
indent-diff current-indentation indent-sum)
+;; (message "Moving tokens and states %s, %s to %s" 
indent-diff current-indentation indent-sum)
 
 ;; ;; Set point of change if it's not set or if it's 
larger than current point
 ;; (when (or (not phps-mode/buffer-changes--start)
@@ -150,7 +149,7 @@
 
 ;; (phps-mode/run-incremental-lex)
 
-))
+)
 
 ;; TODO Implement this?
 (defun phps-mode/indent-region ()
diff --git a/phps-test-functions.el b/phps-test-functions.el
index ff3f82d..468bee7 100644
--- a/phps-test-functions.el
+++ b/phps-test-functions.el
@@ -137,13 +137,15 @@
(let ((buffer-contents (buffer-substring-no-properties (point-min) 
(point-max
  (should (equal buffer-contents "var\n) && !empty($this->var)\n) {\n$this->var = 
'abc123';\n}\n"
+   (goto-char 54)
+   (phps-mode/indent-line)
+   ;; (message "Tokens %s point %s" phps-mode/lexer-tokens (point))
+   (let ((buffer-contents (buffer-substring-no-properties (point-min) 
(point-max
+ (should (equal buffer-contents  "var\n) && 
!empty($

[elpa] externals/phps-mode 3272991 110/405: Merge branch 'master' of https://github.com/cjohansson/emacs-phps-mode

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 3272991591639a0313552c477e50785791bf57c1
Merge: 529042e 6ac718c
Author: Christian Johansson 
Commit: Christian Johansson 

Merge branch 'master' of https://github.com/cjohansson/emacs-phps-mode



[elpa] externals/phps-mode f79cf4f 081/405: Started on function for moving lexer states

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit f79cf4f5f6fab10f56a291c896f6df3f1a335fda
Author: Christian Johansson 
Commit: Christian Johansson 

Started on function for moving lexer states
---
 phps-lexer.el  | 17 +++--
 phps-test-lexer.el | 16 
 2 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/phps-lexer.el b/phps-lexer.el
index d96bf2b..18ee244 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -1278,8 +1278,21 @@ ANY_CHAR'
   (interactive)
   (setq phps-mode/lexer-tokens (semantic-lex-buffer)))
 
-(defun phps-mode/move-lexer-tokens (old-tokens start diff)
-  "Move lexer OLD-TOKENS positions after (or equal to) START with DIFF points."
+(defun phps-mode/move-lexer-states (start diff)
+  "Move lexer states after (or equal to) START with modification DIFF."
+  (setq phps-mode/lexer-states (phps-mode/get-moved-lexer-states 
phps-mode/lexer-states start diff)))
+
+(defun phps-mode/get-moved-lexer-states (states start diff)
+  "Return moved lexer STATES after (or equal to) START with modification DIFF."
+  ;; TODO Implement this
+  )
+
+(defun phps-mode/lexer-move-lexer-tokens (start diff)
+  "Update tokens with moved lexer tokens after or equal to START with 
modification DIFF."
+  (setq phps-mode/lexer-tokens (phps-mode/get-moved-lexer-tokens 
phps-mode/lexer-tokens start diff)))
+
+(defun phps-mode/get-moved-lexer-tokens (old-tokens start diff)
+  "Return moved lexer OLD-TOKENS positions after (or equal to) START with DIFF 
points."
   (let ((new-tokens '()))
 (when old-tokens
 
diff --git a/phps-test-lexer.el b/phps-test-lexer.el
index 8ef15d5..e2401d5 100644
--- a/phps-test-lexer.el
+++ b/phps-test-lexer.el
@@ -269,28 +269,28 @@
 
   )
 
-(defun phps-mode/test-move-lexer-tokens ()
-  "Run test for move lexer tokens."
+(defun phps-mode/test-get-moved-lexer-tokens ()
+  "Run test for get moved lexer tokens."
 
   (should (equal
'((T_OPEN_TAG 1 . 7) (T_START_HEREDOC 7 . 16) (T_ERROR 21 . 60))
-   (phps-mode/move-lexer-tokens '((T_OPEN_TAG 1 . 7) (T_START_HEREDOC 
7 . 16) (T_ERROR 16 . 55)) 8 5)))
+   (phps-mode/get-moved-lexer-tokens '((T_OPEN_TAG 1 . 7) 
(T_START_HEREDOC 7 . 16) (T_ERROR 16 . 55)) 8 5)))
 
   (should (equal
'((T_OPEN_TAG 1 . 7) (T_START_HEREDOC 7 . 16) (T_ERROR 11 . 50))
-   (phps-mode/move-lexer-tokens '((T_OPEN_TAG 1 . 7) (T_START_HEREDOC 
7 . 16) (T_ERROR 16 . 55)) 8 -5)))
+   (phps-mode/get-moved-lexer-tokens '((T_OPEN_TAG 1 . 7) 
(T_START_HEREDOC 7 . 16) (T_ERROR 16 . 55)) 8 -5)))
 
   (should (equal
'((T_OPEN_TAG 1 . 7) (T_START_HEREDOC 8 . 17) (T_ERROR 17 . 56))
-   (phps-mode/move-lexer-tokens '((T_OPEN_TAG 1 . 7) (T_START_HEREDOC 
7 . 16) (T_ERROR 16 . 55)) 7 1)))
+   (phps-mode/get-moved-lexer-tokens '((T_OPEN_TAG 1 . 7) 
(T_START_HEREDOC 7 . 16) (T_ERROR 16 . 55)) 7 1)))
 
   (should (equal
'((T_OPEN_TAG 1 . 7) (T_START_HEREDOC 7 . 16) (T_ERROR 16 . 55))
-   (phps-mode/move-lexer-tokens '((T_OPEN_TAG 1 . 7) (T_START_HEREDOC 
7 . 16) (T_ERROR 16 . 55)) 20 1)))
+   (phps-mode/get-moved-lexer-tokens '((T_OPEN_TAG 1 . 7) 
(T_START_HEREDOC 7 . 16) (T_ERROR 16 . 55)) 20 1)))
 
   (should (equal
'((T_OPEN_TAG 2 . 8) (T_START_HEREDOC 8 . 17) (T_ERROR 17 . 56))
-   (phps-mode/move-lexer-tokens '((T_OPEN_TAG 1 . 7) (T_START_HEREDOC 
7 . 16) (T_ERROR 16 . 55)) -20 1)))
+   (phps-mode/get-moved-lexer-tokens '((T_OPEN_TAG 1 . 7) 
(T_START_HEREDOC 7 . 16) (T_ERROR 16 . 55)) -20 1)))
 
   )
 
@@ -303,7 +303,7 @@
   (phps-mode/test-lexer--complex-tokens)
   (phps-mode/test-lexer--namespaces)
   (phps-mode/test-lexer--errors)
-  (phps-mode/test-move-lexer-tokens)
+  (phps-mode/test-get-moved-lexer-tokens)
   ;; (message "\n-- Ran all tests for lexer. --")
   )
 



[elpa] externals/phps-mode 41ef691 112/405: Fixed lint warning of unused variables

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 41ef691d6eb2bbcd63f2cccec1b87b0ff9ad62aa
Author: Christian Johansson 
Commit: Christian Johansson 

Fixed lint warning of unused variables
---
 phps-mode-lexer.el | 41 ++---
 1 file changed, 18 insertions(+), 23 deletions(-)

diff --git a/phps-mode-lexer.el b/phps-mode-lexer.el
index 3fd2a42..c34 100644
--- a/phps-mode-lexer.el
+++ b/phps-mode-lexer.el
@@ -744,8 +744,8 @@
 (looking-at phps-mode-lexer-DNUM))
 (let* ((start (match-beginning 0))
(end (match-end 0))
-   (data (buffer-substring-no-properties start end)))
-  ;; (message "Exponent/double at: %s" data)
+   (_data (buffer-substring-no-properties start end)))
+  ;; (message "Exponent/double at: %s" _data)
   (phps-mode-lexer-RETURN_TOKEN 'T_DNUMBER start end)))
 
((looking-at phps-mode-lexer-LNUM)
@@ -777,7 +777,7 @@
((looking-at "\\(//\\|#\\)")
 (let* ((start (match-beginning 0))
(end (match-end 0))
-   (data (buffer-substring-no-properties start end))
+   (_data (buffer-substring-no-properties start end))
(line (buffer-substring-no-properties end (line-end-position
   (if (string-match "\\?>" line)
   (progn
@@ -807,7 +807,7 @@
((looking-at "/\\*")
 (let* ((start (match-beginning 0))
(end (match-end 0))
-   (data (buffer-substring-no-properties start end)))
+   (_data (buffer-substring-no-properties start end)))
   (let ((string-start (search-forward "*/" nil t))
 position)
 (if string-start
@@ -843,8 +843,7 @@
((looking-at "'")
 (let* ((start (match-beginning 0))
(end (match-end 0))
-   (data (buffer-substring-no-properties start end))
-   (found nil)
+   (_data (buffer-substring-no-properties start end))
(un-escaped-end (phps-modex/lex--get-next-unescaped "'")))
   (if un-escaped-end
   (progn
@@ -854,14 +853,13 @@
   ;; Unclosed single quotes
   ;; (message "Single quoted string never ends..")
   (phps-mode-lexer-RETURN_TOKEN 'T_ENCAPSED_AND_WHITESPACE start 
(point-max))
-  (phps-mode-lexer-MOVE_FORWARD (point-max))
-  
+  (phps-mode-lexer-MOVE_FORWARD (point-max))
 
;; Double quoted string
((looking-at "\"")
 (let* ((start (match-beginning 0))
(end (match-end 0))
-   (data (buffer-substring-no-properties start end)))
+   (_data (buffer-substring-no-properties start end)))
   (forward-char)
   ;; Handle the "" case
   (if (looking-at-p "\"")
@@ -883,8 +881,8 @@
 (goto-char string-start)
 (if (looking-at "[^]\"")
 (progn
-  (let ((double-quoted-string 
(buffer-substring-no-properties start (+ string-start 2
-;; (message "Double quoted string: %s" 
double-quoted-string)
+  (let ((_double-quoted-string 
(buffer-substring-no-properties start (+ string-start 2
+;; (message "Double quoted string: %s" 
_double-quoted-string)
 (phps-mode-lexer-RETURN_TOKEN 
'T_CONSTANT_ENCAPSED_STRING start (+ string-start 2
   (progn
 ;; (message "Found variable after '%s'" 
(buffer-substring-no-properties start string-start))
@@ -936,11 +934,10 @@
((looking-at phps-mode-lexer-WHITESPACE)
 (let* ((start (match-beginning 0))
(end (match-end 0))
-   (data (buffer-substring-no-properties start end)))
+   (_data (buffer-substring-no-properties start end)))
   (if phps-mode-lexer-PARSER_MODE
   (phps-mode-lexer-MOVE_FORWARD end)
-(phps-mode-lexer-RETURN_TOKEN 'T_WHITESPACE start end))
-  ))
+(phps-mode-lexer-RETURN_TOKEN 'T_WHITESPACE start end
 
((looking-at "->")
 (phps-mode-lexer-RETURN_TOKEN 'T_OBJECT_OPERATOR (match-beginning 0) 
(match-end 0)))
@@ -949,17 +946,15 @@
 (let ((start (match-beginning 0))
(end (match-end 0)))
   (phps-mode-lexer-yy_pop_state)
-  (phps-mode-lexer-RETURN_TOKEN 'T_STRING start end)
-  ))
+  (phps-mode-lexer-RETURN_TOKEN 'T_STRING start end)))
 
((looking-at phps-mode-lexer-ANY_CHAR)
-(let ((start (match-beginning 0))
+(let ((_start (match-beginning 0))
   (end (match-end 0)))
   (phps-mode-lexer-yy_pop_state)
   ;; TODO goto restart here?
   ;; (message "Restart here")
-  (phps-mode-lexer-MOVE_FORWARD end)
-  ))
+  (phps-mode-lexer-MOVE_FORWARD end)))
 
))
 
@@ -1157,8 +1152,8 @@ ANY_CHAR'
 (if string-start
 (let* ((start (match-beginning 0))
(end (match-end 0))
-   (data (buffer-substring-no-properties start end)))
-  ;; (message "Found something ending at %s" data)
+  

[elpa] externals/phps-mode e249124 152/405: Prevent negative indent

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit e249124491c3c910c30a9ce61fcb369762cb5e80
Author: Christian Johansson 
Commit: Christian Johansson 

Prevent negative indent
---
 phps-mode-functions.el  | 3 ++-
 phps-mode-test-functions.el | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index 290d643..fb3f594 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -87,7 +87,8 @@
 (setq nesting-end (+ round-bracket-level 
square-bracket-level curly-bracket-level alternative-control-structure-level 
inline-control-structure-level))
 
 ;; Is line ending indentation lesser than line beginning 
indentation?
-(when (< nesting-end nesting-start)
+(when (and (< nesting-end nesting-start)
+   (> column-level 0))
 
   ;; Decrease indentation by one
   (setq column-level (1- column-level)))
diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el
index ab63e80..f41a0e6 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -69,9 +69,9 @@
(should (equal '((1 (0 0)) (2 (0 0)) (3 (0 1)) (4 (0 1))) 
(phps-mode-test-functions--hash-to-list 
(phps-mode-functions-get-lines-indent)
 
   (phps-mode-test-with-buffer
-   "

[elpa] externals/phps-mode 16d8056 144/405: Foundation for new indentation tests completed

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 16d80562391d6778223183eaa3bfe80458a6e51b
Author: Christian Johansson 
Commit: Christian Johansson 

Foundation for new indentation tests completed
---
 phps-mode-test-functions.el | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el
index f8d39ab..31fe1ac 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -36,6 +36,15 @@
 (autoload 'hash-table-values "subr-x")
 (autoload 'should "ert")
 
+(defun phps-mode-test-functions--hash-to-list (hash-table)
+  "Return a list that represent the HASH-TABLE.  Each element is a list: (list 
key value)."
+  (let (result)
+(maphash
+ (lambda (k v)
+   (push (list k v) result))
+ hash-table)
+(nreverse result)))
+
 (defun phps-mode-test-functions-get-lines-indent ()
   "Test `phps-mode-functions-get-lines-indent' function."
 
@@ -44,7 +53,7 @@
   (phps-mode-test-with-buffer
"Bla bla"
(goto-char 15)
-   (should (equal '((0 0) (0 0) (1 0) (2 0) (1 0) (0 0)) (hash-table-values 
(phps-mode-functions-get-lines-indent)
+   (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (2 0)) (5 (1 0)) (6 (0 
0))) (phps-mode-test-functions--hash-to-list 
(phps-mode-functions-get-lines-indent)
 
   (phps-mode-test-with-buffer
"Bla bla"



[elpa] externals/phps-mode b852f5f 160/405: All tests for indentation passes

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit b852f5fd1db23a1891f5655e17882852bfa5570d
Author: Christian Johansson 
Commit: Christian Johansson 

All tests for indentation passes
---
 phps-mode-functions.el  | 16 +---
 phps-mode-test-functions.el |  6 +++---
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index 022ef6b..d488712 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -122,7 +122,7 @@
   (when first-token-is-nesting-increase
 (setq column-level (1+ column-level
 
-(message "new line at %s, %s %s.%s (%s - %s) = %s %s %s %s 
%s [%s %s] %s" token last-token column-level tuning-level nesting-start 
nesting-end round-bracket-level square-bracket-level curly-bracket-level 
alternative-control-structure-level inline-control-structure-level 
first-token-is-nesting-decrease first-token-is-nesting-increase in-assignment)
+;; (message "new line at %s, %s %s.%s (%s - %s) = %s %s %s 
%s %s [%s %s] %s" token last-token column-level tuning-level nesting-start 
nesting-end round-bracket-level square-bracket-level curly-bracket-level 
alternative-control-structure-level inline-control-structure-level 
first-token-is-nesting-decrease first-token-is-nesting-increase in-assignment)
 
 ;; Put indent-level to hash-table
 (when (> last-line-number 0)
@@ -302,19 +302,20 @@
 (if (string= token ";")
 (progn
   (setq in-assignment nil)
-  (message "Assignment ended at semi-colon"))
+  ;; (message "Assignment ended at semi-colon")
+  )
   (when first-token-on-line
 (if (or (equal token 'T_VARIABLE)
 (equal token 'T_CONSTANT_ENCAPSED_STRING)
 (equal token 'T_OBJECT_OPERATOR))
 (progn
-  (message "In assignment on new-line at %s" token)
+  ;; (message "In assignment on new-line at %s" token)
   (setq in-assignment-on-new-line t))
-  (message "Not in assignment on new-line at %s" token)
+  ;; (message "Not in assignment on new-line at %s" token)
   (setq in-assignment-on-new-line nil)
   (when (and (not after-special-control-structure)
  (string= token "="))
-(message "Started assignment")
+;; (message "Started assignment")
 (setq in-assignment t)
 (setq in-assignment-on-new-line nil))
 
@@ -357,7 +358,8 @@
 
 ;; Is line ending indentation lesser than line beginning 
indentation?
 (when (and (< nesting-end nesting-start)
-   (> column-level 0))
+   (> column-level 0)
+   (not in-assignment-on-new-line))
 
   ;; Decrement column
   (if allow-custom-column-decrement
@@ -374,7 +376,7 @@
   (when first-token-is-nesting-increase
 (setq column-level (1+ column-level
 
-(message "last token at %s %s.%s (%s - %s) = %s %s %s %s %s [%s 
%s]" last-token column-level tuning-level nesting-start nesting-end 
round-bracket-level square-bracket-level curly-bracket-level 
alternative-control-structure-level inline-control-structure-level 
first-token-is-nesting-decrease first-token-is-nesting-increase)
+;; (message "last token at %s %s.%s (%s - %s) = %s %s %s %s %s [%s 
%s]" last-token column-level tuning-level nesting-start nesting-end 
round-bracket-level square-bracket-level curly-bracket-level 
alternative-control-structure-level inline-control-structure-level 
first-token-is-nesting-decrease first-token-is-nesting-increase)
 
 ;; Put indent-level to hash-table
 (puthash last-line-number `(,column-level ,tuning-level) 
line-indents))
diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el
index c862954..46d0ec5 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -179,7 +179,7 @@
"Round bracket test 1"
(goto-char 30)
(phps-mode-functions-indent-line)
-   (message "Tokens %s point %s" phps-mode-lexer-tokens (point))
+   ;; (message "Tokens %s point %s" phps-mode-lexer-tokens (point))
(let ((buffer-contents (buffer-substring-no-properties (point-min) 
(point-max
  (should (equal buffer-contents  "getHead()\n->getTail();\n"
"Multi-line assignment indentation test 1"
-   (message "Tokens: %s" phps-mode-lexer-tokens)
+   ;; (message "Tokens: %s" phps-mode-lexer-tokens)
(goto-char 35)
(phps-mode-functions-indent-line)
(let ((buffer-contents (buffer-substring-no-properties (poi

[elpa] externals/phps-mode 3740660 095/405: Get point-data now collects information about square brackets

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 37406602856c1528c174dac5b79016424a10b8e9
Author: Christian Johansson 
Commit: Christian Johansson 

Get point-data now collects information about square brackets
---
 phps-functions.el  | 42 +-
 phps-test-functions.el |  7 +++
 2 files changed, 32 insertions(+), 17 deletions(-)

diff --git a/phps-functions.el b/phps-functions.el
index 22e42ee..227d0f4 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -43,6 +43,7 @@
   "Start of buffer changes, nil if none.")
 
 ;; NOTE Also format white-space inside the line, i.e. after function 
declarations?
+
 ;; 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
@@ -203,13 +204,15 @@
   (let ((line-beginning (point))
 (line-end (line-end-position))
 (start-in-scripting nil)
-(start-brace-level 0)
-(start-parenthesis-level 0)
+(start-curly-bracket-level 0)
+(start-round-bracket-level 0)
+(start-square-bracket-level 0)
 (start-inline-function-level 0)
 (start-token-number nil)
 (end-in-scripting nil)
-(end-brace-level 0)
-(end-parenthesis-level 0)
+(end-curly-bracket-level 0)
+(end-round-bracket-level 0)
+(end-square-bracket-level 0)
 (end-inline-function-level 0)
 (end-token-number nil)
 (line-in-doc-comment nil)
@@ -240,14 +243,17 @@
   ('T_OPEN_TAG (setq start-in-scripting t))
   ('T_OPEN_TAG_WITH_ECHO (setq start-in-scripting t))
   ('T_CLOSE_TAG (setq start-in-scripting nil))
-  ('T_CURLY_OPEN (setq start-brace-level (+ start-brace-level 
1)))
-  ('T_DOLLAR_OPEN_CURLY_BRACES (setq start-brace-level (+ 
start-brace-level 1)))
-  ("}" (setq start-brace-level (- start-brace-level 1)))
-  ("{" (setq start-brace-level (+ start-brace-level 1)))
-  ("(" (setq start-parenthesis-level (+ 
start-parenthesis-level 1)))
-  (")" (setq start-parenthesis-level (- 
start-parenthesis-level 1)))
+  ('T_CURLY_OPEN (setq start-curly-bracket-level (+ 
start-curly-bracket-level 1)))
+  ('T_DOLLAR_OPEN_CURLY_BRACES (setq start-curly-bracket-level 
(+ start-curly-bracket-level 1)))
+  ("{" (setq start-curly-bracket-level (+ 
start-curly-bracket-level 1)))
+  ("}" (setq start-curly-bracket-level (- 
start-curly-bracket-level 1)))
+  ("[" (setq start-square-bracket-level (+ 
start-square-bracket-level 1)))
+  ("]" (setq start-square-bracket-level (- 
start-square-bracket-level 1)))
+  ("(" (setq start-round-bracket-level (+ 
start-round-bracket-level 1)))
+  (")" (setq start-round-bracket-level (- 
start-round-bracket-level 1)))
   (_)))
 
+  ;; Are we at the final line and inside a doc-comment that ends 
after it?
   (when (and (< token-start line-beginning)
  (>= token-end line-end)
  (eq token 'T_DOC_COMMENT))
@@ -262,19 +268,21 @@
   ('T_OPEN_TAG (setq end-in-scripting t))
   ('T_OPEN_TAG_WITH_ECHO (setq end-in-scripting t))
   ('T_CLOSE_TAG (setq end-in-scripting nil))
-  ('T_CURLY_OPEN (setq end-brace-level (+ end-brace-level 1)))
-  ('T_DOLLAR_OPEN_CURLY_BRACES (setq end-brace-level (+ 
end-brace-level 1)))
-  ("}" (setq end-brace-level (- end-brace-level 1)))
-  ("{" (setq end-brace-level (+ end-brace-level 1)))
-  ("(" (setq end-parenthesis-level (+ end-parenthesis-level 
1)))
-  (")" (setq end-parenthesis-level (- end-parenthesis-level 
1)))
+  ('T_CURLY_OPEN (setq end-curly-bracket-level (+ 
end-curly-bracket-level 1)))
+  ('T_DOLLAR_OPEN_CURLY_BRACES (setq end-curly-bracket-level 
(+ end-curly-bracket-level 1)))
+  ("{" (setq end-curly-bracket-level (+ 
end-curly-bracket-level 1)))
+  ("}" (setq end-curly-bracket-level (- 
end-curly-bracket-level 1)))
+  ("[" (setq end-square-bracket-level (+ 
end-square-bracket-level 1)))
+  ("]" (setq end-square-bracket-level (- 
end-square-bracket-level 1)))
+  ("(" (setq end-round-bracket-level (+ 
end-round-bracket-level 1)))
+  (")" (setq end-round-bracket-level (- 
end-round-bracket-level 1)))
   (_)))
   
   )))
 (when (not found-line-tokens)
   (setq start-token-number nil)
  

[elpa] externals/phps-mode be35ed6 127/405: Added sample files for inline and alternative control structures

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit be35ed6f06a22c3640adc3dfe1649ec319000312
Author: Christian Johansson 
Commit: Christian Johansson 

Added sample files for inline and alternative control structures
---
 sample-php-files/alternative-control-structure.php | 22 ++
 sample-php-files/inline-control-structures.php | 17 +
 2 files changed, 39 insertions(+)

diff --git a/sample-php-files/alternative-control-structure.php 
b/sample-php-files/alternative-control-structure.php
new file mode 100644
index 000..a9f0bef
--- /dev/null
+++ b/sample-php-files/alternative-control-structure.php
@@ -0,0 +1,22 @@
+

[elpa] externals/phps-mode 0b3ced4 145/405: First test for new indentation function passes

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 0b3ced435710c7685477db67a605c3aa66246ad9
Author: Christian Johansson 
Commit: Christian Johansson 

First test for new indentation function passes
---
 phps-mode-functions.el | 28 
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index 09b55c3..f782565 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -40,7 +40,7 @@
 ;; TODO Support indentation for multi-line assignments
 
 (defun phps-mode-functions-get-lines-indent ()
-  "Get the column and tuning indentation-numbers for each line in buffer that 
contains tokens."
+  "Get the column and tuning indentation-numbers for each line in buffer that 
contain tokens."
   (if (boundp 'phps-mode-lexer-tokens)
   (save-excursion
 (beginning-of-line)
@@ -64,7 +64,9 @@
   (last-line-number 0)
   (first-token-on-line nil)
   (line-indents (make-hash-table :test 'equal))
-  (change-of-scope nil))
+  (change-of-scope nil)
+  (token-number 1)
+  (last-token-number (length phps-mode-lexer-tokens)))
 
   ;; Iterate through all buffer tokens from beginning to end
   (dolist (item phps-mode-lexer-tokens)
@@ -74,18 +76,13 @@
(token-line-number (line-number-at-pos token-start t)))
 
   ;; Are we on a new line?
-  (if (> token-line-number last-line-number)
+  (if (or (> token-line-number last-line-number)
+  (= token-number last-token-number))
   (progn
 
 ;; Calculate indentation level at end of line
 (setq nesting-end (+ round-bracket-level 
square-bracket-level curly-bracket-level alternative-control-structure-level 
inline-control-structure-level))
 
-;; Is line ending indentation higher than line beginning 
indentation?
-(when (> nesting-end nesting-start)
-
-  ;; Increase indentation by one
-  (setq column-level (1+ column-level)))
-
 ;; Is line ending indentation lesser than line beginning 
indentation?
 (when (< nesting-end nesting-start)
 
@@ -96,8 +93,7 @@
 (when (and (= nesting-end nesting-start)
change-of-scope)
   (setq column-level (1- column-level)))
-  
-
+
 ;; Increase indent with one space inside doc-comment, 
HEREDOC or NOWDOC
 (if (or in-doc-comment in-heredoc)
 (setq tuning-level 1)
@@ -109,6 +105,12 @@
 (when (> last-line-number 0)
   (puthash last-line-number `(,column-level ,tuning-level) 
line-indents))
 
+;; Is line ending indentation higher than line beginning 
indentation?
+(when (> nesting-end nesting-start)
+
+  ;; Increase indentation by one
+  (setq column-level (1+ column-level)))
+
 ;; Calculate indentation level at start of line
 (setq nesting-start (+ round-bracket-level 
square-bracket-level curly-bracket-level alternative-control-structure-level 
inline-control-structure-level))
 
@@ -233,7 +235,9 @@
 ;; Update last line number
 (setq last-line-number token-line-number))
 
-  ))
+  )
+
+(setq token-number (1+ token-number)))
 
   line-indents))
 nil))



[elpa] externals/phps-mode feb5724 039/405: Various debug work

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit feb57241345c4e55fdec6ea6ea310cecb3314215
Author: Christian Johansson 
Commit: Christian Johansson 

Various debug work
---
 phps-lexer.el  | 10 ++
 phps-test-lexer.el | 23 ---
 2 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/phps-lexer.el b/phps-lexer.el
index 8c545d4..61ad818 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -891,7 +891,7 @@
 ;; (message "Double quoted string: %s" 
double-quoted-string)
 (phps-mode/RETURN_TOKEN 'T_CONSTANT_ENCAPSED_STRING 
start (+ string-start 2
   (progn
-;; (message "Found variable after '%s'" 
(buffer-substring-no-properties start (point)))
+(message "Found variable after '%s'" 
(buffer-substring-no-properties start string-start))
 (phps-mode/BEGIN phps-mode/ST_DOUBLE_QUOTES)
 (phps-mode/RETURN_TOKEN "\"" start (+ start 1))
 (phps-mode/RETURN_TOKEN 'T_ENCAPSED_AND_WHITESPACE (+ 
start 1) string-start
@@ -1001,7 +1001,7 @@
 
((looking-at "[\"]")
 (phps-mode/BEGIN phps-mode/ST_IN_SCRIPTING)
-;; (message "Ended double-quote at %s" (match-beginning 0))
+(message "Ended double-quote at %s" (match-beginning 0))
 (phps-mode/RETURN_TOKEN "\"" (match-beginning 0) (match-end 0)))
 
((looking-at phps-mode/ANY_CHAR)
@@ -1048,7 +1048,8 @@ ANY_CHAR'
 
  ((looking-at (concat "\\$" phps-mode/LABEL "->" "[a-zA-Z_\x80-\xff]"))
   (phps-mode/yy_push_state phps-mode/ST_LOOKING_FOR_PROPERTY)
-  (phps-mode/RETURN_TOKEN 'T_VARIABLE (match-beginning 0) (match-end 
0)))
+  (forward-char -3)
+  (phps-mode/RETURN_TOKEN 'T_VARIABLE (match-beginning 0) (- 
(match-end 0) 3)))
 
  ((looking-at (concat "\\$" phps-mode/LABEL "\\["))
   (phps-mode/yy_push_state phps-mode/ST_VAR_OFFSET)
@@ -1100,7 +1101,8 @@ ANY_CHAR'
 
  ((looking-at (concat "\\$" phps-mode/LABEL "->" "[a-zA-Z_\x80-\xff]"))
   (phps-mode/yy_push_state phps-mode/ST_LOOKING_FOR_PROPERTY)
-  (phps-mode/RETURN_TOKEN 'T_VARIABLE (match-beginning 0) (match-end 0)))
+  (forward-char -3)
+  (phps-mode/RETURN_TOKEN 'T_VARIABLE (match-beginning 0) (- (match-end 0) 
3)))
 
  ((looking-at (concat "\\$" phps-mode/LABEL "\\["))
   (phps-mode/yy_push_state phps-mode/ST_VAR_OFFSET)
diff --git a/phps-test-lexer.el b/phps-test-lexer.el
index eb1af34..3147afd 100644
--- a/phps-test-lexer.el
+++ b/phps-test-lexer.el
@@ -212,6 +212,25 @@
(should (equal phps-mode/lexer-tokens
   '((T_OPEN_TAG 1 . 7) ("`" 7 . 8) (T_CONSTANT_ENCAPSED_STRING 
8 . 20) (T_VARIABLE 20 . 29) (T_CONSTANT_ENCAPSED_STRING 29 . 33) (T_CURLY_OPEN 
33 . 34) (T_VARIABLE 34 . 44) ("}" 44 . 45) (T_CONSTANT_ENCAPSED_STRING 45 . 
49) (T_DOLLAR_OPEN_CURLY_BRACES 49 . 51) (T_STRING_VARNAME 51 . 60) ("}" 60 . 
61) (T_CONSTANT_ENCAPSED_STRING 61 . 65) (T_VARIABLE 65 . 75) (T_STRING 75 . 
80) ("]" 80 . 81) (T_CONSTANT_ENCAPSED_STRING 81 . 90) ("`" 90 . 91) (";" 91 . 
92)
 
+  (phps-mode/with-test-buffer
+   "posts; ?>"
+   (should (equal phps-mode/lexer-tokens
+  '((T_OPEN_TAG 1 . 7) (T_VARIABLE 7 . 12) (T_OBJECT_OPERATOR 
12 . 14) (T_STRING 14 . 19) (";" 19 . 20) (";" 21 . 23) (T_CLOSE_TAG 21 . 
23)
+
+  ;; TODO Fix this, produces invalid tokens
+  (phps-mode/with-test-buffer
+   "posts WHERE ID = 
'\".$id.\"'\"; ?>"
+   (message "Tokens 1: %s" phps-mode/lexer-tokens)
+   (should (equal phps-mode/lexer-tokens
+  '((T_OPEN_TAG 1 . 7) (T_VARIABLE 7 . 11) ("=" 12 . 13) ("\"" 
14 . 15) (T_ENCAPSED_AND_WHITESPACE 15 . 39) (T_VARIABLE 39 . 47) (T_STRING 47 
. 51) (T_CONSTANT_ENCAPSED_STRING 51 . 64) ("\"" 64 . 65) ("." 65 . 66) 
(T_VARIABLE 66 . 69) ("." 69 . 70) (T_CONSTANT_ENCAPSED_STRING 70 . 73) (";" 73 
. 74) (";" 75 . 77) (T_CLOSE_TAG 75 . 77)
+
+  ;; TODO Fix this, produces invalid tokens
+  (phps-mode/with-test-buffer
+   "get_var(\"SELECT post_parent FROM $wpdb->posts WHERE ID = 
'\".$id.\"'\"); ?>"
+   (message "Tokens 2: %s" phps-mode/lexer-tokens)
+   (should (equal phps-mode/lexer-tokens
+  '((T_OPEN_TAG 1 . 7) (T_VARIABLE 7 . 12) (T_OBJECT_OPERATOR 
12 . 14) (T_STRING 14 . 21) ("(" 21 . 22) ("\"" 22 . 23) 
(T_ENCAPSED_AND_WHITESPACE 23 . 47) (T_VARIABLE 47 . 54) (T_OBJECT_OPERATOR 54 
. 56) (T_STRING 56 . 59) (T_CONSTANT_ENCAPSED_STRING 59 . 72) ("\"" 72 . 73) 
("." 73 . 74) (T_VARIABLE 74 . 77) ("." 77 . 78) (T_CONSTANT_ENCAPSED_STRING 78 
. 81) (")" 81 . 82) (";" 82 . 83) (";" 84 . 86) (T_CLOSE_TAG 84 . 86)
+
   )
 
 (defun phps-mode/test-lexer--namespaces ()
@@ -296,12 +315,10 @@
 
   )
 
-;; TODO Test this: $wpdb->get_var("SELECT post_parent FROM $wpdb->posts WHERE 
ID = '".$id."'");
-
 (defun phps-mode/test-lexer ()
   "Run test for lexer."
   ;; (message "-- Running all tests for lexer... --\n")
-  (setq debug-on-error t)
+  ;; (setq debu

[elpa] externals/phps-mode 9792f70 133/405: Cleaning up code gather point meta information

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 9792f70d0863a9ae12ed8f25a1eaee0c94e7f94e
Author: Christian Johansson 
Commit: Christian Johansson 

Cleaning up code gather point meta information
---
 phps-mode-functions.el | 41 +
 1 file changed, 17 insertions(+), 24 deletions(-)

diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index 088d31b..b37ecc4 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -203,6 +203,7 @@
 ;; TODO This function needs to keep track of alternative syntax for the 
control structures: if, while, for, foreach, and switch
 ;; TODO This function needs to keep track of inline syntax for the control 
structures: if, while, for, foreach, and switch
 ;; TODO Support switch case as well
+;; TODO Keep track of assignments as well
 
 (defun phps-mode-functions-get-point-data ()
   "Return information about point in tokens."
@@ -240,12 +241,18 @@
   (token-end (cdr (cdr item
   ;; (message "Token: %s Start: %s End: %s Item: %s" token start 
end item)
 
-  ;; Does token start after the end of line?
+  ;; Does token start after the end of line? - break
   (when (> token-start line-end)
 ;; (message "Stopping iteration at: %s %s" start position)
 (throw 'stop-iteration nil))
 
-  ;; Did we find any token on current line?
+  ;; Keep track of general round brace level
+  (when (string= token "(")
+(setq round-brace-level (1+ round-brace-level)))
+  (when (string= token ")")
+(setq round-brace-level (1- round-brace-level)))
+
+  ;; Did we find any token on current line? - flag t
   (when (and (not found-line-tokens)
  (>= token-start line-beginning)
  (<= token-end line-end))
@@ -273,21 +280,19 @@
   (")" (setq start-round-bracket-level (1- 
start-round-bracket-level)))
   (_))
 
-;; Did we encounter end of alternative control structure?
+;; Did we encounter end of an alternative control structure?
 (when (or (equal token 'T_ENDIF)
   (equal token 'T_ENDWHILE)
   (equal token 'T_ENDFOR)
   (equal token 'T_ENDFOREACH)
   (equal token 'T_ENDSWITCH))
-  (setq start-alternative-control-structure-level (- 
start-alternative-control-structure-level 1)))
+  (setq start-alternative-control-structure-level (1- 
start-alternative-control-structure-level)))
 
 ;; Reduce inline control structure level when we encounter a 
semi-colon after it's opening
 (when (and start-expecting-semi-colon
(string= token ";"))
-  (setq start-inline-control-structure-level (- 
start-inline-control-structure-level 1))
-  (setq start-expecting-semi-colon nil))
-
-)
+  (setq start-inline-control-structure-level (1- 
start-inline-control-structure-level))
+  (setq start-expecting-semi-colon nil)))
 
   ;; Are we at the final line and inside a doc-comment that ends 
after it?
   (when (and (< token-start line-beginning)
@@ -295,7 +300,7 @@
  (eq token 'T_DOC_COMMENT))
 (setq line-in-doc-comment t))
 
-  ;; When start of token is equal or less to end of curent line
+  ;; When start of token is equal or less to end of current line
   (when (<= token-start line-end)
 
 ;; Increment end token number
@@ -317,7 +322,7 @@
   (")" (setq end-round-bracket-level (1- 
end-round-bracket-level)))
   (_))
 
-;; Do we encounter first token on line?
+;; Do we encounter first token on current line?
 (when (and (not first-token-on-line)
(>= token-start line-beginning)
(<= token-start line-end))
@@ -338,15 +343,7 @@
 (when (and end-expecting-semi-colon
(string= token ";"))
   (setq end-inline-control-structure-level (- 
end-inline-control-structure-level 1))
-  (setq end-expecting-semi-colon nil))
-
-)
-
-  ;; Keep track of general round brace level
-  (when (string= token "(")
-(setq round-brace-level (1+ round-brace-level)))
-  (when (string= token ")")
-(setq round-brace-level (1- round-brace-level)))
+  (setq end-expecting-semi-colon nil)))
 
   ;; Are we after a special control structure
   ;; and does the round bracket level match initial round bracket 

[elpa] externals/phps-mode 3f4c344 056/405: Fixed detection of doc comment blocks

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 3f4c344fbaeb8d031afdc431b71e5f28bd32e38d
Author: Christian Johansson 
Commit: Christian Johansson 

Fixed detection of doc comment blocks
---
 phps-lexer.el  | 26 --
 phps-test-functions.el |  3 ++-
 phps-test-lexer.el |  5 +
 3 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/phps-lexer.el b/phps-lexer.el
index bb4c98f..3662d5e 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -1271,41 +1271,39 @@ ANY_CHAR'
   (start-parenthesis-level 0)
   (start-inline-function-level 0)
   (start-token-number nil)
-  (start-in-doc-comment nil)
   (end-in-scripting nil)
   (end-brace-level 0)
   (end-parenthesis-level 0)
   (end-inline-function-level 0)
   (end-token-number nil)
-  (end-in-doc-comment nil)
+  (line-in-doc-comment nil)
   (found-line-tokens nil))
   (catch 'stop-iteration
 (dolist (item phps-mode/lexer-tokens)
   (let ((token (car item))
-(start (car (cdr item)))
-(end (cdr (cdr item
+(token-start (car (cdr item)))
+(token-end (cdr (cdr item
 ;; (message "Token: %s Start: %s End: %s Item: %s" token start end 
item)
 
-(when (> start line-end)
+(when (> token-start line-end)
   ;; (message "Stopping iteration at: %s %s" start position)
   (throw 'stop-iteration nil))
 
 (when (and (not found-line-tokens)
-   (>= start position)
-   (<= end line-end))
+   (>= token-start position)
+   (<= token-end line-end))
   (setq found-line-tokens t))
 
 ;; When end of token is equal or less to current point
-(when (<= end position)
+(when (<= token-end position)
   (when (null start-token-number)
 (setq start-token-number -1))
   (setq start-token-number (+ start-token-number 1))
-  (setq start-in-doc-comment nil)
   (pcase token
 ('T_OPEN_TAG (setq start-in-scripting t))
 ('T_OPEN_TAG_WITH_ECHO (setq start-in-scripting t))
 ('T_CLOSE_TAG (setq start-in-scripting nil))
-('T_DOC_COMMENT (setq start-in-doc-comment t))
+('T_DOC_COMMENT (setq start-in-doc-comment nil))
 ("}" (setq start-brace-level (- start-brace-level 1)))
 ("{" (setq start-brace-level (+ start-brace-level 1)))
 ("(" (setq start-parenthesis-level (+ start-parenthesis-level 
1)))
@@ -1313,16 +1311,16 @@ ANY_CHAR'
 (_)))
 
 ;; When start of token is equal or less to end of curent line
-(when (<= start line-end)
+(when (<= token-start line-end)
   (when (null end-token-number)
 (setq end-token-number -1))
   (setq end-token-number (+ end-token-number 1))
-  (setq end-in-doc-comment nil)
+  (setq line-in-doc-comment nil)
   (pcase token
 ('T_OPEN_TAG (setq end-in-scripting t))
 ('T_OPEN_TAG_WITH_ECHO (setq end-in-scripting t))
 ('T_CLOSE_TAG (setq end-in-scripting nil))
-('T_DOC_COMMENT (setq end-in-doc-comment t))
+('T_DOC_COMMENT (setq line-in-doc-comment t))
 ("}" (setq end-brace-level (- end-brace-level 1)))
 ("{" (setq end-brace-level (+ end-brace-level 1)))
 ("(" (setq end-parenthesis-level (+ end-parenthesis-level 1)))
@@ -1333,7 +1331,7 @@ ANY_CHAR'
   (when (not found-line-tokens)
 (setq start-token-number nil)
 (setq end-token-number nil))
-  (let ((data (list (list start-in-scripting start-brace-level 
start-parenthesis-level start-inline-function-level start-token-number 
start-in-doc-comment) (list end-in-scripting end-brace-level 
end-parenthesis-level end-inline-function-level end-token-number 
end-in-doc-comment
+  (let ((data (list (list start-in-scripting start-brace-level 
start-parenthesis-level start-inline-function-level start-token-number 
line-in-doc-comment) (list end-in-scripting end-brace-level 
end-parenthesis-level end-inline-function-level end-token-number 
line-in-doc-comment
 ;; (message "data: %s" data)
 data
 
diff --git a/phps-test-functions.el b/phps-test-functions.el
index c0cfd23..ae9d11d 100644
--- a/phps-test-functions.el
+++ b/phps-test-functions.el
@@ -38,6 +38,7 @@
 
 
 (autoload 'phps-mode/with-test-buffer "phps-test")
+(autoload 'phps-mode/indent-line "phps-functions")
 (autoload 'should "ert")
 
 (defun phps-mode/test-indent-line ()
@@ -93,7 +94,7 @@
"

[elpa] externals/phps-mode 1be9270 068/405: Updated README

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 1be92700bdf2693cf24e277f7e16392a6454c20d
Author: Christian Johansson 
Commit: Christian Johansson 

Updated README
---
 README.md | 1 +
 phps-lexer.el | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 927b753..b05047c 100644
--- a/README.md
+++ b/README.md
@@ -14,6 +14,7 @@ With current progress estimates:
 * Incremental lexer and syntax coloring after changes (50%)
 * Full integration with Emacs Semantic subsystem (30%)
 * Flymake support (0%)
+* PSR-2 auto-formatting tool based on lexer tokens (0%)
 
 ## Unit tests
 
diff --git a/phps-lexer.el b/phps-lexer.el
index ca68697..2baabc1 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -1262,7 +1262,7 @@ ANY_CHAR'
 ;; TODO Need to store lexer state and stack at each changing point of buffer 
to be able to rewind lexer
 (defun phps-mode/lex--SETUP (start end)
   "Just prepare other lexers for lexing region START to END."
-  (message "phps-mode/lex--SETUP %s %s" start end)
+  ;; (message "phps-mode/lex--SETUP %s %s" start end)
   (when (and (eq start 1)
  end)
 (delete-all-overlays)



[elpa] externals/phps-mode a61cb8b 062/405: Fixed issue with doc comment indentation

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit a61cb8ba0b1ceb8f35e0f293a36ccae50a8aa5f5
Author: Christian Johansson 
Commit: Christian Johansson 

Fixed issue with doc comment indentation
---
 phps-functions.el  | 13 -
 sample-php-files/class.php |  2 +-
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/phps-functions.el b/phps-functions.el
index 8115cf1..a0f4aa1 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -67,13 +67,14 @@
(boundp 'phps-mode/lexer-tokens)
(> indent-start indent-end))
   (let ((token-number start-token-number)
-(valid-tokens t))
+(valid-tokens t)
+(tokens phps-mode/lexer-tokens))
 ;; (message "token start %s, token end %s" start-token-number 
end-token-number)
 (while (and valid-tokens
 (<= token-number end-token-number))
-  (let ((token (car (nth token-number phps-mode/lexer-tokens)))
-(token-start (car (cdr (nth token-number 
phps-mode/lexer-tokens
-(token-end (cdr (cdr (nth token-number 
phps-mode/lexer-tokens)
+  (let ((token (car (nth token-number tokens)))
+(token-start (car (cdr (nth token-number tokens
+(token-end (cdr (cdr (nth token-number tokens)
 (when (and valid-tokens
(or (>= token-start (point))
(>= token-end (point)))
@@ -86,7 +87,7 @@
  (string= token "]")
  (string= token ";")
  (eq token 'T_CLOSE_TAG
-  ;; (message "Token %s - %s in %s was invalid" token 
token-number phps-mode/lexer-tokens)
+  ;; (message "Token %s - %s in %s was invalid" token 
token-number tokens)
   (setq valid-tokens nil)))
   (setq token-number (+ token-number 1)))
 (when valid-tokens
@@ -155,6 +156,7 @@
 ;; (message "Stopping iteration at: %s %s" start position)
 (throw 'stop-iteration nil))
 
+  ;; Did we find any token on this line?
   (when (and (not found-line-tokens)
  (>= token-start line-beginning)
  (<= token-end line-end))
@@ -176,6 +178,7 @@
   (_)))
 
   (when (and (< token-start line-beginning)
+ (>= token-end line-end)
  (eq token 'T_DOC_COMMENT))
 (setq line-in-doc-comment t))
 
diff --git a/sample-php-files/class.php b/sample-php-files/class.php
index e980006..730480e 100644
--- a/sample-php-files/class.php
+++ b/sample-php-files/class.php
@@ -2,7 +2,7 @@
 /**
  * Some comments here
  * @todo was here
- */
+ **/
 
 class MyClass
 {



[elpa] externals/phps-mode 5e30a65 076/405: Added TODO items

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 5e30a6575db7057cbff3807ddc92912c421fca36
Author: Christian Johansson 
Commit: Christian Johansson 

Added TODO items
---
 phps-functions.el  | 6 ++
 phps-test-functions.el | 9 +
 2 files changed, 15 insertions(+)

diff --git a/phps-functions.el b/phps-functions.el
index 03f2d8c..0e84dc5 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -121,12 +121,18 @@
   (when (not (equal indent-sum (current-indentation)))
 ;; (message "Indenting to %s current column %s" indent-sum 
(current-indentation))
 ;; (message "inside scripting, start: %s, end: %s, indenting 
to column %s " start end indent-level)
+
+;; TODO When indent is changed the trailing tokens just need 
to adjust their token positions, this will improve speed of indent-region a lot
 (indent-line-to indent-sum)
+
 (let ((line-start (line-beginning-position)))
+
+  ;; Set point of change if it's not set or if it's larger 
than current point
   (when (or (not phps-mode/buffer-changes--start)
 (< line-start phps-mode/buffer-changes--start))
 ;; (message "Setting changes start from %s to %s" 
phps-mode/buffer-changes--start start)
 (setq phps-mode/buffer-changes--start line-start))
+  
   (phps-mode/run-incremental-lex))
 
 ;; TODO Implement this?
diff --git a/phps-test-functions.el b/phps-test-functions.el
index c24b35b..ff3f82d 100644
--- a/phps-test-functions.el
+++ b/phps-test-functions.el
@@ -137,6 +137,15 @@
(let ((buffer-contents (buffer-substring-no-properties (point-min) 
(point-max
  (should (equal buffer-contents "var
+;; ) && !empty($this->var)
+;; ) {
+;; $this->var = 'abc123';
+;; }
+
+
   )
 
 (defun phps-mode/test-functions--get-point-data ()



[elpa] externals/phps-mode da1d1de 051/405: Temporary lexer after change until other work is ready

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit da1d1de15d3652fdfda30380cfcd7bd7ebf4c76c
Author: Christian Johansson 
Commit: Christian Johansson 

Temporary lexer after change until other work is ready
---
 phps-functions.el  | 3 ++-
 phps-lexer.el  | 7 +--
 sample-php-files/class.php | 3 ---
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/phps-functions.el b/phps-functions.el
index 2ca33aa..a7b795b 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -91,7 +91,8 @@
 ;; (message "Tokens was valid, decreasing indent %s - %s" 
(line-beginning-position) (line-end-position))
 (setq indent-level (- indent-level (- indent-start 
indent-end))
   ;; (message "inside scripting, start: %s, end: %s, indenting to 
column %s " start end indent-level)
-  (indent-line-to (* indent-level tab-width)
+  (indent-line-to (* indent-level tab-width))
+  (phps-mode/run-incremental-lex
 
 ;; TODO Implement this
 (defun phps-mode/indent-region ()
diff --git a/phps-lexer.el b/phps-lexer.el
index 78919e3..123a3cb 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -1331,8 +1331,10 @@ ANY_CHAR'
   (when (and (eq start 1)
  end)
 ;; (message "SETUP %s %s" start end)
+(delete-all-overlays)
 (when (boundp 'phps-mode/buffer-changes--start)
   (setq phps-mode/buffer-changes--start nil))
+
 (phps-mode/BEGIN phps-mode/ST_INITIAL)))
 
 (defun phps-mode/lex--RUN ()
@@ -1343,8 +1345,9 @@ ANY_CHAR'
 (defun phps-mode/run-incremental-lex ()
   "Run incremental lexer based on `phps-mode/buffer-changes--start'."
   (when (boundp 'phps-mode/buffer-changes--start)
-(message "Should run incremental lex here %s - %s" 
phps-mode/buffer-changes--start (point-max))
-(semantic-lex phps-mode/buffer-changes--start (point-max))
+(semantic-lex-buffer)
+;; TODO (message "Should run incremental lex here %s - %s" 
phps-mode/buffer-changes--start (point-max))
+;; TODO (semantic-lex phps-mode/buffer-changes--start (point-max))
 (setq phps-mode/buffer-changes--start nil)))
 
 (define-lex phps-mode/tags-lexer
diff --git a/sample-php-files/class.php b/sample-php-files/class.php
index c7ac743..e980006 100644
--- a/sample-php-files/class.php
+++ b/sample-php-files/class.php
@@ -15,9 +15,6 @@ class MyClass
 public function myMethod()
 {
 echo "Some stuff here"; // Just a comment
-if ($this->var) {
-
-}
 }
 
 public function myMethod2() {



[elpa] externals/phps-mode 8aa1ab6 059/405: Another test for getting point data inside doc block

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 8aa1ab684369fac35af4ac38f7bfd81f571c60bd
Author: Christian Johansson 
Commit: Christian Johansson 

Another test for getting point data inside doc block
---
 phps-test-functions.el | 5 +
 1 file changed, 5 insertions(+)

diff --git a/phps-test-functions.el b/phps-test-functions.el
index d8fae17..5b695cc 100644
--- a/phps-test-functions.el
+++ b/phps-test-functions.el
@@ -181,6 +181,11 @@
(goto-char 9)
(should (equal (list (list nil 0 0 0 nil nil) (list t 0 0 0 1 nil)) 
(phps-mode/get-point-data
 
+  (phps-mode/with-test-buffer
+   "https://www.php-fig.org/psr/psr-2/



[elpa] externals/phps-mode 99dfc68 067/405: Incremental-lexer deletes affected overlays

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 99dfc686eb3abf6d8137d3b0d6e28ee92661d470
Author: Christian Johansson 
Commit: Christian Johansson 

Incremental-lexer deletes affected overlays
---
 phps-lexer.el | 5 +
 1 file changed, 5 insertions(+)

diff --git a/phps-lexer.el b/phps-lexer.el
index bd0a586..ca68697 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -1319,6 +1319,10 @@ ANY_CHAR'
 (throw 'stop-iteration nil)
 
 (setq old-tokens (nreverse old-tokens))
+
+;; Delete all overlays from point of change to end of buffer
+(dolist (overlay (overlays-in previous-token-start (point-max)))
+(delete-overlay overlay))
 
 (let* ((new-tokens (semantic-lex previous-token-start (point-max)))
(appended-tokens (append old-tokens new-tokens)))
@@ -1327,6 +1331,7 @@ ANY_CHAR'
   (setq phps-mode/STATE state)
   (setq phps-mode/state_stack state-stack)
   (setq phps-mode/lexer-states new-states)
+  
   ;; TODO Should clear overlays after point of change here
   ;; (message "Rewinding lex to state: %s and stack: %s and 
states: %s and start: %s old tokens: %s" state state-stack new-states 
previous-token-start old-tokens)
 



[elpa] externals/phps-mode 7e2e902 126/405: Fixed a unit test

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 7e2e902b849fddf5190d93bf465ece64ecf01f34
Author: Christian Johansson 
Commit: Christian Johansson 

Fixed a unit test
---
 phps-mode-test-functions.el | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el
index dfa39ed..141ef33 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -209,11 +209,11 @@
  (should (equal buffer-contents " 'abc',\n),\n   
 $var2\n);\n"
-   (goto-char 50)
+   " 'abc',\n),\n   
 $var5\n);\n"
+   (goto-char 65)
(phps-mode-functions-indent-line)
(let ((buffer-contents (buffer-substring-no-properties (point-min) 
(point-max
- (should (equal buffer-contents " 'abc',\n),\n$var2\n);\n"
+ (should (equal buffer-contents " 'abc',\n),\n$var5\n);\n"
 
   (phps-mode-test-with-buffer
"getHead()\n->getTail();\n"



[elpa] externals/phps-mode 89fac0b 094/405: Added another unit test for bracket less conditional

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 89fac0b843f93a0f919d36a1e9dbb245a9c69902
Author: Christian Johansson 
Commit: Christian Johansson 

Added another unit test for bracket less conditional
---
 phps-test-functions.el | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/phps-test-functions.el b/phps-test-functions.el
index 064ec1b..ed538cc 100644
--- a/phps-test-functions.el
+++ b/phps-test-functions.el
@@ -169,6 +169,20 @@
  (should (equal buffer-contents "

[elpa] externals/phps-mode 7279913 113/405: Improved TODOs

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 7279913039bf790249625d52bcc4ff29792b0a9d
Author: Christian Johansson 
Commit: Christian Johansson 

Improved TODOs
---
 phps-mode-test-functions.el | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el
index 7677cf3..51e8b57 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -245,10 +245,9 @@
 
   )
 
-;; TODO Support all control structures
-;; if, else, elseif, else if, while, do-while, for, foreach, break, switch, 
declare, return, require, include, require_once, include_once, goto
 
-;; TODO Support nested square brackets [[[ ]]]
+;; TODO Support inline control structures for: if, while, for, foreach, and 
switch
+;; TODO Support alternative syntax for control structures for: if, while, for, 
foreach, and switch
 
 
 (defun phps-mode-test-functions-get-point-data ()



[elpa] externals/phps-mode baab77a 121/405: Unit tests for inline control structures working

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit baab77ae322c60e9a14e8471374c3c07fb09081b
Author: Christian Johansson 
Commit: Christian Johansson 

Unit tests for inline control structures working
---
 phps-mode-functions.el  | 18 ++
 phps-mode-test-functions.el |  6 +++---
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index a443b10..d23d06d 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -226,7 +226,8 @@
 (found-line-tokens nil)
 (after-special-control-structure nil)
 (round-brace-level 0)
-(expecting-semi-colon nil)
+(start-expecting-semi-colon nil)
+(end-expecting-semi-colon nil)
 (first-token-on-line nil))
 (catch 'stop-iteration
   (dolist (item phps-mode-lexer-tokens)
@@ -277,10 +278,10 @@
   (setq start-alternative-control-structure-level (- 
start-alternative-control-structure-level 1)))
 
 ;; Reduce inline control structure level when we encounter a 
semi-colon after it's opening
-(when (and expecting-semi-colon
+(when (and start-expecting-semi-colon
(string= token ";"))
   (setq start-inline-control-structure-level (- 
start-inline-control-structure-level 1))
-  (setq expecting-semi-colon nil))
+  (setq start-expecting-semi-colon nil))
 
 )
 
@@ -321,10 +322,10 @@
   (setq end-alternative-control-structure-level (- 
end-alternative-control-structure-level 1)))
 
 ;; Reduce inline control structure level when we encounter a 
semi-colon after it's opening
-(when (and expecting-semi-colon
+(when (and end-expecting-semi-colon
(string= token ";"))
   (setq end-inline-control-structure-level (- 
end-inline-control-structure-level 1))
-  (setq expecting-semi-colon nil))
+  (setq end-expecting-semi-colon nil))
 
 )
 
@@ -367,12 +368,13 @@
 
 (when (or (<= token-end line-beginning)
   (= first-token-on-line end-token-number))
-  (setq start-inline-control-structure-level (+ 
start-inline-control-structure-level 1)))
+  (setq start-inline-control-structure-level (+ 
start-inline-control-structure-level 1))
+  (setq start-expecting-semi-colon t))
 
 (when (<= token-start line-end)
-  (setq end-inline-control-structure-level (+ 
end-inline-control-structure-level 1)))
+  (setq end-inline-control-structure-level (+ 
end-inline-control-structure-level 1))
+  (setq end-expecting-semi-colon t))
 
-(setq expecting-semi-colon t)
 (message "Was not colon")))
 
 (setq after-special-control-structure nil))
diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el
index 453462e..3902c5e 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -343,17 +343,17 @@
   (phps-mode-test-with-buffer
"

[elpa] externals/phps-mode f7f931a 092/405: Added another failing indentation test

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit f7f931a5049f4284d28185e36d5faa8113867d16
Author: Christian Johansson 
Commit: Christian Johansson 

Added another failing indentation test
---
 phps-mode.el   |  2 +-
 phps-test-functions.el | 14 +-
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/phps-mode.el b/phps-mode.el
index cc4a714..58eec94 100644
--- a/phps-mode.el
+++ b/phps-mode.el
@@ -60,7 +60,7 @@
 (defvar phps-mode/use-psr-2 t
   "Whether to use PSR-2 guidelines for white-space or not.")
 
-(defvar phps-mode/idle-interval 1
+(defvar phps-mode/idle-interval 0.2
   "Idle seconds before running incremental lexer.")
 
 (define-derived-mode phps-mode prog-mode "PHPs"
diff --git a/phps-test-functions.el b/phps-test-functions.el
index f9974a6..523641f 100644
--- a/phps-test-functions.el
+++ b/phps-test-functions.el
@@ -162,11 +162,18 @@
  (should (equal buffer-contents "var = 'abc123';\n} else if (mySeconCondition()) {\n$this->var = 
'def456';\n}\n"
 
   (phps-mode/with-test-buffer
-   " 'abc',\n),\n
$var2\n);\n"
+   " 'abc',\n),\n   
 $var2\n);\n"
(goto-char 50)
(phps-mode/indent-line)
(let ((buffer-contents (buffer-substring-no-properties (point-min) 
(point-max
- (should (equal buffer-contents " 'abc',\n),\n$var2\n);\n"
+ (should (equal buffer-contents " 'abc',\n),\n$var2\n);\n"
 
   (phps-mode/with-test-buffer
"getHead()\n->getTail();\n"
@@ -196,9 +203,6 @@
(let ((buffer-contents (buffer-substring-no-properties (point-min) 
(point-max
  (should (equal buffer-contents "var)):\n
$this->var = 'abc123';\nendif;"
 
-  
-
-
   )
 
 (defun phps-mode/test-functions--get-point-data ()



[elpa] externals/phps-mode 9c4a3ba 117/405: More work on alternative control structures

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 9c4a3ba7090536a3a03cc324a2a75ecadf681bf2
Author: Christian Johansson 
Commit: Christian Johansson 

More work on alternative control structures
---
 phps-mode-functions.el | 43 +++
 1 file changed, 31 insertions(+), 12 deletions(-)

diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index 8999b45..930f7cb 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -198,6 +198,7 @@
 
 ;; TODO This function needs to keep track of alternative syntax for the 
control structures: if, while, for, foreach, and switch
 ;; TODO This function needs to keep track of inline syntax for the control 
structures: if, while, for, foreach, and switch
+;; TODO Support switch case as well
 
 (defun phps-mode-functions-get-point-data ()
   "Return information about point in tokens."
@@ -236,18 +237,7 @@
 ;; (message "Stopping iteration at: %s %s" start position)
 (throw 'stop-iteration nil))
 
-  ;; Does the token support inline and alternative syntax?
-  (when (or
- (equal token 'T_IF)
- (equal token 'T_WHILE)
- (equal token 'T_FOR)
- (equal token 'T_FOREACH)
- (equal token 'T_SWITCH)
- (equal token 'T_ELSE)
- (equal token 'T_ELSEIF))
-(setq after-special-control-structure 
start-round-bracket-level))
-
-  ;; Did we find any token on this line?
+  ;; Did we find any token on current line?
   (when (and (not found-line-tokens)
  (>= token-start line-beginning)
  (<= token-end line-end))
@@ -255,6 +245,8 @@
 
   ;; When end of token is equal or less to beginning of current 
line
   (when (<= token-end line-beginning)
+
+;; Change start token number
 (when (null start-token-number)
   (setq start-token-number -1))
 (setq start-token-number (+ start-token-number 1))
@@ -314,6 +306,33 @@
   (equal token 'T_ENDSWITCH))
   (setq end-alternative-control-structure-level (- 
end-alternative-control-structure-level 1
 
+;; Are we after a special control structure
+;; and does round bracket level match initial round bracket 
level
+;; and is token not a round bracket
+(when (and after-special-control-structure
+   (= after-special-control-structure 
start-round-bracket-level)
+   (not (string= token ")"))
+   (not (string= token "(")))
+  (if (not (string= token "{"))
+  (progn
+(message "After special control structure %s in buffer 
%s" token (buffer-substring-no-properties (point-min) (point-max
+;; (message "Not after special control structure %s in 
buffer %s" token (buffer-substring-no-properties (point-min) (point-max)))
+)
+  (setq after-special-control-structure nil))
+
+  ;; Does the token support inline and alternative syntax?
+  (when (or
+ (equal token 'T_IF)
+ (equal token 'T_WHILE)
+ (equal token 'T_FOR)
+ (equal token 'T_FOREACH)
+ (equal token 'T_SWITCH)
+ (equal token 'T_ELSE)
+ (equal token 'T_ELSEIF))
+;; (message "Found special control structure %s %s" token 
start-round-bracket-level)
+(setq after-special-control-structure 
start-round-bracket-level))
+
+
   )))
 (when (not found-line-tokens)
   (setq start-token-number nil)



[elpa] externals/phps-mode ba8165a 063/405: Fixed bug with brace count not including braces inside double quoted strings

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit ba8165afd99bee6e839d17dfa69676ded1e98466
Author: Christian Johansson 
Commit: Christian Johansson 

Fixed bug with brace count not including braces inside double quoted strings
---
 phps-functions.el  | 4 
 phps-test-functions.el | 8 
 2 files changed, 12 insertions(+)

diff --git a/phps-functions.el b/phps-functions.el
index a0f4aa1..fe7ded9 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -171,6 +171,8 @@
   ('T_OPEN_TAG (setq start-in-scripting t))
   ('T_OPEN_TAG_WITH_ECHO (setq start-in-scripting t))
   ('T_CLOSE_TAG (setq start-in-scripting nil))
+  ('T_CURLY_OPEN (setq start-brace-level (+ start-brace-level 
1)))
+  ('T_DOLLAR_OPEN_CURLY_BRACES (setq start-brace-level (+ 
start-brace-level 1)))
   ("}" (setq start-brace-level (- start-brace-level 1)))
   ("{" (setq start-brace-level (+ start-brace-level 1)))
   ("(" (setq start-parenthesis-level (+ 
start-parenthesis-level 1)))
@@ -191,6 +193,8 @@
   ('T_OPEN_TAG (setq end-in-scripting t))
   ('T_OPEN_TAG_WITH_ECHO (setq end-in-scripting t))
   ('T_CLOSE_TAG (setq end-in-scripting nil))
+  ('T_CURLY_OPEN (setq end-brace-level (+ end-brace-level 1)))
+  ('T_DOLLAR_OPEN_CURLY_BRACES (setq end-brace-level (+ 
end-brace-level 1)))
   ("}" (setq end-brace-level (- end-brace-level 1)))
   ("{" (setq end-brace-level (+ end-brace-level 1)))
   ("(" (setq end-parenthesis-level (+ end-parenthesis-level 
1)))
diff --git a/phps-test-functions.el b/phps-test-functions.el
index 1ead7e7..b4ef345 100644
--- a/phps-test-functions.el
+++ b/phps-test-functions.el
@@ -123,6 +123,14 @@
(let ((buffer-contents (buffer-substring-no-properties (point-min) 
(point-max
  (should (equal buffer-contents  "id}\",'__return_empty_array'\n);"
+   (goto-char 25)
+   (phps-mode/indent-line)
+   ;; (message "Tokens %s point %s" phps-mode/lexer-tokens (point))
+   (let ((buffer-contents (buffer-substring-no-properties (point-min) 
(point-max
+ (should (equal buffer-contents "id}\",'__return_empty_array'\n);"
+
   )
 
 (defun phps-mode/test-functions--get-point-data ()



[elpa] externals/phps-mode 0ca9fe8 058/405: Detection of point inside doc comment block improved

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 0ca9fe8ed30c99a573976def04fc6458b38330ca
Author: Christian Johansson 
Commit: Christian Johansson 

Detection of point inside doc comment block improved
---
 phps-functions.el  | 39 +--
 phps-test-functions.el | 12 ++--
 2 files changed, 35 insertions(+), 16 deletions(-)

diff --git a/phps-functions.el b/phps-functions.el
index 03b1119..497a0fd 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -55,11 +55,15 @@
   (start-token-number (nth 4 start))
   (end-bracket-level (nth 1 end))
   (end-parenthesis-level (nth 2 end))
-  (end-token-number (nth 4 end)))
+  (end-token-number (nth 4 end))
+  (in-doc-comment (nth 5 start)))
   (let* ((indent-start (+ start-bracket-level start-parenthesis-level))
  (indent-end (+ end-bracket-level end-parenthesis-level))
- (indent-level indent-start))
+ (indent-level indent-start)
+ (indent-adjust 0))
 ;; (message "indent-start %s, indent-end %s" indent-start 
indent-end)
+
+;; When bracket count at start is larger than bracket count at end
 (when (and
(boundp 'phps-mode/lexer-tokens)
(> indent-start indent-end))
@@ -87,17 +91,22 @@
 (when valid-tokens
   ;; (message "Tokens was valid, decreasing indent %s - %s" 
(line-beginning-position) (line-end-position))
   (setq indent-level (- indent-level (- indent-start 
indent-end))
-;; (message "inside scripting, start: %s, end: %s, indenting to 
column %s " start end indent-level)
-(indent-line-to (* indent-level tab-width))
-(phps-mode/run-incremental-lex)))
 
-;; TODO Implement this
+(when in-doc-comment
+  (setq indent-adjust 1))
+
+(let ((indent-sum (+ (* indent-level tab-width) indent-adjust)))
+  ;; (message "Indenting to %s" indent-sum)
+  ;; (message "inside scripting, start: %s, end: %s, indenting to 
column %s " start end indent-level)
+  (indent-line-to indent-sum)
+  (phps-mode/run-incremental-lex
+
+;; TODO Implement this?
 (defun phps-mode/indent-region ()
   "Indent region."
   )
 
-;; TODO This function should track between what min and max region a specific 
buffer has been modified and then re-run lexer for that region when editor is 
idle, maybe use (buffer-name))
-;; maybe use 'auto-save-hook for this
+;; TODO Fix flycheck error here
 (defun phps-mode/after-change-functions (start stop length)
   "Track buffer change from START to STOP with length LENGTH."
   (when (string= major-mode "phps-mode")
@@ -117,7 +126,7 @@
   (when (boundp 'phps-mode/lexer-tokens)
 (save-excursion
   (beginning-of-line)
-  (let ((position (point))
+  (let ((line-beginning (point))
 (line-end (line-end-position))
 (start-in-scripting nil)
 (start-brace-level 0)
@@ -143,12 +152,12 @@
 (throw 'stop-iteration nil))
 
   (when (and (not found-line-tokens)
- (>= token-start position)
+ (>= token-start line-beginning)
  (<= token-end line-end))
 (setq found-line-tokens t))
 
   ;; When end of token is equal or less to current point
-  (when (<= token-end position)
+  (when (<= token-end line-beginning)
 (when (null start-token-number)
   (setq start-token-number -1))
 (setq start-token-number (+ start-token-number 1))
@@ -156,24 +165,26 @@
   ('T_OPEN_TAG (setq start-in-scripting t))
   ('T_OPEN_TAG_WITH_ECHO (setq start-in-scripting t))
   ('T_CLOSE_TAG (setq start-in-scripting nil))
-  ('T_DOC_COMMENT (setq line-in-doc-comment nil))
   ("}" (setq start-brace-level (- start-brace-level 1)))
   ("{" (setq start-brace-level (+ start-brace-level 1)))
   ("(" (setq start-parenthesis-level (+ 
start-parenthesis-level 1)))
   (")" (setq start-parenthesis-level (- 
start-parenthesis-level 1)))
   (_)))
 
+  (when (and (> token-end line-end)
+ (< token-start line-beginning)
+ (eq token 'T_DOC_COMMENT))
+(setq line-in-doc-comment t))
+
   ;; When start of token is equal or less to end of curent line
   (when (<= token-start line-end)
 (when (null end-token-number)
   (setq end-token-number -1))
 (setq end-token-number (+ end-token-number 1))
-(setq line-in-doc-comment nil)
 (pcase token
   

[elpa] externals/phps-mode 0a32b17 161/405: Improved calculation for indentation for multi-line assignments

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 0a32b17da840d4e05729252a2fffdb9a6d92792c
Author: Christian Johansson 
Commit: Christian Johansson 

Improved calculation for indentation for multi-line assignments
---
 phps-mode-functions.el  |  5 -
 phps-mode-test-functions.el | 16 ++--
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index d488712..eba2a3f 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -307,7 +307,10 @@
   (when first-token-on-line
 (if (or (equal token 'T_VARIABLE)
 (equal token 'T_CONSTANT_ENCAPSED_STRING)
-(equal token 'T_OBJECT_OPERATOR))
+(equal token 'T_ENCAPSED_AND_WHITESPACE)
+(equal token 'T_OBJECT_OPERATOR)
+(equal token 'T_LNUMBER)
+(equal token 'T_DNUMBER))
 (progn
   ;; (message "In assignment on new-line at %s" token)
   (setq in-assignment-on-new-line t))
diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el
index 46d0ec5..476869a 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -83,9 +83,21 @@
"Switch, case, default"
(should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (2 0)) (5 (2 0)) (6 (1 
0)) (7 (2 0)) (8 (1 0)) (9 (2 0)) (10 (0 0))) 
(phps-mode-test-functions--hash-to-list 
(phps-mode-functions-get-lines-indent)
 
-  ;; TODO NOWDOC, HEREDOC
+  (phps-mode-test-with-buffer
+   "getTail()\n->getBottom();"
+   "Multi-line assignments"
+   ;; (message "Tokens: %s" phps-mode-lexer-tokens)
+   (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (1 0)) (5 (1 0)) (6 (1 
0)) (7 (1 0)) (8 (1 0))) (phps-mode-test-functions--hash-to-list 
(phps-mode-functions-get-lines-indent)
+
+
+  ;; TODO NOWDOC
+
+  ;; TODO HEREDOC
+
+  ;; TODO Multi-line single-quoted string
+
+  ;; TODO Multi-line double-quoted strings
 
-  ;; TODO Multi-line assignments
 
   )
 



[elpa] externals/phps-mode 90d059c 064/405: Fixed bug in incremental lexer logic

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 90d059cca8120b659e61835f67302ce4e63cadcf
Author: Christian Johansson 
Commit: Christian Johansson 

Fixed bug in incremental lexer logic
---
 phps-lexer.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/phps-lexer.el b/phps-lexer.el
index 88d65b3..dfca7c2 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -1308,9 +1308,9 @@ ANY_CHAR'
 (setq phps-mode/state_stack state-stack)
 (setq phps-mode/lexer-states new-states)
 ;; (message "Rewinding lex to state: %s and stack: %s and states: 
%s and start: %s" state state-stack new-states previous-token-start)
-(semantic-lex previous-token-start (point-max)))
+(setq phps-mode/lexer-tokens (semantic-lex previous-token-start 
(point-max
 (display-warning "phps-mode" (format "Found no state to rewind to for 
%s in stack %s" change-start states))
-(semantic-lex-buffer)))
+(phps-mode/lex--RUN)))
 (setq phps-mode/buffer-changes--start nil)))
 
 (define-lex phps-mode/tags-lexer



[elpa] externals/phps-mode a8561ab 096/405: Updated unit test for get-point-data with support for square brackets

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit a8561ab202c2a2611b93bf954bba02e82cc036b9
Author: Christian Johansson 
Commit: Christian Johansson 

Updated unit test for get-point-data with support for square brackets
---
 phps-functions.el  |  2 ++
 phps-test-functions.el | 37 ++---
 2 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/phps-functions.el b/phps-functions.el
index 227d0f4..2c50305 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -195,6 +195,8 @@
 ;; (message "phps-mode/after-change-functions %s %s %s" start stop length)
 ))
 
+;; TODO This function needs to keep track of alternative syntax for control 
structures
+
 (defun phps-mode/get-point-data ()
   "Return information about point in tokens."
   ;; (message "Point: %s in %s" (point) phps-mode/lexer-tokens)
diff --git a/phps-test-functions.el b/phps-test-functions.el
index fefb864..137db58 100644
--- a/phps-test-functions.el
+++ b/phps-test-functions.el
@@ -232,6 +232,8 @@
 ;; TODO Support all control structures
 ;; if, else, elseif, else if, while, do-while, for, foreach, break, switch, 
declare, return, require, include, require_once, include_once, goto
 
+;; TODO Support nested square brackets [[[ ]]]
+
 
 (defun phps-mode/test-functions--get-point-data ()
   "Return information about point in tokens."
@@ -239,78 +241,83 @@
   (phps-mode/with-test-buffer
"Bla 
bla"
(goto-char 15)
-   (should (equal (list (list nil 0 0 0 nil nil) (list nil 0 0 0 5 nil)) 
(phps-mode/get-point-data
+   (should (equal (list (list nil 0 0 0 0 nil nil) (list nil 0 0 0 0 5 nil)) 
(phps-mode/get-point-data
 
   (phps-mode/with-test-buffer
"\nBla 
bla"
(goto-char 50)
-   (should (equal (list (list nil 0 0 0 nil nil) (list nil 0 0 0 nil nil)) 
(phps-mode/get-point-data
+   (should (equal (list (list nil 0 0 0 0 nil nil) (list nil 0 0 0 0 nil nil)) 
(phps-mode/get-point-data
 
   (phps-mode/with-test-buffer
"Bla bla"
(goto-char 15)
-   (should (equal (list (list nil 0 0 0 nil nil) (list nil 0 0 0 nil nil)) 
(phps-mode/get-point-data
+   (should (equal (list (list nil 0 0 0 0 nil nil) (list nil 0 0 0 0 nil nil)) 
(phps-mode/get-point-data
 
   (phps-mode/with-test-buffer
"Bla 
bla"
(goto-char 30)
-   (should (equal (list (list nil 0 0 0 nil nil) (list nil 0 0 0 5 nil)) 
(phps-mode/get-point-data
+   (should (equal (list (list nil 0 0 0 0 nil nil) (list nil 0 0 0 0 5 nil)) 
(phps-mode/get-point-data
 
   (phps-mode/with-test-buffer
"Bla 
bla"
(goto-char 50)
-   (should (equal (list (list nil 0 0 0 nil nil) (list nil 0 0 0 5 nil)) 
(phps-mode/get-point-data
+   (should (equal (list (list nil 0 0 0 0 nil nil) (list nil 0 0 0 0 5 nil)) 
(phps-mode/get-point-data
 
   (phps-mode/with-test-buffer
"Bla bla"
;; (message "Tokens: %s" phps-mode/lexer-tokens)
(goto-char 48)
-   (should (equal (list (list t 1 0 0 5 nil) (list nil 0 0 0 17 nil)) 
(phps-mode/get-point-data
+   (should (equal (list (list t 1 0 0 0 5 nil) (list nil 0 0 0 0 17 nil)) 
(phps-mode/get-point-data
 
   (phps-mode/with-test-buffer
"Bla bla"
(goto-char 72)
-   (should (equal (list (list t 2 0 0 10 nil) (list t 2 0 0 13 nil)) 
(phps-mode/get-point-data
+   (should (equal (list (list t 2 0 0 0 10 nil) (list t 2 0 0 0 13 nil)) 
(phps-mode/get-point-data
 
   (phps-mode/with-test-buffer
"Bla bla"
(goto-char 84)
-   (should (equal (list (list t 2 0 0 13 nil) (list t 1 0 0 14 nil)) 
(phps-mode/get-point-data
+   (should (equal (list (list t 2 0 0 0 13 nil) (list t 1 0 0 0 14 nil)) 
(phps-mode/get-point-data
 
   (phps-mode/with-test-buffer
"Bla bla"
(goto-char 100)
-   (should (equal (list (list nil 0 0 0 nil nil) (list nil 0 0 0 17 nil)) 
(phps-mode/get-point-data
+   (should (equal (list (list nil 0 0 0 0 nil nil) (list nil 0 0 0 0 17 nil)) 
(phps-mode/get-point-data
 
   (phps-mode/with-test-buffer
"var\n) && !empty($this->var)\n) {\n$this->var = 
'abc123';\n}\n"
(goto-char 54)
-   (should (equal (list (list t 0 1 0 16 nil) (list t 1 0 0 18 nil)) 
(phps-mode/get-point-data
+   (should (equal (list (list t 0 1 0 0 16 nil) (list t 1 0 0 0 18 nil)) 
(phps-mode/get-point-data
+
+  (phps-mode/with-test-buffer
+   " [\n'hello',\n],\n];\n"
+   (goto-char 46)
+   (should (equal (list (list t 0 0 2 0 6 nil) (list t 0 0 2 0 8 nil)) 
(phps-mode/get-point-data
 
   )
 



[elpa] externals/phps-mode 287d934 077/405: Updated comments are made un-tested function for moving token positions

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit 287d9340f9f3c15401f0773925e07259c9d8aec0
Author: Christian Johansson 
Commit: Christian Johansson 

Updated comments are made un-tested function for moving token positions
---
 phps-functions.el | 34 --
 phps-lexer.el | 20 
 2 files changed, 40 insertions(+), 14 deletions(-)

diff --git a/phps-functions.el b/phps-functions.el
index 0e84dc5..107b927 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -114,26 +114,32 @@
 
   (setq indent-level (- indent-level (- indent-start 
indent-end))
 
+;; If this line is part of a doc-comment increase indent with one 
unit
 (when in-doc-comment
   (setq indent-adjust 1))
 
-(let ((indent-sum (+ (* indent-level tab-width) indent-adjust)))
-  (when (not (equal indent-sum (current-indentation)))
-;; (message "Indenting to %s current column %s" indent-sum 
(current-indentation))
-;; (message "inside scripting, start: %s, end: %s, indenting 
to column %s " start end indent-level)
+(let ((indent-sum (+ (* indent-level tab-width) indent-adjust))
+  current-indentation (current-indentation))
 
-;; TODO When indent is changed the trailing tokens just need 
to adjust their token positions, this will improve speed of indent-region a lot
-(indent-line-to indent-sum)
+  ;; Only continue if current indentation is wrong
+  (when (not (equal indent-sum current-indentation))
+(let ((indent-diff (- current-indentation indent-sum)))
+  ;; (message "Indenting to %s current column %s" indent-sum 
(current-indentation))
+  ;; (message "inside scripting, start: %s, end: %s, indenting 
to column %s " start end indent-level)
 
-(let ((line-start (line-beginning-position)))
+  (indent-line-to indent-sum)
 
-  ;; Set point of change if it's not set or if it's larger 
than current point
-  (when (or (not phps-mode/buffer-changes--start)
-(< line-start phps-mode/buffer-changes--start))
-;; (message "Setting changes start from %s to %s" 
phps-mode/buffer-changes--start start)
-(setq phps-mode/buffer-changes--start line-start))
-  
-  (phps-mode/run-incremental-lex))
+  ;; TODO When indent is changed the trailing tokens just need 
to adjust their token positions, this will improve speed of indent-region a lot
+
+  (let ((line-start (line-beginning-position)))
+
+;; Set point of change if it's not set or if it's larger 
than current point
+(when (or (not phps-mode/buffer-changes--start)
+  (< line-start phps-mode/buffer-changes--start))
+  ;; (message "Setting changes start from %s to %s" 
phps-mode/buffer-changes--start start)
+  (setq phps-mode/buffer-changes--start line-start))
+
+(phps-mode/run-incremental-lex)))
 
 ;; TODO Implement this?
 (defun phps-mode/indent-region ()
diff --git a/phps-lexer.el b/phps-lexer.el
index 70359c0..8e41347 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -1278,6 +1278,26 @@ ANY_CHAR'
   (interactive)
   (setq phps-mode/lexer-tokens (semantic-lex-buffer)))
 
+(defun phps-mode/move-lexer-tokens (old-tokens start diff)
+  "Move lexer OLD-TOKENS positions after START with DIFF points."
+  (let ((new-tokens '()))
+(when old-tokens
+
+  ;; Iterate over all tokens, add those that are to be left unchanged and
+  ;; add modified ones that are to be changed.
+  (catch 'stop-iteration
+(dolist (token (nreverse old-tokens))
+  (let ((token-symbol (car token))
+(token-start (car (cdr token)))
+(token-end (cdr (cdr token
+(if (> token-start start)
+(let ((new-token-start (+ token-start diff))
+  (new-token-end (+ token-end diff)))
+  (push `(,token-symbol ,new-token-start ,new-token-end) 
new-tokens)
+  (push token new-tokens))
+
+  new-tokens)))
+
 (defun phps-mode/run-incremental-lex ()
   "Run incremental lexer based on `phps-mode/buffer-changes--start'."
   (when (and (boundp 'phps-mode/buffer-changes--start)



[elpa] externals/phps-mode cc947a9 140/405: Added more tests for new indentation function

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit cc947a91828355a368ecb3828b60e7f69e0e9c37
Author: Christian Johansson 
Commit: Christian Johansson 

Added more tests for new indentation function
---
 phps-mode-functions.el  | 27 ---
 phps-mode-test-functions.el | 54 +
 2 files changed, 78 insertions(+), 3 deletions(-)

diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index f5a6985..55501cd 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -114,7 +114,8 @@
 (when (string= token "}")
   (setq curly-bracket-level (1- curly-bracket-level)))
 
-;; TODO Keep track of inline control structures
+;; TODO Keep track of case and default special tokens
+
 ;; Keep track of alternative control structure level
 (when (or (equal token 'T_ENDIF)
   (equal token 'T_ENDWHILE)
@@ -123,11 +124,31 @@
   (equal token 'T_ENDSWITCH))
   (setq alternative-control-structure-level (1- 
alternative-control-structure-level)))
 
+(when (and after-special-control-structure
+   (= after-special-control-structure 
round-bracket-level)
+   (not (string= token ")"))
+   (not (string= token "(")))
+
+  ;; Is token not a curly bracket - because that is a ordinary 
control structure syntax
+  (unless (string= token "{")
+
+;; Is it the start of an alternative control structure?
+(if (string= token ":")
+(setq alternative-control-structure-level (1+ 
alternative-control-structure-level))
+  (setq inline-control-structure-level (1+ 
inline-control-structure-level))
+  (setq in-inline-control-structure t)))
+
+  (setq after-special-control-structure nil))
+
+;; Did we reach a semicolon inside a inline block? Close the 
inline block
+(when (and in-inline-control-structure
+   (string= token ";"))
+  (setq inline-control-structure-level (1- 
inline-control-structure-level))
+  (setq in-inline-control-structure nil))
+
 ;; Did we encounter a token that supports alternative and 
inline control structures?
 (when (or (equal token 'T_IF)
   (equal token 'T_WHILE)
-  (equal token 'T_CASE)
- (equal token 'T_DEFAULT)
   (equal token 'T_FOR)
   (equal token 'T_FOREACH)
   (equal token 'T_SWITCH)
diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el
index 7a91214..b8a6f8c 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -76,6 +76,60 @@
(goto-char 17)
(should (equal '(0 1) (phps-mode-functions-get-current-line-indent
 
+  ;; Alternative control structures
+
+  (phps-mode-test-with-buffer
+   "

[elpa] externals/phps-mode dd80d27 055/405: Started work on detecting doc comment blocks

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit dd80d2797a53c35a53f0412bf10d2483b514571b
Author: Christian Johansson 
Commit: Christian Johansson 

Started work on detecting doc comment blocks
---
 phps-lexer.el  | 15 +++
 phps-test-lexer.el | 26 +++---
 2 files changed, 26 insertions(+), 15 deletions(-)

diff --git a/phps-lexer.el b/phps-lexer.el
index 387f306..bb4c98f 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -1271,11 +1271,13 @@ ANY_CHAR'
   (start-parenthesis-level 0)
   (start-inline-function-level 0)
   (start-token-number nil)
+  (start-in-doc-comment nil)
   (end-in-scripting nil)
   (end-brace-level 0)
   (end-parenthesis-level 0)
   (end-inline-function-level 0)
   (end-token-number nil)
+  (end-in-doc-comment nil)
   (found-line-tokens nil))
   (catch 'stop-iteration
 (dolist (item phps-mode/lexer-tokens)
@@ -1293,15 +1295,17 @@ ANY_CHAR'
(<= end line-end))
   (setq found-line-tokens t))
 
-;; When start of token is equal or less to current point
+;; When end of token is equal or less to current point
 (when (<= end position)
   (when (null start-token-number)
 (setq start-token-number -1))
   (setq start-token-number (+ start-token-number 1))
+  (setq start-in-doc-comment nil)
   (pcase token
 ('T_OPEN_TAG (setq start-in-scripting t))
 ('T_OPEN_TAG_WITH_ECHO (setq start-in-scripting t))
 ('T_CLOSE_TAG (setq start-in-scripting nil))
+('T_DOC_COMMENT (setq start-in-doc-comment t))
 ("}" (setq start-brace-level (- start-brace-level 1)))
 ("{" (setq start-brace-level (+ start-brace-level 1)))
 ("(" (setq start-parenthesis-level (+ start-parenthesis-level 
1)))
@@ -1313,10 +1317,12 @@ ANY_CHAR'
   (when (null end-token-number)
 (setq end-token-number -1))
   (setq end-token-number (+ end-token-number 1))
+  (setq end-in-doc-comment nil)
   (pcase token
 ('T_OPEN_TAG (setq end-in-scripting t))
 ('T_OPEN_TAG_WITH_ECHO (setq end-in-scripting t))
 ('T_CLOSE_TAG (setq end-in-scripting nil))
+('T_DOC_COMMENT (setq end-in-doc-comment t))
 ("}" (setq end-brace-level (- end-brace-level 1)))
 ("{" (setq end-brace-level (+ end-brace-level 1)))
 ("(" (setq end-parenthesis-level (+ end-parenthesis-level 1)))
@@ -1324,9 +1330,10 @@ ANY_CHAR'
 (_)))
 
 )))
-  (let ((data (list (list start-in-scripting start-brace-level 
start-parenthesis-level start-inline-function-level nil) (list end-in-scripting 
end-brace-level end-parenthesis-level end-inline-function-level nil
-(when found-line-tokens
-  (setq data (list (list start-in-scripting start-brace-level 
start-parenthesis-level start-inline-function-level start-token-number) (list 
end-in-scripting end-brace-level end-parenthesis-level 
end-inline-function-level end-token-number
+  (when (not found-line-tokens)
+(setq start-token-number nil)
+(setq end-token-number nil))
+  (let ((data (list (list start-in-scripting start-brace-level 
start-parenthesis-level start-inline-function-level start-token-number 
start-in-doc-comment) (list end-in-scripting end-brace-level 
end-parenthesis-level end-inline-function-level end-token-number 
end-in-doc-comment
 ;; (message "data: %s" data)
 data
 
diff --git a/phps-test-lexer.el b/phps-test-lexer.el
index 8eb8ed3..1bafd80 100644
--- a/phps-test-lexer.el
+++ b/phps-test-lexer.el
@@ -274,54 +274,58 @@
   (phps-mode/with-test-buffer
"Bla 
bla"
(goto-char 15)
-   (should (equal (list (list nil 0 0 0 nil) (list nil 0 0 0 5)) 
(phps-mode/lexer-get-point-data
+   (should (equal (list (list nil 0 0 0 nil nil) (list nil 0 0 0 5 nil)) 
(phps-mode/lexer-get-point-data
 
   (phps-mode/with-test-buffer
"\nBla 
bla"
(goto-char 50)
-   (should (equal (list (list nil 0 0 0 nil) (list nil 0 0 0 nil)) 
(phps-mode/lexer-get-point-data
+   (should (equal (list (list nil 0 0 0 nil nil) (list nil 0 0 0 nil nil)) 
(phps-mode/lexer-get-point-data
 
   (phps-mode/with-test-buffer
"Bla bla"
(goto-char 15)
-   (should (equal (list (list nil 0 0 0 nil) (list nil 0 0 0 nil)) 
(phps-mode/lexer-get-point-data
+   (should (equal (list (list nil 0 0 0 nil nil) (list nil 0 0 0 nil nil)) 
(phps-mode/lexer-get-point-data
 
   (phps-mode/with-test-buffer
"Bla 
bla"
(goto-char 30)
-   (should (equal (list (list nil 0 0 0 nil) (list nil 0 0 0 5)) 
(phps-mode/lexer-get-point-data
+   (should (equal (list (list nil 0 0 0 nil nil) (list nil 0 0 0

[elpa] externals/phps-mode e206605 115/405: Adding failing unit tests for inline and alternative syntax

2019-07-13 Thread Stefan Monnier
branch: externals/phps-mode
commit e206605fb3cf354c6c382a3fb5411d183d4405d0
Author: Christian Johansson 
Commit: Christian Johansson 

Adding failing unit tests for inline and alternative syntax
---
 phps-mode-test-functions.el | 44 
 1 file changed, 44 insertions(+)

diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el
index 19f95a8..a0cef01 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -333,6 +333,50 @@
(goto-char 46)
(should (equal (list (list t 0 0 2 0 0 6 nil) (list t 0 0 2 0 0 8 nil)) 
(phps-mode-functions-get-point-data
 
+  ;; INLINE SYNTAX
+
+  (phps-mode-test-with-buffer
+   "https://www.php-fig.org/psr/psr-2/



  1   2   3   4   5   >