emacs-pretest-bug
[Top][All Lists]
Advanced

[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: Kim F. Storm
Subject: Re: python-mode.el doesn't associate python-mode with .PY files
Date: Wed, 27 Dec 2006 21:35:44 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.92 (gnu/linux)

Stefan Monnier <address@hidden> writes:

> It's at the very best a misfeature.  Far from a feature.
> See sample patch below to fix this problem.

This code is exactly what we need!

It is simple, localized, easy to document, and have no really severe
effects if it guesses wrong - as the worst effect of a wrong choice is
to not to enter fundamental-mode (which is usually pretty useless).

In contrast, the "recognize images by file contents" approach has already
required three rounds of bug-fixing ... and there's no guarantee that there
are not more "surprises"...

I strongly support installing this, _and_ reverting the recent image-mode 
related
patches which would no longer be needed with this patch.

>
>
>         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)))))))))

-- 
Kim F. Storm <address@hidden> http://www.cua.dk





reply via email to

[Prev in Thread] Current Thread [Next in Thread]