[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/raku-mode 1b0698744b 015/253: Move Perl 6 detection into p
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/raku-mode 1b0698744b 015/253: Move Perl 6 detection into perl6-detect.el |
Date: |
Sat, 29 Jan 2022 08:28:35 -0500 (EST) |
branch: elpa/raku-mode
commit 1b0698744bebc1ed9f9cf7013de9949d4a07be7e
Author: Hinrik Örn Sigurðsson <hinrik.sig@gmail.com>
Commit: Hinrik Örn Sigurðsson <hinrik.sig@gmail.com>
Move Perl 6 detection into perl6-detect.el
---
Makefile | 2 +-
perl6-detect.el | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
perl6-mode.el | 35 +----------------------------------
3 files changed, 55 insertions(+), 35 deletions(-)
diff --git a/Makefile b/Makefile
index 1fca5bf111..07066008cf 100644
--- a/Makefile
+++ b/Makefile
@@ -7,7 +7,7 @@ export EMACS
PKGDIR := $(shell EMACS=$(EMACS) $(CASK) package-directory)
-SRCS = perl6-mode.el perl6-font-lock.el
+SRCS = perl6-mode.el perl6-font-lock.el perl6-detect.el
OBJS = $(SRCS:.el=.elc)
.PHONY: compile test clean
diff --git a/perl6-detect.el b/perl6-detect.el
new file mode 100644
index 0000000000..05ed2fe8ae
--- /dev/null
+++ b/perl6-detect.el
@@ -0,0 +1,53 @@
+;;; perl6-detect.el --- Perl 6 detection -*- lexical-binding: t; -*-
+
+;;; Commentary:
+
+;; Yes, we are adding to `magic-mode-alist' here. Perl 6 specifies the
+;; same file extensions as Perl 5, so for those files we look at the
+;; first line of code to determine whether to call `perl6-mode'
+;; instead of `perl-mode'.
+
+;;; Code:
+
+;;;###autoload
+(add-to-list 'interpreter-mode-alist '("perl6" . perl6-mode))
+
+;;;###autoload
+(add-to-list 'auto-mode-alist '("\\.p[lm]?6\\'" . perl6-mode))
+
+;;;###autoload
+(defvar perl6-magic-pattern
+ (rx line-start
+ (0+ space)
+ (or (and "use" (0+ space) "v6")
+ (and (opt (and (or "my" "our") (1+ space)))
+ (or "module" "class" "role" "grammar" "enum" "slang"
"subset")))))
+
+;;;###autoload
+(defun perl6-magic-matcher ()
+ "Return non-nil if the current buffer is probably a Perl 6 file."
+ (let ((case-fold-search nil))
+ (when (and (stringp buffer-file-name)
+ (string-match "\\.\\(?:t\\|p[lm]\\)\\'" buffer-file-name))
+ (let ((keep-going t)
+ (found-perl6 nil)
+ (max-pos (min 4096 (point-max))))
+ (while (and (< (point) max-pos)
+ keep-going)
+ (if (looking-at "^ *\\(?:#.*\\)?$")
+ (beginning-of-line 2)
+ (setq keep-going nil
+ found-perl6 (looking-at perl6-magic-pattern))))
+ found-perl6))))
+
+;;;###autoload
+(add-to-list 'magic-mode-alist '(perl6-magic-matcher . perl6-mode))
+
+(provide 'perl6-detect)
+
+;; Local Variables:
+;; coding: utf-8
+;; indent-tabs-mode: nil
+;; End:
+
+;;; perl6-detect.el ends here
diff --git a/perl6-mode.el b/perl6-mode.el
index 6b957d7a6e..333c38b9eb 100644
--- a/perl6-mode.el
+++ b/perl6-mode.el
@@ -38,6 +38,7 @@
:prefix "perl6-"
:group 'language)
+(require 'perl6-detect)
(require 'perl6-font-lock)
;;;###autoload
@@ -52,40 +53,6 @@
(setq-local comment-use-syntax t)
(setq-local comment-end ""))
-;;;###autoload
-(add-to-list 'interpreter-mode-alist '("perl6" . perl6-mode))
-
-;;;###autoload
-(add-to-list 'auto-mode-alist '("\\.p[lm]?6\\'" . perl6-mode))
-
-;;;###autoload
-(defvar perl6-magic-pattern
- (rx line-start
- (0+ space)
- (or (and "use" (0+ space) "v6")
- (and (opt (and (or "my" "our") (1+ space)))
- (or "module" "class" "role" "grammar" "enum" "slang"
"subset")))))
-
-;;;###autoload
-(defun perl6-magic-matcher ()
- "Return non-nil if the current buffer is probably a Perl 6 file."
- (let ((case-fold-search nil))
- (when (and (stringp buffer-file-name)
- (string-match "\\.\\(?:t\\|p[lm]\\)\\'" buffer-file-name))
- (let ((keep-going t)
- (found-perl6 nil)
- (max-pos (min 4096 (point-max))))
- (while (and (< (point) max-pos)
- keep-going)
- (if (looking-at "^ *\\(?:#.*\\)?$")
- (beginning-of-line 2)
- (setq keep-going nil
- found-perl6 (looking-at perl6-magic-pattern))))
- found-perl6))))
-
-;;;###autoload
-(add-to-list 'magic-mode-alist '(perl6-magic-matcher . perl6-mode))
-
(provide 'perl6-mode)
;; Local Variables:
- [nongnu] elpa/raku-mode 5f885f4961 177/253: There's no need to install this, (continued)
- [nongnu] elpa/raku-mode 5f885f4961 177/253: There's no need to install this, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode f6dcbaf9a4 190/253: Add raku exec path to customization group, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 3d43b91d82 209/253: Add syntax highlighting to REPL., ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode e0639c89a3 230/253: Merge pull request #35 from tmtvl/24-highlight-pod-the-same-as-comments, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 4ed7c06294 200/253: also detect '.rakutest' extension, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode b6a5535e27 219/253: Merge pull request #29 from tmtvl/auto-insert-skeletons, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 8a6e17f174 234/253: Merge pull request #41 from anquegi/master, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 6fa383e25f 003/253: More robust magic matching of Perl 6 code, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode ce3ef00b82 026/253: Syntax propertize <quoted words>, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 3cf62b8383 002/253: Only check if .t/.pl/.pm files contain Perl 6 code, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 1b0698744b 015/253: Move Perl 6 detection into perl6-detect.el,
ELPA Syncer <=
- [nongnu] elpa/raku-mode 2f3b6f5eec 039/253: Remvoe superfluous space, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 1a7cb03101 050/253: Slight change in wording, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 4b8f5150d6 063/253: Break line in two, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 44c6e42d56 044/253: Highlight basic punctuation/match variables, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode eb32e01386 045/253: Correctly highilight version literal ranges, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode d2dfe7031c 073/253: Don't apply punctuation syntax to all set operators, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode e7e04422d0 052/253: Don't bug me with email notifications, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode 4ec31b6904 070/253: Highlight number literals with an explicit base, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode a01e71cde7 081/253: Avoid highlighting numbers and type constraints in strings/comments, ELPA Syncer, 2022/01/29
- [nongnu] elpa/raku-mode b7f95283e2 115/253: Remove redundant reduce operator highlighting, ELPA Syncer, 2022/01/29