From 05b4f4ce4d6d2d655ed94c9de91cb530372eec0c Mon Sep 17 00:00:00 2001 From: Simeon Simeonov Date: Tue, 1 Aug 2017 12:02:49 +0200 Subject: Upgrade php-mode.el yaml-mode.el yasnippet.el --- .emacs.d/lisp/yasnippet.el | 76 +++++++++++++++++++++++++++------------------- 1 file changed, 45 insertions(+), 31 deletions(-) (limited to '.emacs.d/lisp/yasnippet.el') diff --git a/.emacs.d/lisp/yasnippet.el b/.emacs.d/lisp/yasnippet.el index 69f7381..94ccffb 100644 --- a/.emacs.d/lisp/yasnippet.el +++ b/.emacs.d/lisp/yasnippet.el @@ -1,11 +1,11 @@ ;;; yasnippet.el --- Yet another snippet extension for Emacs. -;; Copyright (C) 2008-2016 Free Software Foundation, Inc. +;; Copyright (C) 2008-2017 Free Software Foundation, Inc. ;; Authors: pluskid , ;; João Távora , ;; Noam Postavsky ;; Maintainer: Noam Postavsky -;; Version: 0.11.0 +;; Version: 0.12.1 ;; X-URL: http://github.com/joaotavora/yasnippet ;; Keywords: convenience, emulation ;; URL: http://github.com/joaotavora/yasnippet @@ -132,6 +132,7 @@ ;;; Code: (require 'cl-lib) +(declare-function cl-progv-after "cl-extra") ; Needed for 23.4. (require 'easymenu) (require 'help-mode) @@ -535,7 +536,7 @@ override bindings from other packages (e.g., `company-mode')." ;;; Internal variables -(defconst yas--version "0.11.0") +(defconst yas--version "0.12.1") (defvar yas--menu-table (make-hash-table) "A hash table of MAJOR-MODE symbols to menu keymaps.") @@ -585,6 +586,8 @@ override bindings from other packages (e.g., `company-mode')." (defvar yas--minor-mode-menu nil "Holds the YASnippet menu.") +(defvar yas--condition-cache-timestamp nil) + (defun yas--maybe-expand-key-filter (cmd) (when (let ((yas--condition-cache-timestamp (current-time))) (yas--templates-for-key-at-point)) @@ -2183,7 +2186,6 @@ Just put this function in `hippie-expand-try-functions-list'." ;;; ;;; ;;; -(defvar yas--condition-cache-timestamp nil) (defmacro yas-define-condition-cache (func doc &rest body) "Define a function FUNC with doc DOC and body BODY. BODY is executed at most once every snippet expansion attempt, to check @@ -3028,9 +3030,16 @@ DEPTH is a count of how many nested mirrors can affect this mirror" (defmacro yas--letenv (env &rest body) "Evaluate BODY with bindings from ENV. -ENV is a list of elements with the form (VAR FORM)." +ENV is a lisp expression that evaluates to list of elements with +the form (VAR FORM), where VAR is a symbol and FORM is a lisp +expression that evaluates to its value." (declare (debug (form body)) (indent 1)) - `(eval (cl-list* 'let* ,env ',body))) + (let ((envvar (make-symbol "envvar"))) + `(let ((,envvar ,env)) + (cl-progv + (mapcar #'car ,envvar) + (mapcar (lambda (v-f) (eval (cadr v-f))) ,envvar) + ,@body)))) (defun yas--snippet-map-markers (fun snippet) "Apply FUN to all marker (sub)fields in SNIPPET. @@ -3635,7 +3644,10 @@ field start. This hook does nothing if an undo is in progress." (narrow-to-region beg end) (mapc #'yas--restore-marker-location remarkers) (mapc #'yas--restore-overlay-location reoverlays)) - (mapc #'yas--update-mirrors snippets)))) + (mapc (lambda (snippet) + (yas--letenv (yas--snippet-expand-env snippet) + (yas--update-mirrors snippet))) + snippets)))) ;;; Apropos protection overlays: @@ -3828,7 +3840,7 @@ considered when expanding the snippet." (sit-for 0) ;; fix issue 125 (yas--letenv (yas--snippet-expand-env snippet) (yas--move-to-field snippet first-field)))) - (yas--message 4 "snippet expanded.") + (yas--message 4 "snippet %d expanded." (yas--snippet-id snippet)) (setq deactivate-mark nil) t)))) @@ -4540,7 +4552,7 @@ When multiple expressions are found, only the last one counts." (when parent-field (yas--advance-start-maybe mirror (yas--fom-start parent-field)))) ;; Update this mirror. - do (yas--mirror-update-display mirror field snippet) + do (yas--mirror-update-display mirror field) ;; Delay indenting until we're done all mirrors. We must do ;; this to avoid losing whitespace between fields that are ;; still empty (i.e., they will be non-empty after updating). @@ -4557,7 +4569,7 @@ When multiple expressions are found, only the last one counts." (cl-loop for (beg . end) in (cl-sort indent-regions #'< :key #'car) do (yas--indent-region beg end snippet))))))) -(defun yas--mirror-update-display (mirror field snippet) +(defun yas--mirror-update-display (mirror field) "Update MIRROR according to FIELD (and mirror transform)." (let* ((mirror-parent-field (yas--mirror-parent-field mirror)) @@ -4601,27 +4613,29 @@ When multiple expressions are found, only the last one counts." ;; (defun yas--post-command-handler () "Handles various yasnippet conditions after each command." - (yas--finish-moving-snippets) - (cond ((eq 'undo this-command) - ;; - ;; After undo revival the correct field is sometimes not - ;; restored correctly, this condition handles that - ;; - (let* ((snippet (car (yas-active-snippets))) - (target-field - (and snippet - (cl-find-if-not - (lambda (field) - (yas--field-probably-deleted-p snippet field)) - (remq nil - (cons (yas--snippet-active-field snippet) - (yas--snippet-fields snippet))))))) - (when target-field - (yas--move-to-field snippet target-field)))) - ((not (yas--undo-in-progress)) - ;; When not in an undo, check if we must commit the snippet - ;; (user exited it). - (yas--check-commit-snippet)))) + (condition-case err + (progn (yas--finish-moving-snippets) + (cond ((eq 'undo this-command) + ;; + ;; After undo revival the correct field is sometimes not + ;; restored correctly, this condition handles that + ;; + (let* ((snippet (car (yas-active-snippets))) + (target-field + (and snippet + (cl-find-if-not + (lambda (field) + (yas--field-probably-deleted-p snippet field)) + (remq nil + (cons (yas--snippet-active-field snippet) + (yas--snippet-fields snippet))))))) + (when target-field + (yas--move-to-field snippet target-field)))) + ((not (yas--undo-in-progress)) + ;; When not in an undo, check if we must commit the snippet + ;; (user exited it). + (yas--check-commit-snippet)))) + ((debug error) (signal (car err) (cdr err))))) ;;; Fancy docs: ;; -- cgit v1.3