branch: master
commit ad3a4d192d8dafc283ebb1db7bbd8ca782c417d0
Author: Noam Postavsky <[email protected]>
Commit: Noam Postavsky <[email protected]>
Don't use prog-mode in older Emacs
* yasnippet.el (snippet-mode): Derive from prog-mode only if it's
fbound.
* yasnippet-tests.el (extra-modes-parenthood)
(loading-with-cyclic-parenthood): Fix comment typo.
---
yasnippet-tests.el | 4 ++--
yasnippet.el | 27 +++++++++++++++++++--------
2 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/yasnippet-tests.el b/yasnippet-tests.el
index a773def..1851986 100644
--- a/yasnippet-tests.el
+++ b/yasnippet-tests.el
@@ -1090,7 +1090,7 @@ hello ${1:$(when (stringp yas-text) (funcall func
yas-text))} foo${1:$$(concat \
yet-another-c-mode
and-also-this-one
and-that-one
- ;; prog-mode doesn't exist in emacs 24.3
+ ;; prog-mode doesn't exist in emacs 23.4
,@(if (fboundp 'prog-mode)
'(prog-mode))
emacs-lisp-mode
@@ -1117,7 +1117,7 @@ hello ${1:$(when (stringp yas-text) (funcall func
yas-text))} foo${1:$$(concat \
c-mode
,major-mode))
(expected-rest `(cc-mode
- ;; prog-mode doesn't exist in emacs 24.3
+ ;; prog-mode doesn't exist in emacs 23.4
,@(if (fboundp 'prog-mode)
'(prog-mode))
emacs-lisp-mode
diff --git a/yasnippet.el b/yasnippet.el
index 600bda8..56e2377 100644
--- a/yasnippet.el
+++ b/yasnippet.el
@@ -951,14 +951,25 @@ Honour `yas-dont-activate-functions', which see."
"The keymap used when `snippet-mode' is active.")
-;;;###autoload
-(define-derived-mode snippet-mode prog-mode "Snippet"
- "A mode for editing yasnippets"
- (setq font-lock-defaults '(yas--font-lock-keywords))
- (set (make-local-variable 'require-final-newline) nil)
- (set (make-local-variable 'comment-start) "#")
- (set (make-local-variable 'comment-start-skip) "#+[\t ]*")
- (add-hook 'after-save-hook #'yas-maybe-load-snippet-buffer nil t))
+
+;;;###autoload(autoload 'snippet-mode "yasnippet" "A mode for editing
yasnippets" t nil)
+(eval-and-compile
+ (if (fboundp 'prog-mode)
+ ;; `prog-mode' is new in 24.1.
+ (define-derived-mode snippet-mode prog-mode "Snippet"
+ "A mode for editing yasnippets"
+ (setq font-lock-defaults '(yas--font-lock-keywords))
+ (set (make-local-variable 'require-final-newline) nil)
+ (set (make-local-variable 'comment-start) "#")
+ (set (make-local-variable 'comment-start-skip) "#+[\t ]*")
+ (add-hook 'after-save-hook #'yas-maybe-load-snippet-buffer nil t))
+ (define-derived-mode snippet-mode fundamental-mode "Snippet"
+ "A mode for editing yasnippets"
+ (setq font-lock-defaults '(yas--font-lock-keywords))
+ (set (make-local-variable 'require-final-newline) nil)
+ (set (make-local-variable 'comment-start) "#")
+ (set (make-local-variable 'comment-start-skip) "#+[\t ]*")
+ (add-hook 'after-save-hook #'yas-maybe-load-snippet-buffer nil t))))
(defun yas-snippet-mode-buffer-p ()
"Return non-nil if current buffer should be in `snippet-mode'.