Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

"Text is read-only"... except it isn't... or shouldn't be

31 views
Skip to first unread message

ken

unread,
May 13, 2013, 5:47:46 AM5/13/13
to help-gn...@gnu.org
A file which I've been opening in emacs and editing for a few years in
emacs suddenly with emacs version 22.1.1 became read-only. I open it,
can navigate around in it (though the cursor/mark isn't visible), but
when I try to edit it, I'm not allowed. I get a message in the
minibuffer saying, "Text is read-only". The beginning of the modeline
is "-u: --". I can open this same file in vi and edit it (as the same
user) without any problem at all. I don't have this problem with any
other file I edit in emacs, just this one. The OS is linux, kernel
version 2.6.18.384, and the permissions for this file are 664 and I am
the owner of the file. If I change (i.e., mv) the name of the file to
something else, emacs behaves normally and lets me edit the file just
like any other file. So I'm pretty sure that the problem is that emacs
has a problem with the file name and thinks I shouldn't be allowed to
edit it. How do I turn this behavior off?

thanks much.



Eli Zaretskii

unread,
May 13, 2013, 12:13:58 PM5/13/13
to help-gn...@gnu.org
> Date: Mon, 13 May 2013 05:47:46 -0400
> From: ken <geb...@mousecar.com>
What does Emacs say if you type this:

M-: major-mode RET

in the buffer that visits this file you aren't allowed to edit?

ken

unread,
May 13, 2013, 12:51:55 PM5/13/13
to Eli Zaretskii, help-gn...@gnu.org
image-mode

ken

unread,
May 13, 2013, 1:59:52 PM5/13/13
to help-gn...@gnu.org
If I do "M-x text-mode", it's still not possible to edit the file... I
still get the message "Text is read-only".


Eli Zaretskii

unread,
May 13, 2013, 1:08:47 PM5/13/13
to help-gn...@gnu.org
> Date: Mon, 13 May 2013 12:51:55 -0400
> From: ken <geb...@mousecar.com>
> CC: help-gn...@gnu.org
>
>
> > What does Emacs say if you type this:
> >
> > M-: major-mode RET
> >
> > in the buffer that visits this file you aren't allowed to edit?
> >
>
> image-mode

That explains everything, doesn't it? Your file has a file-name
extension that matches some image file, so Emacs enters the Image mode
for it, and doesn't let you edit images (because image-editing
capabilities are not yet part of Emacs).

Solution: remove that extension from auto-mode-alist, and Bob's your
uncle.

Eli Zaretskii

unread,
May 13, 2013, 2:10:04 PM5/13/13
to help-gn...@gnu.org
> Date: Mon, 13 May 2013 13:59:52 -0400
> From: ken <geb...@mousecar.com>
> CC: Eli Zaretskii <el...@gnu.org>
>
> >> What does Emacs say if you type this:
> >>
> >> M-: major-mode RET
> >>
> >> in the buffer that visits this file you aren't allowed to edit?
> >>
> >
> > image-mode
>
> If I do "M-x text-mode", it's still not possible to edit the file... I
> still get the message "Text is read-only".

What is the name of that file?

Bob Proulx

unread,
May 13, 2013, 2:15:14 PM5/13/13
to help-gn...@gnu.org
ken wrote:
> If I do "M-x text-mode", it's still not possible to edit the file...
> I still get the message "Text is read-only".

Use:

C-x C-q

Which means:

C-x C-q runs the command read-only-mode
Change whether the current buffer is read-only.

Good for an individual one-off named file that you don't normally want
to edit.

Bob

ken

unread,
May 13, 2013, 10:26:01 PM5/13/13
to help-gn...@gnu.org
This puts the buffer *into* read-only mode but doing the same again
doesn't toggle out of it. This isn't how the documentation says it's
supposed to work, but that's what happens.


ken

unread,
May 13, 2013, 10:34:34 PM5/13/13
to Eli Zaretskii, help-gn...@gnu.org


On 05/13/2013 01:08 PM Eli Zaretskii wrote:
>> Date: Mon, 13 May 2013 12:51:55 -0400
>> From: ken <geb...@mousecar.com>
>> CC: help-gn...@gnu.org
>>
>>
>>> What does Emacs say if you type this:
>>>
>>> M-: major-mode RET
>>>
>>> in the buffer that visits this file you aren't allowed to edit?
>>>
>>
>> image-mode
>
> That explains everything, doesn't it? Your file has a file-name
> extension that matches some image file, so Emacs enters the Image mode
> for it, and doesn't let you edit images (because image-editing
> capabilities are not yet part of Emacs).
>
> Solution: remove that extension from auto-mode-alist, and Bob's your
> uncle.

Cool. That's what I want. So I guess I put something in ~/.emacs...
but what?


Barry Margolin

unread,
May 13, 2013, 10:38:14 PM5/13/13
to
In article <mailman.25692.1368498...@gnu.org>,
It does in most buffers. There's something weird going on in that
particular buffer. It sounds like it's setting read-only text properties
on parts of the buffer -- is that part of image editing mode?

--
Barry Margolin, bar...@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***

Eli Zaretskii

unread,
May 14, 2013, 2:46:32 AM5/14/13
to help-gn...@gnu.org
> Date: Mon, 13 May 2013 22:34:34 -0400
> > That explains everything, doesn't it? Your file has a file-name
> > extension that matches some image file, so Emacs enters the Image mode
> > for it, and doesn't let you edit images (because image-editing
> > capabilities are not yet part of Emacs).
> >
> > Solution: remove that extension from auto-mode-alist, and Bob's your
> > uncle.
>
> Cool. That's what I want. So I guess I put something in ~/.emacs...
> but what?

I don't know what is the file-name extension of that file, so I cannot
give a precise recipe. Assuming for a moment that its extension is
.png, I see that auto-mode-alist includes this element:

("\\.png\\'" . image-mode)

So to remove this, you need to do this:

(delete '("\\.png\\'" . image-mode) auto-mode-alist)

Peter Dyballa

unread,
May 14, 2013, 4:59:18 AM5/14/13
to Eli Zaretskii, ken, help-gn...@gnu.org

Am 14.05.2013 um 08:46 schrieb Eli Zaretskii:

>>> Solution: remove that extension from auto-mode-alist, and Bob's your
>>> uncle.
>>
>> Cool. That's what I want. So I guess I put something in ~/.emacs...
>> but what?
>
> I don't know what is the file-name extension of that file, so I cannot
> give a precise recipe. Assuming for a moment that its extension is
> .png, I see that auto-mode-alist includes this element:
>
> ("\\.png\\'" . image-mode)
>
> So to remove this, you need to do this:
>
> (delete '("\\.png\\'" . image-mode) auto-mode-alist)

Since this removes all image support from PNG (or the actual type of) files it might be more useful to either rename the file temporarily or to create a link with an extension like .txt and edit that link.

--
Greetings

Pete

If you don't find it in the index, look very carefully through the entire catalogue.
– Sears, Roebuck, and Co., Consumer's Guide, 1897


ken

unread,
May 14, 2013, 7:58:38 AM5/14/13
to Eli Zaretskii, help-gn...@gnu.org
On 05/14/2013 02:46 AM Eli Zaretskii wrote:
>> Date: Mon, 13 May 2013 22:34:34 -0400
>> From: ken <geb...@mousecar.com>
>> CC: help-gn...@gnu.org
>>
>>> That explains everything, doesn't it? Your file has a file-name
>>> extension that matches some image file, so Emacs enters the Image mode
>>> for it, and doesn't let you edit images (because image-editing
>>> capabilities are not yet part of Emacs).
>>>
>>> Solution: remove that extension from auto-mode-alist, and Bob's your
>>> uncle.
>>
>> Cool. That's what I want. So I guess I put something in ~/.emacs...
>> but what?
>
> I don't know what is the file-name extension of that file, so I cannot
> give a precise recipe. Assuming for a moment that its extension is
> .png, I see that auto-mode-alist includes this element:
>
> ("\\.png\\'" . image-mode)
>
> So to remove this, you need to do this:
>
> (delete '("\\.png\\'" . image-mode) auto-mode-alist)
>

Thanks. That worked.

ken

unread,
May 14, 2013, 8:22:00 AM5/14/13
to Peter Dyballa, help-gn...@gnu.org
On 05/14/2013 04:59 AM Peter Dyballa wrote:
>
> Am 14.05.2013 um 08:46 schrieb Eli Zaretskii:
>
>>>> Solution: remove that extension from auto-mode-alist, and Bob's
>>>> your uncle.
>>>
>>> Cool. That's what I want. So I guess I put something in
>>> ~/.emacs... but what?
>>
>> I don't know what is the file-name extension of that file, so I
>> cannot give a precise recipe. Assuming for a moment that its
>> extension is .png, I see that auto-mode-alist includes this
>> element:
>>
>> ("\\.png\\'" . image-mode)
>>
>> So to remove this, you need to do this:
>>
>> (delete '("\\.png\\'" . image-mode) auto-mode-alist)
>
> Since this removes all image support from PNG (or the actual type of)
> files it might be more useful to either rename the file temporarily
> or to create a link with an extension like .txt and edit that link.

Yeah, I thought about all that. As I said in my original post though,
I've been happily editing this file with this name for years. I would
sooner switch to using vi on it than to change the file's name in any
way. Second and more importantly, I don't care for the Windozy attitude
toward users, treating then like idiots and upon that rationale, taking
control away from users, or their overly simplistic strategy for
determining a file type merely by looking at the filename extension,
especially when this can be more suitably and accurately and
intelligently accomplished by determining a file's magic number as the
Linux "file" utility does.


Eli Zaretskii

unread,
May 14, 2013, 9:39:21 AM5/14/13
to help-gn...@gnu.org
> Date: Tue, 14 May 2013 08:22:00 -0400
> From: ken <geb...@mousecar.com>
> CC: Eli Zaretskii <el...@gnu.org>, help-gn...@gnu.org
>
> [...] overly simplistic strategy for determining a file type merely
> by looking at the filename extension, especially when this can be
> more suitably and accurately and intelligently accomplished by
> determining a file's magic number as the Linux "file" utility does.

Emacs does look at the magic signature, see magic-mode-alist.

ken

unread,
May 14, 2013, 4:39:59 PM5/14/13
to Eli Zaretskii, help-gn...@gnu.org
They why didn't it see that my file was (obviously) a text file and not
an image file?


Eli Zaretskii

unread,
May 14, 2013, 4:42:00 PM5/14/13
to help-gn...@gnu.org
> Date: Tue, 14 May 2013 16:39:59 -0400
> From: ken <geb...@mousecar.com>
> CC: help-gn...@gnu.org
I have no idea, and won't have one, unless you disclose the name of
that file.

Jai Dayal

unread,
May 14, 2013, 4:45:01 PM5/14/13
to Eli Zaretskii, help-gnu-emacs
How do I unsubscribe to this trivial list

ken

unread,
May 14, 2013, 5:36:11 PM5/14/13
to Eli Zaretskii, help-gn...@gnu.org
On 05/14/2013 04:42 PM Eli Zaretskii wrote:
>> Date: Tue, 14 May 2013 16:39:59 -0400
>> From: ken <geb...@mousecar.com>
>> CC: help-gn...@gnu.org
>>
>> On 05/14/2013 09:39 AM Eli Zaretskii wrote:
>>>> Date: Tue, 14 May 2013 08:22:00 -0400
>>>> From: ken <geb...@mousecar.com>
>>>> CC: Eli Zaretskii <el...@gnu.org>, help-gn...@gnu.org
>>>>
>>>> [...] overly simplistic strategy for determining a file type merely
>>>> by looking at the filename extension, especially when this can be
>>>> more suitably and accurately and intelligently accomplished by
>>>> determining a file's magic number as the Linux "file" utility does.
>>>
>>> Emacs does look at the magic signature, see magic-mode-alist.
>>>
>>
>> They why didn't it see that my file was (obviously) a text file and not
>> an image file?
>
> I have no idea, and won't have one, unless you disclose the name of
> that file.
>

list.gif

Would it make a difference if the basename (without the extension) were
named something else?


Óscar Fuentes

unread,
May 14, 2013, 5:39:19 PM5/14/13
to Jai Dayal, help-gnu-emacs
Jai Dayal <daya...@gmail.com> writes:

> How do I unsubscribe to this trivial list

See the bottom of this page:

https://lists.gnu.org/mailman/listinfo/help-gnu-emacs

You are served.

Bob Proulx

unread,
May 14, 2013, 7:23:49 PM5/14/13
to help-gnu-emacs
Jai Dayal wrote:
> How do I unsubscribe to this trivial list

You would unsubscribe by the same method you used to subscribe. If
you had emailed help-gnu-em...@gnu.org with a "subscribe"
commend then email it again with "unsubscribe" command. If you used
the web interface before then use the web interface again.

https://lists.gnu.org/mailman/listinfo/help-gnu-emacs

I tend not to like the web interface because it is so far removed
from email that people forget how they did it. At least with email
the control addresses can be derived from knowing the main mailing
list address.

In addition every mailing list message includes this information in
the headers. The List-* headers are standard and every mailing list
includes them.

List-Id: Users list for the GNU Emacs text editor <help-gnu-emacs.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/help-gnu-emacs>,
<mailto:help-gnu-em...@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/help-gnu-emacs>
List-Post: <mailto:help-gn...@gnu.org>
List-Help: <mailto:help-gnu-em...@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/help-gnu-emacs>,
<mailto:help-gnu-em...@gnu.org?subject=subscribe>

If all else fails then write to the mailing list admins and ask for
assistance. The humans who run mailing lists can be found by
appending -OWNER to the end of the mailing list address.

help-gnu-e...@gnu.org

Bob

Jai Dayal

unread,
May 14, 2013, 10:16:59 PM5/14/13
to help-gnu-emacs
There are no headers for me. Emacs users make erroneous assumptions again!!

Kevin Rodgers

unread,
May 15, 2013, 1:17:44 AM5/15/13
to help-gn...@gnu.org
On 5/14/13 2:39 PM, ken wrote:
> On 05/14/2013 09:39 AM Eli Zaretskii wrote:
>>> Date: Tue, 14 May 2013 08:22:00 -0400
>>> From: ken <geb...@mousecar.com>
>>> CC: Eli Zaretskii <el...@gnu.org>, help-gn...@gnu.org
>>>
>>> [...] overly simplistic strategy for determining a file type merely
>>> by looking at the filename extension, especially when this can be
>>> more suitably and accurately and intelligently accomplished by
>>> determining a file's magic number as the Linux "file" utility does.
>>
>> Emacs does look at the magic signature, see magic-mode-alist.
>>
>
> They why didn't it see that my file was (obviously) a text file and not an image
> file?

1. Because the default value of magic-mode-alist is nil.

2. Because the default value of auto-mode-alist matches the ".gif" extension.

3. Because it is not obvious what the signature is for a text file -- perhaps
something like "\\`[[:print:]\t\f\r\n]", which is so general that it would
prevent most of the existing automatic method from working.

See the "Choosing Modes" section of the Emacs manual.

--
Kevin Rodgers
Denver, Colorado, USA


Eli Zaretskii

unread,
May 15, 2013, 3:23:42 AM5/15/13
to help-gn...@gnu.org
> From: Jai Dayal <daya...@gmail.com>
> Date: Tue, 14 May 2013 19:16:59 -0700
>
> There are no headers for me. Emacs users make erroneous assumptions again!!

There always are. You just probably don't know how to display them in
whatever email client you are using. The only assumption was that you
do know that.


Eli Zaretskii

unread,
May 15, 2013, 3:28:55 AM5/15/13
to help-gn...@gnu.org
> From: Kevin Rodgers <kevin.d...@gmail.com>
> Date: Tue, 14 May 2013 23:17:44 -0600
>
> 1. Because the default value of magic-mode-alist is nil.
>
> 2. Because the default value of auto-mode-alist matches the ".gif" extension.
>
> 3. Because it is not obvious what the signature is for a text file -- perhaps
> something like "\\`[[:print:]\t\f\r\n]", which is so general that it would
> prevent most of the existing automatic method from working.
>
> See the "Choosing Modes" section of the Emacs manual.

If the request is that any *.gif file whose signature doesn't match be
rejected by image-mode, then I suggest to file a feature request bug
using "M-x report-emacs-bug RET".

ken

unread,
May 15, 2013, 7:48:19 AM5/15/13
to Kevin Rodgers, help-gn...@gnu.org
On 05/15/2013 01:17 AM Kevin Rodgers wrote:
> On 5/14/13 2:39 PM, ken wrote:
>> On 05/14/2013 09:39 AM Eli Zaretskii wrote:
>>>> Date: Tue, 14 May 2013 08:22:00 -0400
>>>> From: ken <geb...@mousecar.com>
>>>> CC: Eli Zaretskii <el...@gnu.org>, help-gn...@gnu.org
>>>>
>>>> [...] overly simplistic strategy for determining a file type merely
>>>> by looking at the filename extension, especially when this can be
>>>> more suitably and accurately and intelligently accomplished by
>>>> determining a file's magic number as the Linux "file" utility does.
>>>
>>> Emacs does look at the magic signature, see magic-mode-alist.
>>>
>>
>> They why didn't it see that my file was (obviously) a text file and
>> not an image
>> file?
>
> 1. Because the default value of magic-mode-alist is nil.

If you mean this functionality was turned off in this version I recently
installed, then, yes, that agrees with what I said earlier in this
thread: emacs no longer determines a file's magic upon visiting a file.
The more comprehensive fix, then, would be to set magic-mode-alist to
t, yes? If so, what elisp statement(s) do you think would best
accomplish that?


>
> 2. Because the default value of auto-mode-alist matches the ".gif"
> extension.

The documentation suggests that magic-mode-alist, if turned on, will
override auto-mode-alist.


>
> 3. Because it is not obvious what the signature is for a text file --
> perhaps
> something like "\\`[[:print:]\t\f\r\n]", which is so general that it
> would
> prevent most of the existing automatic method from working.

Yes, the damned humans with their writing so random and the different
languages characters and syntaxes and punctuation etc. make such
evaluation nigh impossible. Probably for this reason, magic mode adopts
a different strategy. The linux "file" utility, referred to earlier in
this thread, probably does this also, as it makes fairly reliable
evaluations of files' contents.


ken

unread,
May 15, 2013, 7:56:01 AM5/15/13
to Eli Zaretskii, help-gn...@gnu.org
On 05/15/2013 03:28 AM Eli Zaretskii wrote:
>> From: Kevin Rodgers <kevin.d...@gmail.com>
>> Date: Tue, 14 May 2013 23:17:44 -0600
>>
>> ....
>
> If the request is that any *.gif file whose signature doesn't match be
> rejected by image-mode, then I suggest to file a feature request bug
> using "M-x report-emacs-bug RET".
>

As said earlier, this problem first appeared after my last emacs
upgrade, and this after editing this same file for, perhaps ten, perhaps
more years. It would seem then that someone upstream decided already
not to make magic-mode-alist the default.

Eli Zaretskii

unread,
May 15, 2013, 8:30:57 AM5/15/13
to help-gn...@gnu.org
> Date: Wed, 15 May 2013 07:56:01 -0400
> From: ken <geb...@mousecar.com>
> CC: help-gn...@gnu.org
>
> > If the request is that any *.gif file whose signature doesn't match be
> > rejected by image-mode, then I suggest to file a feature request bug
> > using "M-x report-emacs-bug RET".
> >
>
> As said earlier, this problem first appeared after my last emacs
> upgrade, and this after editing this same file for, perhaps ten, perhaps
> more years. It would seem then that someone upstream decided already
> not to make magic-mode-alist the default.

If you want this issue to be fixed, I suggest to report it as a bug.
Otherwise, you will have to hack auto-mode-alist forever. Which is
fine with me, if it suits you, because I don't have a file named
list.gif that is nowhere near a GIF image.

Jason Rumney

unread,
May 15, 2013, 11:49:36 PM5/15/13
to
On Wednesday, 15 May 2013 19:56:01 UTC+8, ken wrote:

> As said earlier, this problem first appeared after my last emacs
> upgrade

This information is meaningless without specifying which version you upgraded from.

Kevin Rodgers

unread,
May 16, 2013, 2:27:16 AM5/16/13
to help-gn...@gnu.org
On 5/15/13 5:48 AM, ken wrote:
> On 05/15/2013 01:17 AM Kevin Rodgers wrote:
>> On 5/14/13 2:39 PM, ken wrote:
>>> On 05/14/2013 09:39 AM Eli Zaretskii wrote:
>>>> Emacs does look at the magic signature, see magic-mode-alist.
>>>
>>> They why didn't it see that my file was (obviously) a text file and
>>> not an image
>>> file?
>>
>> 1. Because the default value of magic-mode-alist is nil.
>
> If you mean this functionality was turned off in this version I recently
> installed, then, yes, that agrees with what I said earlier in this thread: emacs
> no longer determines a file's magic upon visiting a file.

No, you misunderstand. After file local variables and
interpreter-mode-alist, magic-mode-alist is merely the first relevant
option that is consulted when automatically setting the major mode.
Then auto-mode-alist (which matches the file name), then
magic-fallback-mode-alist (which matches the file contents, like
magic-mode-alist, but which is not nil by default).

That is why I suggested you actually read the "Choosing Modes" section of the
Emacs manual.

Any part of that algorithm might have changed between your unnamed previous
version and the current Emacs version, probably in response to specific bug
reports and after review by the maintainers.

> The more comprehensive
> fix, then, would be to set magic-mode-alist to t, yes? If so, what elisp
> statement(s) do you think would best accomplish that?

No, t is not a valid alist.

You could remove the ".gif" entry from auto-mode-alist, and add an entry to
magic-fallback-mode-alist. According to my /usr/share/file/magic, the regexp
should be "\\`GIF8".

Here is my guess at the lisp:

(setq auto-mode-alist
(remove '("\\.gif\\'" . image-mode) auto-mode-alist))

(setq magic-fallback-mode-alist
(cons '("\\`GIF8" . image-mode) magic-fallback-mode-alist))

>> 2. Because the default value of auto-mode-alist matches the ".gif"
>> extension.
>
> The documentation suggests that magic-mode-alist, if turned on, will override
> auto-mode-alist.

More precisely: If there is an entry in magic-mode-alist that matches the
filecontents, it has precedence over auto-mode-alist.

>> 3. Because it is not obvious what the signature is for a text file --
>> perhaps
>> something like "\\`[[:print:]\t\f\r\n]", which is so general that it
>> would
>> prevent most of the existing automatic method from working.
>
> Yes, the damned humans with their writing so random and the different languages
> characters and syntaxes and punctuation etc. make such evaluation nigh
> impossible. Probably for this reason, magic mode adopts a different strategy.
> The linux "file" utility, referred to earlier in this thread, probably does this
> also, as it makes fairly reliable evaluations of files' contents.

Yes: Instead of trying to detect text files by their content, detect all the
other kinds of files by their content or name (and then default to Fundamental
mode).

ken

unread,
May 16, 2013, 7:08:57 AM5/16/13
to Kevin Rodgers, help-gn...@gnu.org
On 05/16/2013 02:27 AM Kevin Rodgers wrote:
> On 5/15/13 5:48 AM, ken wrote:
>> On 05/15/2013 01:17 AM Kevin Rodgers wrote:
>>> On 5/14/13 2:39 PM, ken wrote:
>>>> On 05/14/2013 09:39 AM Eli Zaretskii wrote:
>>>>> Emacs does look at the magic signature, see magic-mode-alist.
>>>>
>>>> ....
>
> Yes: Instead of trying to detect text files by their content, detect all
> the
> other kinds of files by their content or name (and then default to
> Fundamental
> mode).
>

So given this:

echo This is not an image file. > list.gif; emacs list.gif &

which mode should emacs invoke?

Suvayu Ali

unread,
May 16, 2013, 8:50:01 AM5/16/13
to help-gn...@gnu.org
On Tue, May 14, 2013 at 07:16:59PM -0700, Jai Dayal wrote:
> There are no headers for me. Emacs users make erroneous assumptions again!!

It seems you are using the Gmail web interface. To see the headers
click on "Show original" on the drop down menu on your top right.

--
Suvayu

Open source is the future. It sets us free.

Kevin Rodgers

unread,
May 16, 2013, 9:30:51 AM5/16/13
to help-gn...@gnu.org
If you agree with the convention that .gif files are GIF images, then
image-mode.

If you choose to violate that convention, then I suggest:

echo -e "-*- mode: Text;-*-\nThis is not an image file." > list.gif; emacs list.gif

ken

unread,
May 16, 2013, 10:23:04 AM5/16/13
to help-gn...@gnu.org, Kevin Rodgers


On 05/16/2013 07:08 AM ken wrote:
> On 05/16/2013 02:27 AM Kevin Rodgers wrote:
>> On 5/15/13 5:48 AM, ken wrote:
>>> On 05/15/2013 01:17 AM Kevin Rodgers wrote:
>>>> On 5/14/13 2:39 PM, ken wrote:
>>>>> On 05/14/2013 09:39 AM Eli Zaretskii wrote:
>>>>>> Emacs does look at the magic signature, see magic-mode-alist.
>>>>>
>>>>> ....
>>
>> Yes: Instead of trying to detect text files by their content, detect all
>> the
>> other kinds of files by their content or name (and then default to
>> Fundamental
>> mode).
>>
>
> So given this:
>
> echo This is not an image file. > list.gif; emacs list.gif &
>
> which mode should emacs invoke?
>

If this question can't be answered straightforwardly and unambiguously,
then there's really no sense in discussing code... or filing a bug
report. For how could it be determined whether the code is working or not?




ken

unread,
May 16, 2013, 10:26:30 AM5/16/13
to Kevin Rodgers, help-gn...@gnu.org


On 05/16/2013 09:30 AM Kevin Rodgers wrote:
> On 5/16/13 5:08 AM, ken wrote:
>> On 05/16/2013 02:27 AM Kevin Rodgers wrote:
>>> On 5/15/13 5:48 AM, ken wrote:
>>>> On 05/15/2013 01:17 AM Kevin Rodgers wrote:
>>>>> On 5/14/13 2:39 PM, ken wrote:
>>>>>> On 05/14/2013 09:39 AM Eli Zaretskii wrote:
>>>>>>> Emacs does look at the magic signature, see magic-mode-alist.
>>>>>>
>>>>>> ....
>>>
>>> Yes: Instead of trying to detect text files by their content, detect all
>>> the
>>> other kinds of files by their content or name (and then default to
>>> Fundamental
>>> mode).
>>>
>>
>> So given this:
>>
>> echo This is not an image file. > list.gif; emacs list.gif &
>>
>> which mode should emacs invoke?
>
> If you agree with the convention that .gif files are GIF images, then
> image-mode.
>
> If you choose to violate that convention, then I suggest:
>
> echo -e "-*- mode: Text;-*-\nThis is not an image file." > list.gif;
> emacs list.gif
>

$ echo This is not an image file. > list.gif; file list.gif
list.gif: ASCII text

Peter Dyballa

unread,
May 16, 2013, 10:39:22 AM5/16/13
to geb...@mousecar.com, help-gn...@gnu.org, Kevin Rodgers

Am 16.05.2013 um 16:26 schrieb ken:

> $ echo This is not an image file. > list.gif; file list.gif
> list.gif: ASCII text

File always reads a few bytes into the file. You can cleverly use file to suggest GNU Emacs to open your GIF file as a text file.

--
Greetings

Pete

There are very few jobs that actually require a penis or vagina. All other jobs should be open to everybody.
– Florynce Kennedy


Peter Dyballa

unread,
May 16, 2013, 10:41:42 AM5/16/13
to geb...@mousecar.com, help-gn...@gnu.org, Kevin Rodgers

Am 16.05.2013 um 16:23 schrieb ken:

>> which mode should emacs invoke?
>>
>
> If this question can't be answered straightforwardly and unambiguously, then there's really no sense in discussing code... or filing a bug report. For how could it be determined whether the code is working or not?

My collection of GNU Emacsen 22.1…24.3.50 open your GIF file in Image mode, when invoked with -Q. This is clean, reliable, and straightforward behaviour.

--
Greetings

Pete

If the majority of cooking accidents happen in the kitchen, then why don't we just cook in other rooms?


Dmitry Gutov

unread,
May 16, 2013, 10:48:33 AM5/16/13
to ken, help-gn...@gnu.org, Kevin Rodgers
ken <geb...@mousecar.com> writes:

> If this question can't be answered straightforwardly and
> unambiguously, then there's really no sense in discussing code... or
> filing a bug report. For how could it be determined whether the code
> is working or not?

The code is working as intended. If you disagree with its behavior, you
should file a bug report like someone already suggested.

The bug tracker is not only used for glaring bugs, for also for feature
requests, etc.

Xue Fuqiao

unread,
May 16, 2013, 6:00:18 PM5/16/13
to ken, help-gnu-emacs, Kevin Rodgers, Dmitry Gutov
+1 And you can also submit patches to bug-gnu-emacs.

--
Best regards, Xue Fuqiao.
http://www.gnu.org/software/emacs/

Kevin Rodgers

unread,
May 18, 2013, 9:59:32 AM5/18/13
to help-gn...@gnu.org
On 5/16/13 8:26 AM, ken wrote:
> On 05/16/2013 09:30 AM Kevin Rodgers wrote:
>> On 5/16/13 5:08 AM, ken wrote:
>>> So given this:
>>>
>>> echo This is not an image file. > list.gif; emacs list.gif &
>>>
>>> which mode should emacs invoke?
>>
>> If you agree with the convention that .gif files are GIF images, then
>> image-mode.
>>
>> If you choose to violate that convention, then I suggest:
>>
>> echo -e "-*- mode: Text;-*-\nThis is not an image file." > list.gif;
>> emacs list.gif
>
> $ echo This is not an image file. > list.gif; file list.gif
> list.gif: ASCII text

The first step in getting emacs to emulate the file command is

(setq auto-mode-alist nil)

Then map /etc/magic into magic-mode-alist and interpreter-mode-alist.

ken

unread,
May 19, 2013, 8:10:54 AM5/19/13
to Kevin Rodgers, help-gn...@gnu.org
Thanks, Kevin. But there are already way too many projects in front of
me for the foreseeable future (including some emacs development). I
simply can't take on any more. Moreover, this wasn't an issue in all
the previous versions of emacs I've used for at least ten years, so
probably something was changed in this or a recent version which maybe
shouldn't have been. So the regular developers would be in a much
better position to address this issue than I would.

Because it might be useful to those developers, I'll put into the record
here the version used last (in which this issue didn't exist):

$ yum info emacs |grep -i 'version\|release'
Version : 21.4
Release : 24.el5

In the past I've filed a few bug reports/feature requests and for the
most part found the experience unpleasant and not useful. So I don't do
that anymore. However, if anyone else wants to write up a ticket, most
all the information needed is already contained in this thread.


Thanks again.

0 new messages