diff --git a/lisp/emacs-lisp/package-activate.el b/lisp/emacs-lisp/package-activate.el index cc73860708d..3965906f5d8 100644 --- a/lisp/emacs-lisp/package-activate.el +++ b/lisp/emacs-lisp/package-activate.el @@ -588,7 +588,7 @@ what command to invoke to enable the package." `(,(pred package-installed-p) . ,_)) nil) (`(,_ auto-mode-alist ,ext . ,_) - (and (string-match-p ext (buffer-name)) t)) + (and (buffer-file-name) (string-match-p ext (buffer-file-name)) t)) (`(,_ magic-mode-alist ,mag . ,_) (without-restriction (save-excursion