From: Chong Yidong <cyd@stupidchicken.com>
To: Juri Linkov <juri@jurta.org>
Cc: Lars Magne Ingebrigtsen <larsi@gnus.org>,
9044@debbugs.gnu.org, Peter Dyballa <Peter_Dyballa@freenet.de>
Subject: bug#9044: 24.0.50; File mode specification error: (error "Malformed -*- line")
Date: Sat, 17 Sep 2011 17:58:37 -0400 [thread overview]
Message-ID: <87obyiygoi.fsf@stupidchicken.com> (raw)
In-Reply-To: <87sjnwd537.fsf@mail.jurta.org> (Juri Linkov's message of "Fri, 16 Sep 2011 15:50:04 +0300")
Juri Linkov <juri@jurta.org> writes:
>> How about just adding the common ones -- jpeg?, tiff?, png, gif. That
>> will take care of 99% of the problems.
>
> There are many other binary formats that may contain "-*-" in the
> first line. For example, it's impossible to visit TGA files in Emacs
> because they contain a lot of "-*-".
I propose two fixes: (1) Adding some common image types to
inhibit-first-line-modes-regexps, and (2) changing
hack-local-variables-prop-line to return nil instead of signalling an
error for the "Malformed mode line" case.
Does anyone see a problem with this approach (in particular (2))?
=== modified file 'lisp/files.el'
*** lisp/files.el 2011-09-12 20:45:56 +0000
--- lisp/files.el 2011-09-17 21:56:13 +0000
***************
*** 2461,2467 ****
See also `auto-mode-alist'.")
! (defvar inhibit-first-line-modes-regexps (mapcar 'purecopy '("\\.tar\\'" "\\.tgz\\'"))
"List of regexps; if one matches a file name, don't look for `-*-'.")
(defvar inhibit-first-line-modes-suffixes nil
--- 2461,2469 ----
See also `auto-mode-alist'.")
! (defvar inhibit-first-line-modes-regexps
! (mapcar 'purecopy '("\\.tar\\'" "\\.tgz\\'" "\\.tiff?\\'"
! "\\.gif\\'" "\\.png\\'" "\\.jpe?g\\'"))
"List of regexps; if one matches a file name, don't look for `-*-'.")
(defvar inhibit-first-line-modes-suffixes nil
***************
*** 2952,2961 ****
and VAL is the specified value. Ignores any specification for
`mode:' and `coding:' (which should have already been handled
by `set-auto-mode' and `set-auto-coding', respectively).
! Throws an error if the -*- line is malformed.
If MODE-ONLY is non-nil, just returns the symbol specifying the
mode, if there is one, otherwise nil."
(save-excursion
(goto-char (point-min))
(let ((end (set-auto-mode-1))
--- 2954,2964 ----
and VAL is the specified value. Ignores any specification for
`mode:' and `coding:' (which should have already been handled
by `set-auto-mode' and `set-auto-coding', respectively).
! Return nil if the -*- line is malformed.
If MODE-ONLY is non-nil, just returns the symbol specifying the
mode, if there is one, otherwise nil."
+ (catch 'fail
(save-excursion
(goto-char (point-min))
(let ((end (set-auto-mode-1))
***************
*** 2974,2981 ****
(while (and (or (not mode-only)
(not result))
(< (point) end))
! (or (looking-at "[ \t]*\\([^ \t\n:]+\\)[ \t]*:[ \t]*")
! (error "Malformed -*- line"))
(goto-char (match-end 0))
;; There used to be a downcase here,
;; but the manual didn't say so,
--- 2977,2985 ----
(while (and (or (not mode-only)
(not result))
(< (point) end))
! (unless (looking-at "[ \t]*\\([^ \t\n:]+\\)[ \t]*:[ \t]*")
! (message "Malformed mode-line")
! (throw 'fail nil))
(goto-char (match-end 0))
;; There used to be a downcase here,
;; but the manual didn't say so,
***************
*** 3005,3011 ****
val) result)
(error nil))))
(skip-chars-forward " \t;")))
! result)))))
(defun hack-local-variables-filter (variables dir-name)
"Filter local variable settings, querying the user if necessary.
--- 3009,3015 ----
val) result)
(error nil))))
(skip-chars-forward " \t;")))
! result))))))
(defun hack-local-variables-filter (variables dir-name)
"Filter local variable settings, querying the user if necessary.
next prev parent reply other threads:[~2011-09-17 21:58 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-10 23:36 bug#9044: 24.0.50; File mode specification error: (error "Malformed -*- line") Peter Dyballa
2011-07-12 21:53 ` Glenn Morris
2011-07-12 23:27 ` Peter Dyballa
2011-07-13 0:01 ` Glenn Morris
2011-09-11 3:24 ` Lars Magne Ingebrigtsen
2011-09-15 18:37 ` Juri Linkov
2011-09-15 20:03 ` Stefan Monnier
2011-09-16 1:58 ` Lars Magne Ingebrigtsen
2011-09-16 12:50 ` Juri Linkov
2011-09-17 5:06 ` Lars Magne Ingebrigtsen
2011-09-17 12:48 ` Juri Linkov
2011-09-18 7:49 ` Lars Magne Ingebrigtsen
2011-09-17 21:58 ` Chong Yidong [this message]
2011-09-18 7:50 ` Lars Magne Ingebrigtsen
2011-09-18 19:28 ` Juri Linkov
2011-09-18 20:50 ` Juri Linkov
2011-09-19 13:06 ` Stefan Monnier
2011-09-19 14:18 ` Juri Linkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87obyiygoi.fsf@stupidchicken.com \
--to=cyd@stupidchicken.com \
--cc=9044@debbugs.gnu.org \
--cc=Peter_Dyballa@freenet.de \
--cc=juri@jurta.org \
--cc=larsi@gnus.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).