branch: elpa/raku-mode commit 2257deb15abf31e3e135744ba23e7fd2d36676d6 Author: Hinrik Örn Sigurðsson <hinrik....@gmail.com> Commit: Hinrik Örn Sigurðsson <hinrik....@gmail.com>
Simplify the magic matching logic --- perl6-mode.el | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/perl6-mode.el b/perl6-mode.el index 0580f5c4f2..95a6817d77 100644 --- a/perl6-mode.el +++ b/perl6-mode.el @@ -70,23 +70,18 @@ (defun perl6-magic-matcher () "Return non-nil if the current buffer is probably a Perl 6 file." (let ((case-fold-search nil)) - (and (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 keep-going - (cond ((>= (point) max-pos) - (setq keep-going nil)) - ((looking-at "^ *\\(?:#.*\\)?$") - nil) - ((looking-at perl6-magic-pattern) - (setq keep-going nil - found-perl6 t)) - (t - (setq keep-going nil))) - (beginning-of-line 2)) - found-perl6)))) + (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))