diff options
| author | Simeon Simeonov | 2017-06-12 12:19:09 +0200 |
|---|---|---|
| committer | Simeon Simeonov | 2017-06-12 12:19:09 +0200 |
| commit | baa0fad528cd0082820c698352e4aeed08fbab51 (patch) | |
| tree | d6ef0391a198d07f7f8848e4c0022614e041a07a /.emacs.d/lisp | |
| parent | beaddc354283a9d45a4260d171be022129443c45 (diff) | |
Update php-mode and yasnippet
Diffstat (limited to '.emacs.d/lisp')
| -rw-r--r-- | .emacs.d/lisp/php-mode.el | 4 | ||||
| -rw-r--r-- | .emacs.d/lisp/yasnippet.el | 64 |
2 files changed, 41 insertions, 27 deletions
diff --git a/.emacs.d/lisp/php-mode.el b/.emacs.d/lisp/php-mode.el index 60df841..62e1e97 100644 --- a/.emacs.d/lisp/php-mode.el +++ b/.emacs.d/lisp/php-mode.el | |||
| @@ -294,7 +294,9 @@ You can replace \"en\" with your ISO language code." | |||
| 294 | :type 'string) | 294 | :type 'string) |
| 295 | 295 | ||
| 296 | ;;;###autoload | 296 | ;;;###autoload |
| 297 | (add-to-list 'interpreter-mode-alist (cons "php" 'php-mode)) | 297 | (add-to-list 'interpreter-mode-alist |
| 298 | ;; Match php, php-3, php5, php7, php5.5, php-7.0.1, etc. | ||
| 299 | (cons "php\\(?:-?[3457]\\(?:\\.[0-9]+\\)*\\)?" 'php-mode)) | ||
| 298 | 300 | ||
| 299 | (defcustom php-mode-hook nil | 301 | (defcustom php-mode-hook nil |
| 300 | "List of functions to be executed on entry to `php-mode'." | 302 | "List of functions to be executed on entry to `php-mode'." |
diff --git a/.emacs.d/lisp/yasnippet.el b/.emacs.d/lisp/yasnippet.el index 34bc5eb..798e49e 100644 --- a/.emacs.d/lisp/yasnippet.el +++ b/.emacs.d/lisp/yasnippet.el | |||
| @@ -3713,7 +3713,15 @@ Move the overlays, or create them if they do not exit." | |||
| 3713 | ;; running. This would mean a lot of overlay modification hooks | 3713 | ;; running. This would mean a lot of overlay modification hooks |
| 3714 | ;; running, but if managed correctly (including overlay priorities) | 3714 | ;; running, but if managed correctly (including overlay priorities) |
| 3715 | ;; they should account for all situations... | 3715 | ;; they should account for all situations... |
| 3716 | ;; | 3716 | |
| 3717 | (defvar yas--first-indent-undo nil | ||
| 3718 | "Internal variable for indent undo entries. | ||
| 3719 | Used to pass info from `yas--indent-region' to `yas-expand-snippet'.") | ||
| 3720 | (defvar yas--get-indent-undo-pos nil | ||
| 3721 | "Record undo info for line beginning at given position. | ||
| 3722 | We bind this when first creating a snippet. See also | ||
| 3723 | `yas--first-indent-undo'.") | ||
| 3724 | |||
| 3717 | (defun yas-expand-snippet (content &optional start end expand-env) | 3725 | (defun yas-expand-snippet (content &optional start end expand-env) |
| 3718 | "Expand snippet CONTENT at current point. | 3726 | "Expand snippet CONTENT at current point. |
| 3719 | 3727 | ||
| @@ -3742,6 +3750,7 @@ considered when expanding the snippet." | |||
| 3742 | (to-delete (and start | 3750 | (to-delete (and start |
| 3743 | end | 3751 | end |
| 3744 | (buffer-substring-no-properties start end))) | 3752 | (buffer-substring-no-properties start end))) |
| 3753 | (yas--first-indent-undo nil) | ||
| 3745 | snippet) | 3754 | snippet) |
| 3746 | (goto-char start) | 3755 | (goto-char start) |
| 3747 | (setq yas--indent-original-column (current-column)) | 3756 | (setq yas--indent-original-column (current-column)) |
| @@ -3765,7 +3774,8 @@ considered when expanding the snippet." | |||
| 3765 | ;; plain text will get recorded at the end. | 3774 | ;; plain text will get recorded at the end. |
| 3766 | ;; | 3775 | ;; |
| 3767 | ;; stacked expansion: also shoosh the overlay modification hooks | 3776 | ;; stacked expansion: also shoosh the overlay modification hooks |
| 3768 | (let ((buffer-undo-list t)) | 3777 | (let ((buffer-undo-list t) |
| 3778 | (yas--get-indent-undo-pos (line-beginning-position))) | ||
| 3769 | ;; snippet creation might evaluate users elisp, which | 3779 | ;; snippet creation might evaluate users elisp, which |
| 3770 | ;; might generate errors, so we have to be ready to catch | 3780 | ;; might generate errors, so we have to be ready to catch |
| 3771 | ;; them mostly to make the undo information | 3781 | ;; them mostly to make the undo information |
| @@ -3791,23 +3801,20 @@ considered when expanding the snippet." | |||
| 3791 | (unless (yas--snippet-fields snippet) | 3801 | (unless (yas--snippet-fields snippet) |
| 3792 | (yas-exit-snippet snippet)) | 3802 | (yas-exit-snippet snippet)) |
| 3793 | 3803 | ||
| 3794 | ;; Push two undo actions: the deletion of the inserted contents of | 3804 | ;; Undo actions from indent of snippet's 1st line. |
| 3795 | ;; the new snippet (without the "key") followed by an apply of | 3805 | (setq buffer-undo-list |
| 3796 | ;; `yas--take-care-of-redo' on the newly inserted snippet boundaries | 3806 | (nconc yas--first-indent-undo buffer-undo-list)) |
| 3797 | ;; | 3807 | ;; Undo action for the expand snippet contents. |
| 3798 | ;; A small exception, if `yas-also-auto-indent-first-line' | 3808 | (push (cons (overlay-start (yas--snippet-control-overlay snippet)) |
| 3799 | ;; is t and `yas--indent' decides to indent the line to a | 3809 | (overlay-end (yas--snippet-control-overlay snippet))) |
| 3800 | ;; point before the actual expansion point, undo would be | 3810 | buffer-undo-list) |
| 3801 | ;; messed up. We call the early point "newstart"". case, | 3811 | ;; Follow up with `yas--take-care-of-redo' on the newly |
| 3802 | ;; and attempt to fix undo. | 3812 | ;; inserted snippet boundaries. |
| 3803 | ;; | 3813 | (push `(apply yas--take-care-of-redo ,start |
| 3804 | (let ((newstart (overlay-start (yas--snippet-control-overlay snippet))) | 3814 | ,(overlay-end (yas--snippet-control-overlay snippet)) |
| 3805 | (end (overlay-end (yas--snippet-control-overlay snippet)))) | 3815 | ,snippet) |
| 3806 | (when (< newstart start) | 3816 | buffer-undo-list) |
| 3807 | (push (cons (make-string (- start newstart) ? ) newstart) buffer-undo-list)) | 3817 | |
| 3808 | (push (cons newstart end) buffer-undo-list) | ||
| 3809 | (push `(apply yas--take-care-of-redo ,start ,end ,snippet) | ||
| 3810 | buffer-undo-list)) | ||
| 3811 | ;; Now, schedule a move to the first field | 3818 | ;; Now, schedule a move to the first field |
| 3812 | ;; | 3819 | ;; |
| 3813 | (let ((first-field (car (yas--snippet-fields snippet)))) | 3820 | (let ((first-field (car (yas--snippet-fields snippet)))) |
| @@ -4189,12 +4196,12 @@ Buffer must be narrowed to BEG..END used to create the snapshot info." | |||
| 4189 | (defun yas--indent-region (from to snippet) | 4196 | (defun yas--indent-region (from to snippet) |
| 4190 | "Indent the lines between FROM and TO with `indent-according-to-mode'. | 4197 | "Indent the lines between FROM and TO with `indent-according-to-mode'. |
| 4191 | The SNIPPET's markers are preserved." | 4198 | The SNIPPET's markers are preserved." |
| 4192 | (let* ((snippet-markers (yas--collect-snippet-markers snippet)) | 4199 | (save-excursion |
| 4193 | (to (set-marker (make-marker) to))) | 4200 | (save-restriction |
| 4194 | (save-excursion | 4201 | (widen) |
| 4195 | (goto-char from) | 4202 | (let* ((snippet-markers (yas--collect-snippet-markers snippet)) |
| 4196 | (save-restriction | 4203 | (to (set-marker (make-marker) to))) |
| 4197 | (widen) | 4204 | (goto-char from) |
| 4198 | (cl-loop for bol = (line-beginning-position) | 4205 | (cl-loop for bol = (line-beginning-position) |
| 4199 | for eol = (line-end-position) | 4206 | for eol = (line-end-position) |
| 4200 | if (/= bol eol) do | 4207 | if (/= bol eol) do |
| @@ -4206,7 +4213,12 @@ The SNIPPET's markers are preserved." | |||
| 4206 | remarkers))) | 4213 | remarkers))) |
| 4207 | (unwind-protect | 4214 | (unwind-protect |
| 4208 | (progn (back-to-indentation) | 4215 | (progn (back-to-indentation) |
| 4209 | (indent-according-to-mode)) | 4216 | (if (eq yas--get-indent-undo-pos bol) |
| 4217 | (let ((buffer-undo-list nil)) | ||
| 4218 | (indent-according-to-mode) | ||
| 4219 | (setq yas--first-indent-undo | ||
| 4220 | (delq nil buffer-undo-list))) | ||
| 4221 | (indent-according-to-mode))) | ||
| 4210 | (save-restriction | 4222 | (save-restriction |
| 4211 | (narrow-to-region bol (line-end-position)) | 4223 | (narrow-to-region bol (line-end-position)) |
| 4212 | (mapc #'yas--restore-marker-location remarkers)))) | 4224 | (mapc #'yas--restore-marker-location remarkers)))) |
