summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorStefan Kangas <stefankangas@gmail.com>2024-09-26 17:04:31 +0200
committerStefan Kangas <stefankangas@gmail.com>2024-09-26 17:04:31 +0200
commit2f485e68ff96cc66a17df2c0a58e272bbfc24765 (patch)
tree858d7b180caa24365c8b578d16971913b00870df /lisp
parent4c567892e044ada0e09889ec520fefa07f52b20b (diff)
Add Python "*.pth" files to auto-mode-alist
* lisp/progmodes/python.el (python--auto-mode-alist-regexp): New variable. (auto-mode-alist, python-ts-mode): Use above new variable.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/progmodes/python.el11
1 files changed, 9 insertions, 2 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 6a258892f16..cfa71fc3a74 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -293,8 +293,15 @@
(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))
@@ -7208,7 +7215,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))