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

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

[elpa] externals/phps-mode a0b7695 316/405: Passes unit tests for integr


From: Stefan Monnier
Subject: [elpa] externals/phps-mode a0b7695 316/405: Passes unit tests for integration with electric-pair
Date: Sat, 13 Jul 2019 10:00:39 -0400 (EDT)

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

    Passes unit tests for integration with electric-pair
---
 README.md                   |  1 +
 phps-mode-syntax-table.el   | 20 +++++++++++++++++---
 phps-mode-test-functions.el |  4 ----
 3 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/README.md b/README.md
index 72ae7d6..f51cab3 100644
--- a/README.md
+++ b/README.md
@@ -14,6 +14,7 @@ This mode does not require PHP installed on computer because 
it has a elisp base
 * Syntax coloring based on lexer tokens (100%)
 * PSR-1 and PSR-2 indentation based on lexer tokens (100%)
 * Imenu support (100%)
+* Integration with (electric-pair) (100%)
 * Incremental lexer and syntax coloring after buffer changes (75%)
 * Incremental indentation and imenu calculation after buffer changes (50%)
 * Wisent LALR parser based on official PHP yacc parser automatically converted 
grammar (50%)
diff --git a/phps-mode-syntax-table.el b/phps-mode-syntax-table.el
index c5e9cfc..23a1413 100644
--- a/phps-mode-syntax-table.el
+++ b/phps-mode-syntax-table.el
@@ -98,17 +98,31 @@
     (modify-syntax-entry ?\" "\"" phps-mode-syntax-table)
 
     ;; Treat single quoted string as string quote
-    (modify-syntax-entry ?\' "\"" phps-mode-syntax-table)
+    (modify-syntax-entry ?' "\"" phps-mode-syntax-table)
 
     ;; Treat back-quoted string as string quote
-    (modify-syntax-entry ?\` "\"" phps-mode-syntax-table)
+    (modify-syntax-entry ?` "\"" phps-mode-syntax-table)
 
     phps-mode-syntax-table)
   "Syntax table for phps-mode.")
 
 (defun phps-mode-syntax-table-init ()
   "Apply syntax table."
-  (set-syntax-table phps-mode-syntax-table))
+  (set-syntax-table phps-mode-syntax-table)
+
+  ;; NOTE: These are required for wrapping region functionality
+  (transient-mark-mode)
+  (electric-pair-mode)
+
+  (when (boundp 'electric-pair-pairs)
+
+    ;; Add back-quotes to electric pair list
+    (unless (assoc 96 electric-pair-pairs)
+      (push '(96 . 96) electric-pair-pairs))
+
+    ;; Add single-quotes to electric-pair characters
+    (unless (assoc 39 electric-pair-pairs)
+      (push '(39 . 39) electric-pair-pairs))))
 
 (provide 'phps-mode-syntax-table)
 
diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el
index 629fed6..139705f 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -780,10 +780,6 @@
 (defun phps-mode-test-functions-quote-region ()
   "Test double quotes, single quotes, curly bracket, square bracket, round 
bracket, back-quotes on regions."
 
-  ;; NOTE: These are required for wrapping region functionality
-  (transient-mark-mode)
-  (electric-pair-mode)
-
   (phps-mode-test-with-buffer
    "<?php\n$var = abc;"
    "Double quotes around region"



reply via email to

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