]> git.eshelyaron.com Git - emacs.git/commitdiff
Add Python "*.pth" files to auto-mode-alist
authorStefan Kangas <stefankangas@gmail.com>
Thu, 26 Sep 2024 15:04:31 +0000 (17:04 +0200)
committerEshel Yaron <me@eshelyaron.com>
Fri, 27 Sep 2024 10:23:21 +0000 (12:23 +0200)
* lisp/progmodes/python.el (python--auto-mode-alist-regexp): New
variable.
(auto-mode-alist, python-ts-mode): Use above new variable.

(cherry picked from commit 2f485e68ff96cc66a17df2c0a58e272bbfc24765)

lisp/progmodes/python.el

index 7ee45b4bb7c523e0569f2878355a62898748b210..8b69d0b3a7402b35d583f1595a819f0babacf0cc 100644 (file)
 (autoload 'comint-mode "comint")
 (autoload 'help-function-arglist "help-fns")
 
+(defconst python--auto-mode-alist-regexp
+  (rx "." (or "py"
+              "pth"                     ; Python Path Configuration File
+              "pyi"                     ; Python Stub File (PEP 484)
+              "pyw")                    ; MS-Windows specific extension
+      eos))
+
 ;;;###autoload
-(add-to-list 'auto-mode-alist (cons (purecopy "\\.py[iw]?\\'") 'python-mode))
+(add-to-list 'auto-mode-alist (cons python--auto-mode-alist-regexp 'python-mode))
 ;;;###autoload
 (add-to-list 'interpreter-mode-alist (cons (purecopy "python[0-9.]*") 'python-mode))
 
@@ -7199,7 +7206,7 @@ implementations: `python-mode' and `python-ts-mode'."
     (when python-indent-guess-indent-offset
       (python-indent-guess-indent-offset))
 
-    (add-to-list 'auto-mode-alist '("\\.py[iw]?\\'" . python-ts-mode))
+    (add-to-list 'auto-mode-alist '(python--auto-mode-alist-regexp . python-ts-mode))
     (add-to-list 'interpreter-mode-alist '("python[0-9.]*" . python-ts-mode))))
 
 (derived-mode-add-parents 'python-ts-mode '(python-mode))