summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.emacs10
-rw-r--r--.emacs.d/lisp/php-face.el5
-rw-r--r--.emacs.d/lisp/php-mode.el108
-rw-r--r--.emacs.d/lisp/php.el60
-rw-r--r--.emacs.d/lisp/yasnippet.el22
5 files changed, 167 insertions, 38 deletions
diff --git a/.emacs b/.emacs
index 594c445..0b5d15e 100644
--- a/.emacs
+++ b/.emacs
@@ -55,6 +55,7 @@
55(set-keyboard-coding-system 'utf-8) 55(set-keyboard-coding-system 'utf-8)
56 56
57(put 'downcase-region 'disabled nil) 57(put 'downcase-region 'disabled nil)
58(kill-buffer "*scratch*")
58 59
59 60
60;; Programming section 61;; Programming section
@@ -93,6 +94,15 @@
93(require 'yaml-mode) 94(require 'yaml-mode)
94(add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode)) 95(add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode))
95 96
97;; Python
98(require 'whitespace)
99(add-hook 'python-mode-hook
100 (lambda ()
101 (progn
102 (setq whitespace-line-column 80)
103 (setq whitespace-style '(face empty tabs lines-tail trailing))
104 (whitespace-mode))))
105
96;; yasnippet 106;; yasnippet
97(require 'yasnippet) 107(require 'yasnippet)
98(yas-global-mode 1) 108(yas-global-mode 1)
diff --git a/.emacs.d/lisp/php-face.el b/.emacs.d/lisp/php-face.el
index 75bdc81..4230bae 100644
--- a/.emacs.d/lisp/php-face.el
+++ b/.emacs.d/lisp/php-face.el
@@ -101,6 +101,11 @@
101 :group 'php-faces 101 :group 'php-faces
102 :tag "PHP Type") 102 :tag "PHP Type")
103 103
104(defface php-class '((t (:inherit font-lock-type-face)))
105 "PHP Mode face used to highlight class."
106 :group 'php-faces
107 :tag "PHP Class")
108
104(defface php-constant '((t (:inherit font-lock-constant-face))) 109(defface php-constant '((t (:inherit font-lock-constant-face)))
105 "PHP Mode face used to highlight constants." 110 "PHP Mode face used to highlight constants."
106 :group 'php-faces 111 :group 'php-faces
diff --git a/.emacs.d/lisp/php-mode.el b/.emacs.d/lisp/php-mode.el
index a339e17..9be3b55 100644
--- a/.emacs.d/lisp/php-mode.el
+++ b/.emacs.d/lisp/php-mode.el
@@ -444,8 +444,32 @@ In that case set to `NIL'."
444 (prefix "\\" "::"))) 444 (prefix "\\" "::")))
445 445
446(c-lang-defconst c-operators 446(c-lang-defconst c-operators
447 php (delete '(postfix-if-paren "<" ">") 447 php `((prefix "new" "clone")
448 (c-lang-const c-operators))) 448 ,@(c-lang-const c-identifier-ops)
449 (postfix "->")
450 (postfix "++" "--" "[" "]" "(" ")")
451 (right-assoc "**")
452 (prefix "++" "--" "+" "-" "~" "(" ")" "@")
453 (prefix "instanceof")
454 (prefix "!")
455 (left-assoc "*" "/" "%")
456 (left-assoc "+" "-" ".")
457 (left-assoc "<<" ">>")
458 (left-assoc "<" ">" "<=" ">=")
459 (left-assoc "==" "!=" "===" "!==" "<>" "<=>")
460 (left-assoc "&")
461 (left-assoc "^")
462 (left-assoc "|")
463 (left-assoc "&&")
464 (left-assoc "||")
465 (right-assoc "??")
466 (left-assoc "?:")
467 (right-assoc-sequence "?" ":")
468 (right-assoc ,@(c-lang-const c-assignment-operators))
469 (left-assoc "and")
470 (left-assoc "xor")
471 (left-assoc "or")
472 (left-assoc ",")))
449 473
450;; Allow '\' when scanning from open brace back to defining 474;; Allow '\' when scanning from open brace back to defining
451;; construct like class 475;; construct like class
@@ -950,31 +974,43 @@ this ^ lineup"
950 (goto-char (point-max))) 974 (goto-char (point-max)))
951 (c-put-char-property (1- (point)) 'syntax-table (string-to-syntax "|"))) 975 (c-put-char-property (1- (point)) 'syntax-table (string-to-syntax "|")))
952 976
977(defvar-local php-mode--propertize-extend-region-current nil
978 "Prevent undesirable recursion in PHP-SYNTAX-PROPERTIZE-EXTEND-REGION")
979
953(defun php-syntax-propertize-extend-region (start end) 980(defun php-syntax-propertize-extend-region (start end)
954 "Extend the propertize region if START or END falls inside a PHP heredoc." 981 "Extend the propertize region if START or END falls inside a PHP heredoc."
955 (let ((new-start) 982 (let ((pair (cons start end)))
956 (new-end)) 983 (when (not (member pair php-mode--propertize-extend-region-current))
957 (goto-char start) 984 ;; re-search functions may trigger
958 (when (re-search-backward php-heredoc-start-re nil t) 985 ;; syntax-propertize-extend-region-functions to be called again, which in
959 (let ((maybe (point))) 986 ;; turn call this to be called again.
960 (when (and (re-search-forward 987 (push pair php-mode--propertize-extend-region-current)
961 (php-heredoc-end-re (match-string 0)) nil t) 988 (unwind-protect
962 (> (point) start)) 989 (let ((new-start)
963 (setq new-start maybe)))) 990 (new-end))
964 (goto-char end) 991 (goto-char start)
965 (when (re-search-backward php-heredoc-start-re nil t) 992 (when (re-search-backward php-heredoc-start-re nil t)
966 (if (re-search-forward 993 (let ((maybe (point)))
967 (php-heredoc-end-re (match-string 0)) nil t) 994 (when (and (re-search-forward (php-heredoc-end-re (match-string 0)) nil t)
968 (when (> (point) end) 995 (> (point) start))
969 (setq new-end (point))) 996 (setq new-start maybe))))
970 (setq new-end (point-max)))) 997 (goto-char end)
971 (when (or new-start new-end) 998 (when (re-search-backward php-heredoc-start-re nil t)
972 (cons (or new-start start) (or new-end end))))) 999 (if (re-search-forward (php-heredoc-end-re (match-string 0)) nil t)
1000 (when (> (point) end)
1001 (setq new-end (point)))
1002 (setq new-end (point-max))))
1003 (when (or new-start new-end)
1004 (cons (or new-start start) (or new-end end))))
1005 ;; Cleanup
1006 (setq php-mode--propertize-extend-region-current
1007 (delete pair php-mode--propertize-extend-region-current))))))
973 1008
974(easy-menu-define php-mode-menu php-mode-map "PHP Mode Commands" 1009(easy-menu-define php-mode-menu php-mode-map "PHP Mode Commands"
975 (cons "PHP" (c-lang-const c-mode-menu php))) 1010 (cons "PHP" (c-lang-const c-mode-menu php)))
976 1011
977(defvar-local php-mode--delayed-set-style nil) 1012(defvar-local php-mode--delayed-set-style nil)
1013(defvar-local php-style-delete-trailing-whitespace nil)
978 1014
979(defun php-set-style (stylename &optional dont-override) 1015(defun php-set-style (stylename &optional dont-override)
980 "Set the current `php-mode' buffer to use the style STYLENAME. 1016 "Set the current `php-mode' buffer to use the style STYLENAME.
@@ -1029,7 +1065,8 @@ After setting the stylevars run hooks according to STYLENAME
1029 (when php-mode--delayed-set-style 1065 (when php-mode--delayed-set-style
1030 (let ((coding-style (or (and (boundp 'php-project-coding-style) php-project-coding-style) 1066 (let ((coding-style (or (and (boundp 'php-project-coding-style) php-project-coding-style)
1031 php-mode-coding-style))) 1067 php-mode-coding-style)))
1032 (prog1 (php-set-style (symbol-name coding-style)) 1068 (prog1 (when coding-style
1069 (php-set-style (symbol-name coding-style)))
1033 (remove-hook 'hack-local-variables-hook #'php-mode-set-style-delay))))) 1070 (remove-hook 'hack-local-variables-hook #'php-mode-set-style-delay)))))
1034 1071
1035(defvar php-mode-syntax-table 1072(defvar php-mode-syntax-table
@@ -1077,8 +1114,8 @@ After setting the stylevars run hooks according to STYLENAME
1077 (setq-local font-lock-constant-face 'php-constant) 1114 (setq-local font-lock-constant-face 'php-constant)
1078 1115
1079 (setq-local syntax-propertize-function #'php-syntax-propertize-function) 1116 (setq-local syntax-propertize-function #'php-syntax-propertize-function)
1080 (add-to-list (make-local-variable 'syntax-propertize-extend-region-functions) 1117 (add-hook 'syntax-propertize-extend-region-functions
1081 #'php-syntax-propertize-extend-region) 1118 #'php-syntax-propertize-extend-region t t)
1082 1119
1083 (setq imenu-generic-expression php-imenu-generic-expression) 1120 (setq imenu-generic-expression php-imenu-generic-expression)
1084 1121
@@ -1250,20 +1287,22 @@ current `tags-file-name'."
1250 nil))) 1287 nil)))
1251 1288
1252(defun php-show-arglist () 1289(defun php-show-arglist ()
1290 "Show function arguments at cursor position."
1253 (interactive) 1291 (interactive)
1254 (let* ((tagname (php-get-pattern)) 1292 (let* ((tagname (php-get-pattern))
1255 (buf (find-tag-noselect tagname nil nil)) 1293 (buf (find-tag-noselect tagname nil nil))
1256 arglist) 1294 arglist)
1257 (with-current-buffer buf 1295 (with-current-buffer buf
1258 (goto-char (point-min)) 1296 (save-excursion
1259 (when (re-search-forward 1297 (goto-char (point-min))
1260 (format "function\\s-+%s\\s-*(\\([^{]*\\))" tagname) 1298 (when (re-search-forward
1261 nil t) 1299 (format "function\\s-+%s\\s-*(\\([^{]*\\))" tagname)
1262 (setq arglist (buffer-substring-no-properties 1300 nil t)
1263 (match-beginning 1) (match-end 1))))) 1301 (setq arglist (buffer-substring-no-properties
1302 (match-beginning 1) (match-end 1))))))
1264 (if arglist 1303 (if arglist
1265 (message "Arglist for %s: %s" tagname arglist) 1304 (message "Arglist for %s: %s" tagname arglist)
1266 (message "Unknown function: %s" tagname)))) 1305 (message "Unknown function: %s" tagname))))
1267 1306
1268(defcustom php-search-documentation-browser-function nil 1307(defcustom php-search-documentation-browser-function nil
1269 "Function to display PHP documentation in a WWW browser. 1308 "Function to display PHP documentation in a WWW browser.
@@ -1464,7 +1503,14 @@ a completion list."
1464 ;; namespaces 1503 ;; namespaces
1465 ("\\(\\([a-zA-Z0-9_]+\\\\\\)+[a-zA-Z0-9_]+\\|\\(\\\\[a-zA-Z0-9_]+\\)+\\)[^:a-zA-Z0-9_\\\\]" 1 'font-lock-type-face) 1504 ("\\(\\([a-zA-Z0-9_]+\\\\\\)+[a-zA-Z0-9_]+\\|\\(\\\\[a-zA-Z0-9_]+\\)+\\)[^:a-zA-Z0-9_\\\\]" 1 'font-lock-type-face)
1466 ("\\(\\([a-zA-Z0-9_]+\\\\\\)+[a-zA-Z0-9_]+\\|\\(\\\\[a-zA-Z0-9_]+\\)+\\)::" 1 'php-constant) 1505 ("\\(\\([a-zA-Z0-9_]+\\\\\\)+[a-zA-Z0-9_]+\\|\\(\\\\[a-zA-Z0-9_]+\\)+\\)::" 1 'php-constant)
1467 1506 (,(eval-when-compile
1507 (rx bol (* (syntax whitespace))
1508 (or "private" "protected" "public")
1509 (+ (syntax whitespace))
1510 (group (? "?") (+ (or "\\" (syntax word) (syntax symbol))))
1511 (+ (syntax whitespace))
1512 (: "$" (+ (or (syntax word) (syntax symbol))))))
1513 1 'php-class)
1468 ;; Support the ::class constant in PHP5.6 1514 ;; Support the ::class constant in PHP5.6
1469 ("\\sw+\\(::\\)\\(class\\)\\b" (1 'php-paamayim-nekudotayim) (2 'php-magical-constant)) 1515 ("\\sw+\\(::\\)\\(class\\)\\b" (1 'php-paamayim-nekudotayim) (2 'php-magical-constant))
1470 1516
diff --git a/.emacs.d/lisp/php.el b/.emacs.d/lisp/php.el
index 336c267..2bf117b 100644
--- a/.emacs.d/lisp/php.el
+++ b/.emacs.d/lisp/php.el
@@ -28,8 +28,10 @@
28;; This file provides common variable and functions for PHP packages. 28;; This file provides common variable and functions for PHP packages.
29 29
30;;; Code: 30;;; Code:
31(require 'cl-lib)
31(require 'flymake) 32(require 'flymake)
32(require 'php-project) 33(require 'php-project)
34(require 'rx)
33 35
34;;;###autoload 36;;;###autoload
35(defgroup php nil 37(defgroup php nil
@@ -121,6 +123,14 @@ You can replace \"en\" with your ISO language code."
121 :group 'php 123 :group 'php
122 :tag "PHP Mode Maybe Hook" 124 :tag "PHP Mode Maybe Hook"
123 :type 'hook) 125 :type 'hook)
126
127(defcustom php-default-builtin-web-server-port 3939
128 "Port number of PHP Built-in HTTP server (php -S)."
129 :group 'php
130 :tag "PHP Default Built-in Web Server Port"
131 :type 'integer
132 :link '(url-link :tag "Built-in web server"
133 "https://www.php.net/manual/features.commandline.webserver.php"))
124 134
125;;; PHP Keywords 135;;; PHP Keywords
126(defconst php-magical-constants 136(defconst php-magical-constants
@@ -299,5 +309,55 @@ Look at the `php-executable' variable instead of the constant \"php\" command."
299 (when matched 309 (when matched
300 (insert (concat matched php-namespace-suffix-when-insert))))) 310 (insert (concat matched php-namespace-suffix-when-insert)))))
301 311
312;;;###autoload
313(defun php-run-builtin-web-server (router-or-dir hostname port &optional document-root)
314 "Run PHP Built-in web server.
315
316`ROUTER-OR-DIR': Path to router PHP script or Document root.
317`HOSTNAME': Hostname or IP address of Built-in web server.
318`PORT': Port number of Built-in web server.
319`DOCUMENT-ROOT': Path to Document root.
320
321When `DOCUMENT-ROOT' is NIL, the document root is obtained from `ROUTER-OR-DIR'."
322 (interactive
323 (let ((insert-default-directory t)
324 (d-o-r (read-file-name "Document root or Script: " default-directory)))
325 (list
326 (expand-file-name d-o-r)
327 (read-string "Hostname: " "0.0.0.0")
328 (read-number "Port: " php-default-builtin-web-server-port)
329 (if (file-directory-p d-o-r)
330 nil
331 (let ((root-input (read-file-name "Document root: " (directory-file-name d-o-r))))
332 (file-name-directory
333 (if (file-directory-p root-input)
334 root-input
335 (directory-file-name root-input))))))))
336 (let* ((default-directory
337 (or document-root
338 (if (file-directory-p router-or-dir)
339 router-or-dir
340 (directory-file-name router-or-dir))))
341 (pattern (rx-form `(: bos ,(getenv "HOME"))))
342 (short-dirname (replace-regexp-in-string pattern "~" default-directory))
343 (short-filename (replace-regexp-in-string pattern "~" router-or-dir))
344 (buf-name (format "php -S %s:%s -t %s %s"
345 hostname
346 port
347 short-dirname
348 (if document-root short-filename "")))
349 (args (cl-remove-if
350 #'null
351 (list "-S"
352 (format "%s:%d" hostname port)
353 "-t"
354 default-directory
355 (when document-root router-or-dir)))))
356 (message "Run PHP built-in server: %s" buf-name)
357 (apply #'make-comint buf-name php-executable nil args)
358 (funcall
359 (if (called-interactively-p 'interactive) #'display-buffer #'get-buffer)
360 (format "*%s*" buf-name))))
361
302(provide 'php) 362(provide 'php)
303;;; php.el ends here 363;;; php.el ends here
diff --git a/.emacs.d/lisp/yasnippet.el b/.emacs.d/lisp/yasnippet.el
index 9951940..3bbb94d 100644
--- a/.emacs.d/lisp/yasnippet.el
+++ b/.emacs.d/lisp/yasnippet.el
@@ -1,6 +1,6 @@
1;;; yasnippet.el --- Yet another snippet extension for Emacs. 1;;; yasnippet.el --- Yet another snippet extension for Emacs
2 2
3;; Copyright (C) 2008-2018 Free Software Foundation, Inc. 3;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
4;; Authors: pluskid <pluskid@gmail.com>, 4;; Authors: pluskid <pluskid@gmail.com>,
5;; João Távora <joaotavora@gmail.com>, 5;; João Távora <joaotavora@gmail.com>,
6;; Noam Postavsky <npostavs@gmail.com> 6;; Noam Postavsky <npostavs@gmail.com>
@@ -381,8 +381,7 @@ the trigger key itself."
381(defcustom yas-alias-to-yas/prefix-p t 381(defcustom yas-alias-to-yas/prefix-p t
382 "If non-nil make aliases for the old style yas/ prefixed symbols. 382 "If non-nil make aliases for the old style yas/ prefixed symbols.
383It must be set to nil before loading yasnippet to take effect." 383It must be set to nil before loading yasnippet to take effect."
384 :type 'boolean 384 :type 'boolean)
385 :group 'yasnippet)
386 385
387;; Only two faces, and one of them shouldn't even be used... 386;; Only two faces, and one of them shouldn't even be used...
388;; 387;;
@@ -790,12 +789,12 @@ expanded.")
790 ["About" yas-about 789 ["About" yas-about
791 :help "Display some information about YASnippet"])) 790 :help "Display some information about YASnippet"]))
792 791
792(define-obsolete-variable-alias 'yas-extra-modes 'yas--extra-modes "0.9.1")
793(defvar yas--extra-modes nil 793(defvar yas--extra-modes nil
794 "An internal list of modes for which to also lookup snippets. 794 "An internal list of modes for which to also lookup snippets.
795 795
796This variable probably makes more sense as buffer-local, so 796This variable probably makes more sense as buffer-local, so
797ensure your use `make-local-variable' when you set it.") 797ensure your use `make-local-variable' when you set it.")
798(define-obsolete-variable-alias 'yas-extra-modes 'yas--extra-modes "0.9.1")
799 798
800(defvar yas--tables (make-hash-table) 799(defvar yas--tables (make-hash-table)
801 "A hash table of mode symbols to `yas--table' objects.") 800 "A hash table of mode symbols to `yas--table' objects.")
@@ -3039,8 +3038,13 @@ snippet field. The arguments are the same as `completing-read'.
3039 3038
3040(defun yas--auto-next () 3039(defun yas--auto-next ()
3041 "Helper for `yas-auto-next'." 3040 "Helper for `yas-auto-next'."
3042 (remove-hook 'post-command-hook #'yas--auto-next t) 3041 (cl-loop
3043 (yas-next-field)) 3042 do (progn (remove-hook 'post-command-hook #'yas--auto-next t)
3043 (yas-next-field))
3044 ;; The transform in the next field may have requested auto-next as
3045 ;; well. Call it ourselves, since the command loop itself won't
3046 ;; recheck the value of post-command-hook while running it.
3047 while (memq #'yas--auto-next post-command-hook)))
3044 3048
3045(defmacro yas-auto-next (&rest body) 3049(defmacro yas-auto-next (&rest body)
3046 "Automatically advance to next field after eval'ing BODY." 3050 "Automatically advance to next field after eval'ing BODY."
@@ -4149,6 +4153,7 @@ After revival, push the `yas--take-care-of-redo' in the
4149 (when (yas--maybe-move-to-active-field snippet) 4153 (when (yas--maybe-move-to-active-field snippet)
4150 (setf (yas--snippet-control-overlay snippet) (yas--make-control-overlay snippet beg end)) 4154 (setf (yas--snippet-control-overlay snippet) (yas--make-control-overlay snippet beg end))
4151 (overlay-put (yas--snippet-control-overlay snippet) 'yas--snippet snippet) 4155 (overlay-put (yas--snippet-control-overlay snippet) 'yas--snippet snippet)
4156 (push snippet yas--active-snippets)
4152 (when (listp buffer-undo-list) 4157 (when (listp buffer-undo-list)
4153 (push `(apply yas--take-care-of-redo ,snippet) 4158 (push `(apply yas--take-care-of-redo ,snippet)
4154 buffer-undo-list)))) 4159 buffer-undo-list))))
@@ -4683,7 +4688,10 @@ SAVED-QUOTES is the in format returned by `yas--save-backquotes'."
4683(defun yas--scan-sexps (from count) 4688(defun yas--scan-sexps (from count)
4684 (ignore-errors 4689 (ignore-errors
4685 (save-match-data ; `scan-sexps' may modify match data. 4690 (save-match-data ; `scan-sexps' may modify match data.
4691 ;; Parse using the syntax table corresponding to the yasnippet syntax.
4686 (with-syntax-table (standard-syntax-table) 4692 (with-syntax-table (standard-syntax-table)
4693 ;; And ignore syntax-table properties that may have been placed by the
4694 ;; major mode since these aren't related to the yasnippet syntax.
4687 (let ((parse-sexp-lookup-properties nil)) 4695 (let ((parse-sexp-lookup-properties nil))
4688 (scan-sexps from count)))))) 4696 (scan-sexps from count))))))
4689 4697