[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master ac3fe83 30/60: Merge pull request #621 from npostavs/dfs-e
From: |
João Távora |
Subject: |
[elpa] master ac3fe83 30/60: Merge pull request #621 from npostavs/dfs-extra-modes2 |
Date: |
Thu, 21 Jan 2016 22:35:58 +0000 |
branch: master
commit ac3fe832471449f432c8cc3054166e94168a5ee2
Merge: 710ea4d fb6ec67
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>
Merge pull request #621 from npostavs/dfs-extra-modes2
find parents for extra-modes too (v2)
---
yasnippet-tests.el | 33 +++++++++++++++++++++++++++++----
yasnippet.el | 32 ++++++++++++++++----------------
2 files changed, 45 insertions(+), 20 deletions(-)
diff --git a/yasnippet-tests.el b/yasnippet-tests.el
index fbf79f8..4756571 100644
--- a/yasnippet-tests.el
+++ b/yasnippet-tests.el
@@ -491,15 +491,40 @@ TODO: correct this bug!"
yet-another-c-mode
and-also-this-one
and-that-one
- ;; prog-mode doesn't exit in emacs 24.3
+ ;; prog-mode doesn't exist in emacs 24.3
,@(if (fboundp 'prog-mode)
'(prog-mode))
emacs-lisp-mode
lisp-interaction-mode))
(observed (yas--modes-to-activate)))
- (should (null (cl-set-exclusive-or expected observed)))
- (should (= (length expected)
- (length observed))))))))
+ (should (equal (sort expected #'string<) (sort observed
#'string<))))))))
+
+(ert-deftest extra-modes-parenthood ()
+ "Test activation of parents of `yas--extra-modes'."
+ (yas-saving-variables
+ (yas-with-snippet-dirs '((".emacs.d/snippets"
+ ("c-mode"
+ (".yas-parents" . "cc-mode"))
+ ("cc-mode"
+ (".yas-parents" . "yet-another-c-mode
and-that-one"))
+ ("yet-another-c-mode"
+ (".yas-parents" . "c-mode and-also-this-one
lisp-interaction-mode"))))
+ (yas-reload-all)
+ (with-temp-buffer
+ (let* ((_ (yas-activate-extra-mode 'c-mode))
+ (expected `(,major-mode
+ c-mode
+ cc-mode
+ yet-another-c-mode
+ and-also-this-one
+ and-that-one
+ ;; prog-mode doesn't exist in emacs 24.3
+ ,@(if (fboundp 'prog-mode)
+ '(prog-mode))
+ emacs-lisp-mode
+ lisp-interaction-mode))
+ (observed (yas--modes-to-activate)))
+ (should (equal (sort expected #'string<) (sort observed
#'string<))))))))
(ert-deftest issue-492-and-494 ()
(defalias 'yas--phony-c-mode 'c-mode)
diff --git a/yasnippet.el b/yasnippet.el
index 1311cd0..a119011 100644
--- a/yasnippet.el
+++ b/yasnippet.el
@@ -728,22 +728,22 @@ 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)
- (setq dfs (lambda (mode &optional explored)
- (push mode explored)
- (cons mode
- (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))
- append (funcall dfs neighbour explored)))))
- (remove-duplicates (if mode
- (funcall dfs mode)
- (append yas--extra-modes
- (funcall dfs major-mode))))))
+ (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))
(defvar yas-minor-mode-hook nil
"Hook run when `yas-minor-mode' is turned on.")
- [elpa] master 7703a55 24/60: * doc/snippet-organization.org (.yas-skip): Add info., (continued)
- [elpa] master 7703a55 24/60: * doc/snippet-organization.org (.yas-skip): Add info., João Távora, 2016/01/21
- [elpa] master 041821a 22/60: * yasnippet-tests.el (string-suffix-p): Define for older Emacsen., João Távora, 2016/01/21
- [elpa] master fb6ec67 29/60: Fix #619; find parents for extra-modes too, João Távora, 2016/01/21
- [elpa] master 710ea4d 26/60: Update snippets module, João Távora, 2016/01/21
- [elpa] master 215ad9b 19/60: Fix #597; use SAVE-FILE to visit compiled snippets, João Távora, 2016/01/21
- [elpa] master e3f03ca 21/60: Test visiting compiled snippets, João Távora, 2016/01/21
- [elpa] master e56aa6f 28/60: Build a single `explored' list., João Távora, 2016/01/21
- [elpa] master b6d924c 31/60: * yasnippet.el (yas--scan-sexps): Use ignore-errors., João Távora, 2016/01/21
- [elpa] master 00b84ce 27/60: Add (failing) yas--modes-to-activate test, João Távora, 2016/01/21
- [elpa] master 72c6c4c 32/60: Fix #618; save match data in yas--scan-sexps, João Távora, 2016/01/21
- [elpa] master ac3fe83 30/60: Merge pull request #621 from npostavs/dfs-extra-modes2,
João Távora <=
- [elpa] master b8687bb 35/60: Avoid double snippet loading messages, João Távora, 2016/01/21
- [elpa] master 35642ac 33/60: Simplify string matching., João Távora, 2016/01/21
- [elpa] master b055f13 34/60: Fix #617; ensure point is visible before x prompt, João Távora, 2016/01/21
- [elpa] master f121645 38/60: Fix #607; avoid Emacs bug #21824, João Távora, 2016/01/21
- [elpa] master 1cf723a 41/60: Ignore trailing spaces in snippet definitions, João Távora, 2016/01/21
- [elpa] master 2100b89 42/60: Closes #632: Use `user-emacs-directory' instead of hardcoded "~/emacs.d", João Távora, 2016/01/21
- [elpa] master beb02e5 39/60: * CONTRIBUTING.md: Add note about changelog only messages., João Távora, 2016/01/21
- [elpa] master fb28ec8 37/60: * README.mdown (Use `yas-minor-mode`): Reword., João Távora, 2016/01/21
- [elpa] master 6c46878 43/60: Fix #587; set `this-command' on fallback., João Távora, 2016/01/21
- [elpa] master 23ee54e 44/60: Use destructive list functions in yas--s-a-p, João Távora, 2016/01/21