[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: python-mode.el doesn't associate python-mode with .PY files
From: |
Stefan Monnier |
Subject: |
Re: python-mode.el doesn't associate python-mode with .PY files |
Date: |
Wed, 27 Dec 2006 11:01:32 -0500 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.91 (gnu/linux) |
>> I'm browsing some old Python sources on a CD, and they're all opening
>> in fundamental-mode instead of python-mode.
>>
>> All the filenames on the CD are in uppercase.
>>
>> Perhaps python-mode.el could be modified to recognise .PY files as
>> well as .py files as containing Python code?
> That's not a bug, that's a feature! But you can work around it in your
> ~/.emacs:
> (setq auto-mode-alist
> (cons '("\\.PY\\'" . python-mode) auto-mode-alist))
It's at the very best a misfeature. Far from a feature.
See sample patch below to fix this problem.
Stefan
--- orig/lisp/files.el
+++ mod/lisp/files.el
@@ -2234,15 +2234,22 @@
(setq name (file-name-sans-versions name))
(while name
;; Find first matching alist entry.
- (let ((case-fold-search
- (memq system-type '(vax-vms windows-nt cygwin))))
- (if (and (setq mode (assoc-default name auto-mode-alist
- 'string-match))
- (consp mode)
- (cadr mode))
- (setq mode (car mode)
- name (substring name 0 (match-beginning 0)))
- (setq name)))
+ (if (and (setq mode
+ (or (unless (memq system-type '(vax-vms
windows-nt cygwin))
+ ;; First match case-sensitively if the
+ ;; system is case-sensitive.
+ (let ((case-fold-search nil))
+ (assoc-default name auto-mode-alist
+ 'string-match)))
+ ;; Fallback to case-insensitive match.
+ (let ((case-fold-search t))
+ (assoc-default name auto-mode-alist
+ 'string-match))))
+ (consp mode)
+ (cadr mode))
+ (setq mode (car mode)
+ name (substring name 0 (match-beginning 0)))
+ (setq name))
(when mode
(set-auto-mode-0 mode keep-mode-if-same)))))))))
- python-mode.el doesn't associate python-mode with .PY files, Chris Moore, 2006/12/22
- Re: python-mode.el doesn't associate python-mode with .PY files, Kevin Rodgers, 2006/12/27
- Re: python-mode.el doesn't associate python-mode with .PY files,
Stefan Monnier <=
- Re: python-mode.el doesn't associate python-mode with .PY files, Kim F. Storm, 2006/12/27
- Re: python-mode.el doesn't associate python-mode with .PY files, Juanma Barranquero, 2006/12/27
- Re: python-mode.el doesn't associate python-mode with .PY files, Juanma Barranquero, 2006/12/28
- Re: python-mode.el doesn't associate python-mode with .PY files, Richard Stallman, 2006/12/29
- Re: python-mode.el doesn't associate python-mode with .PY files, Juanma Barranquero, 2006/12/29
- Re: python-mode.el doesn't associate python-mode with .PY files, Kim F. Storm, 2006/12/28
- Re: python-mode.el doesn't associate python-mode with .PY files, Juanma Barranquero, 2006/12/28
- Re: python-mode.el doesn't associate python-mode with .PY files, Juanma Barranquero, 2006/12/28
- Re: python-mode.el doesn't associate python-mode with .PY files, Richard Stallman, 2006/12/29
- Re: python-mode.el doesn't associate python-mode with .PY files, Richard Stallman, 2006/12/28