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

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

[elpa] externals/phps-mode 2cc670e: Improved documentation, minor code o


From: Christian Johansson
Subject: [elpa] externals/phps-mode 2cc670e: Improved documentation, minor code optimizations
Date: Wed, 17 Jul 2019 01:41:26 -0400 (EDT)

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

    Improved documentation, minor code optimizations
---
 README.md                      | 45 ++++++++++++++++++++++++++++++++++++------
 docs/heuristics.md             |  6 ++++++
 docs/imenu.md                  |  2 ++
 docs/todo.md                   |  5 +++--
 phps-mode-automation.el        |  4 ++--
 phps-mode-functions.el         | 12 +++++------
 phps-mode-lexer.el             |  8 +++++---
 phps-mode.el                   | 14 ++++++-------
 sample-php-files/functions.php |  2 ++
 9 files changed, 72 insertions(+), 26 deletions(-)

diff --git a/README.md b/README.md
index a5cce8b..ee007c9 100644
--- a/README.md
+++ b/README.md
@@ -21,6 +21,7 @@ This mode does not require PHP installed on your computer 
because it has a built
 * Imenu support
 * Minimal mode map* Tested using unit tests and integration tests
 * Travis support
+* Included in ELPA
 
 
 ## Develop
@@ -91,18 +92,50 @@ make compile
 make clean
 ```
 
-## Installation example
+## Installation
 
-Download to `~/.emacs.d/phps-mode/` and then add this to your init file:
+### Install manually
 
-### Using use-package with flycheck support
+If you have downloaded manually i.e. to `~/.emacs.d/phps-mode/` you need to 
add this first to your init file:
 
 ``` emacs-lisp
 (add-to-list 'load-path (expand-file-name "~/.emacs.d/phps-mode/"))
+```
+
+### Install via package manager
+
+You can install via ELPA (`M-x package-install` `phps-mode`), package will be 
loaded automatically then.
+
+### Install, load and configure via use-package
+
+``` emacs-lisp
+(use-package phps-mode
+    :after flycheck
+    :ensure t
+    :mode ("\\.php\\'" "\\.phtml\\'"))
+```
+
+### Load and configure using use-package
+
+``` emacs-lisp
 (use-package phps-mode
     :after flycheck
-    :mode ("\\.php\\'" "\\.phtml\\'")
-    :config
-    (setq phps-mode-flycheck-support t))
+    :mode ("\\.php\\'" "\\.phtml\\'"))
 ```
 
+### Load and configure using regular emacs-lisp
+``` emacs-lisp
+(require 'phps-mode)
+(add-to-list 'auto-mode-alist '("\\.\\(php\\|phtml\\)\\'" . phps-mode))
+```
+
+## Contribute
+
+This project is licensed to Free Software Foundation so sign the needed 
papers. Then create a branch based on a updated `develop`. Make pull request.
+
+## Docs
+
+* [TODO](docs/todo.md)
+* [Heuristics](docs/heuristics.md)
+* [Imenu algorithm](docs/imenu.md)
+* [Indentation algorithm](docs/indentation.md)
diff --git a/docs/heuristics.md b/docs/heuristics.md
index 90098f5..744cfbe 100644
--- a/docs/heuristics.md
+++ b/docs/heuristics.md
@@ -1,2 +1,8 @@
+## Heuristics
+
+These should solve the problem of freezing editor when making white-space 
changes to code.
+
 * When pressing return when line after cursor is only white-space
 * When pressing backspace when line before cursor is only white-space
+
+[Back to start](../../../)
diff --git a/docs/imenu.md b/docs/imenu.md
index 9bba396..1603078 100644
--- a/docs/imenu.md
+++ b/docs/imenu.md
@@ -20,3 +20,5 @@ for token in tokens:
 
 endfor;
 ```
+
+[Back to start](../../../)
diff --git a/docs/todo.md b/docs/todo.md
index 60673c0..2996673 100644
--- a/docs/todo.md
+++ b/docs/todo.md
@@ -1,4 +1,4 @@
-## TODOs
+## TODO
 
 *With current progress estimates:*
 
@@ -11,4 +11,5 @@
 * Flymake support (0%)
 * PSR-2 auto-formatting tool based on lexer tokens (0%)
 * Add to MELPA (0%)
-* Add to ELPA (0%)
+
+[Back to start](../../../)
diff --git a/phps-mode-automation.el b/phps-mode-automation.el
index 2a31e55..980f460 100644
--- a/phps-mode-automation.el
+++ b/phps-mode-automation.el
@@ -27,7 +27,7 @@
 
 ;;; Code:
 
-(add-to-list 'load-path (expand-file-name 
"~/.emacs.d/emacs-wisent-grammar-converter/"))
+(add-to-list 'load-path (expand-file-name (concat user-emacs-directory 
"emacs-wisent-grammar-converter/")))
 (autoload 'emacs-wisent-grammar-converter/generate-grammar-from-filename 
"emacs-wisent-grammar-converter")
 
 (let ((php-yacc-url 
"https://raw.githubusercontent.com/php/php-src/master/Zend/zend_language_parser.y";)
@@ -38,7 +38,7 @@
   (unless (file-exists-p php-yacc-file)
     (message "Downloading PHP Yacc grammar..")
     (url-copy-file php-yacc-url php-yacc-file t t)
-    (message "Downlad completed"))
+    (message "Download completed"))
 
   ;; Generate grammar
   (message "Generating Wisent grammar..")
diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index 79df173..5e6e920 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -987,13 +987,13 @@
           (progn
             (goto-char end)
             (backward-char 3)
-            (when (looking-at-p " \\*\/")
+            (when (looking-at-p " \\*/")
               (delete-char 3))
 
             (goto-char beg)
-            (when (looking-at-p "\/\/ ")
+            (when (looking-at-p "// ")
               (delete-char 3))
-            (when (looking-at-p "\/\\* ")
+            (when (looking-at-p "/\\* ")
               (delete-char 3)))
 
         ;; Do this for every line in region
@@ -1006,15 +1006,15 @@
 
           ;; Does this line contain something other than white-space?
           (unless (>= (+ (point) 3) (line-end-position))
-            (when (looking-at-p "\/\/ ")
+            (when (looking-at-p "// ")
               (delete-char 3))
-            (when (looking-at-p "\/\\* ")
+            (when (looking-at-p "/\\* ")
               (delete-char 3))
 
             (move-end-of-line nil)
 
             (backward-char 3)
-            (when (looking-at-p " \\*\/")
+            (when (looking-at-p " \\*/")
               (delete-char 3)))
 
           (when (< current-line-number end-line-number)
diff --git a/phps-mode-lexer.el b/phps-mode-lexer.el
index 46161c5..a8e8079 100644
--- a/phps-mode-lexer.el
+++ b/phps-mode-lexer.el
@@ -148,8 +148,9 @@
   "Exponent double number.")
 
 (defvar phps-mode-lexer-LABEL
-  "[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*"
+  "[a-zA-Z_\u0080-\u00FF][a-zA-Z0-9_\x80-\xff]*"
   "Labels are used for names.")
+;; NOTE original \x80-\xff replaced with \u0080-\u00FF, since original means 
raw bytes in emacs-lisp
 
 (defvar phps-mode-lexer-WHITESPACE "[ \n\r\t]+"
   "White-space.")
@@ -157,8 +158,9 @@
 (defvar phps-mode-lexer-TABS_AND_SPACES "[ \t]*"
   "Tabs and white-spaces.")
 
-(defvar phps-mode-lexer-TOKENS "[][;\\:,\.()|^&+-/*=%!~\\$<>?@]"
+(defvar phps-mode-lexer-TOKENS "[][;:,.()|^&+/*=%!~$<>?@-]"
   "Tokens.")
+;; NOTE The hyphen moved last since it has special meaning and to avoid it 
being interpreted as a range.
 
 (defvar phps-mode-lexer-ANY_CHAR ".\\|\n"
   "Any character.  The Zend equivalent is [^] but is not possible in Emacs 
Lisp.")
@@ -1364,7 +1366,7 @@
                    ;; (message "Double quoted string %s" double-quoted-string)
                    ;; Do we find variable inside quote?
                    (goto-char string-start)
-                   (if (looking-at "[^\\\\]\"")
+                   (if (looking-at "[^\\]\"")
                        (progn
                          (let ((_double-quoted-string 
(buffer-substring-no-properties start (+ string-start 2))))
                            ;; (message "Double quoted string: %s" 
_double-quoted-string)
diff --git a/phps-mode.el b/phps-mode.el
index fcfc9be..8290f0a 100644
--- a/phps-mode.el
+++ b/phps-mode.el
@@ -5,8 +5,8 @@
 ;; Author: Christian Johansson <github.com/cjohansson>
 ;; Maintainer: Christian Johansson <github.com/cjohansson>
 ;; Created: 3 Mar 2018
-;; Modified: 4 May 2019
-;; Version: 0.2.1
+;; Modified: 17 Jul 2019
+;; Version: 0.2.2
 ;; Keywords: tools, convenience
 ;; URL: https://github.com/cjohansson/emacs-phps-mode
 
@@ -30,13 +30,16 @@
 
 ;;; Commentary:
 
+;; A major-mode that uses original PHP lexer tokens for syntax coloring and 
indentation making it easier to spot errors in syntax.  Also includes full 
support for PSR-1 and PSR-2 indentation, imenu.  Improved syntax table in 
comparison with old PHP major-mode.
+
 ;; Please see README.md from the same repository for extended documentation.
 
-;; NOTE use wisent-parse-toggle-verbose-flag and (semantic-debug) to debug 
parsing
 
 
 ;;; Code:
 
+;; NOTE use wisent-parse-toggle-verbose-flag and (semantic-debug) to debug 
parsing
+
 (autoload 'phps-mode-flycheck-init "phps-mode-flycheck")
 (autoload 'phps-mode-flymake-init "phps-mode-flymake")
 (autoload 'phps-mode-font-lock-init "phps-mode-font-lock")
@@ -67,7 +70,7 @@
   ;; Font lock
   (phps-mode-font-lock-init)
 
-  ;; Flymake
+  ;; Flymake TODO
   ;; (phps-mode-flymake-init)
 
   ;; Flycheck
@@ -76,9 +79,6 @@
   ;; Override functions
   (phps-mode-functions-init)
 
-  (setq major-mode 'phps-mode)
-  (setq mode-name "PHPs")
-
   ;; Lexer
   (phps-mode-lexer-init)
 
diff --git a/sample-php-files/functions.php b/sample-php-files/functions.php
index 1b64482..3cf263f 100644
--- a/sample-php-files/functions.php
+++ b/sample-php-files/functions.php
@@ -6,5 +6,7 @@
  */
 function myFunctionA($myArg1, $myArg2)
 {
+    $myArg1 = true;
+    $myArg2 = false;
     echo "some stuff";
 }



reply via email to

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