]> code.delx.au - gnu-emacs-elpa/blobdiff - yasnippet.el
* README.mdown (Use `yas-minor-mode`): Reword.
[gnu-emacs-elpa] / yasnippet.el
index 706c86a70cefea8205bd75a235acc9b8cf1fb254..4f06a48e5d6230c1a0b66f6ceb135fa663e73027 100644 (file)
@@ -728,22 +728,21 @@ defined direct keybindings to the command
 (defun yas--modes-to-activate (&optional mode)
   "Compute list of mode symbols that are active for `yas-expand'
 and friends."
-  (let (dfs explored)
-    (setq dfs (lambda (mode)
-                (unless (memq mode explored)
-                  (push mode explored)
-                  (loop for neighbour
-                        in (cl-list* (get mode 'derived-mode-parent)
-                                     (ignore-errors (symbol-function mode))
-                                     (gethash mode yas--parents))
-                        when (and neighbour
-                                  (not (memq neighbour explored))
-                                  (symbolp neighbour))
-                        do (funcall dfs neighbour)))))
-    (if mode
-        (funcall dfs mode)
-      (mapcar dfs (cons major-mode yas--extra-modes)))
-    explored))
+  (let* ((explored (if mode (list mode) ; Building up list in reverse.
+                     (cons major-mode (reverse yas--extra-modes))))
+         (dfs
+          (lambda (mode)
+            (cl-loop for neighbour
+                     in (cl-list* (get mode 'derived-mode-parent)
+                                  (ignore-errors (symbol-function mode))
+                                  (gethash mode yas--parents))
+                     when (and neighbour
+                               (not (memq neighbour explored))
+                               (symbolp neighbour))
+                     do (push neighbour explored)
+                     (funcall dfs neighbour)))))
+    (mapcar dfs explored)
+    (nreverse explored)))
 
 (defvar yas-minor-mode-hook nil
   "Hook run when `yas-minor-mode' is turned on.")
@@ -1576,6 +1575,9 @@ Optional PROMPT sets the prompt to use."
 (defun yas-x-prompt (prompt choices &optional display-fn)
   "Display choices in a x-window prompt."
   (when (and window-system choices)
+    ;; Let window position be recalculated to ensure that
+    ;; `posn-at-point' returns non-nil.
+    (redisplay)
     (or
      (x-popup-menu
       (if (fboundp 'posn-at-point)
@@ -1776,9 +1778,9 @@ With prefix argument USE-JIT do jit-loading of snippets."
                           (current-time-string)))))
     ;; Normal case.
     (unless (file-exists-p (concat directory "/" ".yas-skip"))
-      (if (and (progn (yas--message 2 "Loading compiled snippets from %s" directory) t)
-               (load (expand-file-name ".yas-compiled-snippets" directory) 'noerror (<= yas-verbosity 3)))
-          (yas--message 2 "Loading snippet files from %s" directory)
+      (unless (and (load (expand-file-name ".yas-compiled-snippets" directory) 'noerror (<= yas-verbosity 3))
+                   (progn (yas--message 2 "Loaded compiled snippets from %s" directory) t))
+        (yas--message 2 "Loading snippet files from %s" directory)
         (yas--load-directory-2 directory mode-sym)))))
 
 (defun yas--load-directory-2 (directory mode-sym)
@@ -4015,8 +4017,9 @@ with their evaluated value into `yas--backquote-markers-and-strings'."
 
 (defun yas--scan-sexps (from count)
   (ignore-errors
-    (with-syntax-table (standard-syntax-table)
-      (scan-sexps from count))))
+    (save-match-data ; `scan-sexps' may modify match data.
+      (with-syntax-table (standard-syntax-table)
+        (scan-sexps from count)))))
 
 (defun yas--make-marker (pos)
   "Create a marker at POS with nil `marker-insertion-type'."
@@ -4048,9 +4051,8 @@ When multiple expressions are found, only the last one counts."
                                    ;; after the ":", this will be
                                    ;; caught as a mirror with
                                    ;; transform later.
-                                   (not (save-match-data
-                                          (eq (string-match "$[ \t\n]*("
-                                                            (match-string-no-properties 2)) 0)))
+                                   (not (string-match-p "\\`\\$[ \t\n]*("
+                                                        (match-string-no-properties 2)))
                                    ;; allow ${0: some exit text}
                                    ;; (not (and number (zerop number)))
                                    (yas--make-field number