branch: elpa/raku-mode
commit 3cf62b8383e3a3d77516c70725ad6d49bbf9d0d9
Author: Hinrik Örn Sigurðsson <[email protected]>
Commit: Hinrik Örn Sigurðsson <[email protected]>
Only check if .t/.pl/.pm files contain Perl 6 code
Also fixed it to not match "usev6".
---
perl6-mode.el | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/perl6-mode.el b/perl6-mode.el
index e6c36e8c46..1840e7a451 100644
--- a/perl6-mode.el
+++ b/perl6-mode.el
@@ -58,8 +58,15 @@
;;;###autoload
(add-to-list 'auto-mode-alist '("\\.p[lm]?6\\'" . perl6-mode))
+(defvar perl6--content-pattern
+ "^ *\\(?:use +v6\\|\\(?:\\(?:my\\|our\\)
+\\)?\\(?:module\\|class\\|role\\|grammar\\)\\)")
+
;;;###autoload
-(add-to-list 'magic-mode-alist '("^ *\\(?:use *v6\\|\\(?:\\(?:my\\|our\\)
+\\)?\\(?:module\\|class\\|role\\|grammar\\)\\)" . perl6-mode))
+(add-to-list 'magic-mode-alist '((lambda ()
+ (and
+ (and (stringp buffer-file-name)
+ (string-match
"\\.\\(?:t\\|p[lm]\\)\\'" buffer-file-name))
+ (re-search-forward perl6--content-pattern
4096 t))) . perl6-mode))
(provide 'perl6-mode)