unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Problem with doc-view-previous-major-mode
@ 2013-04-11 20:30 Stephen Berman
  2013-04-12  1:57 ` Stefan Monnier
  2013-04-14  2:56 ` Stefan Monnier
  0 siblings, 2 replies; 7+ messages in thread
From: Stephen Berman @ 2013-04-11 20:30 UTC (permalink / raw)
  To: emacs-devel

If you visit a .docx file, you see an image of its content, since
auto-mode-alist assigns that extension to doc-view-mode-maybe.  Then if
you type C-c C-c, the display switches to a listing of the archive
contents, since .docx files are assigned by magic-fallback-mode-alist to
archive-mode.  (The same thing should also happen with ODF files ending
in .odt, .ods, etc., but doesn't, due to bug#14188.)  At least, this is
what happens with -Q.  But I have customized the global value of
major-mode to text-mode, and when I type C-c C-c on the image of a .docx
file, instead of getting the archive listing I only see the binary
content in text-mode.  The reason for this is that in doc-view-mode,
doc-view-previous-major-mode is assigned the global value of major-mode,
unless this is fundamental-mode, and then doc-view-fallback-mode calls
the mode function stored in doc-view-previous-major-mode, in my case
text-mode.  But if doc-view-previous-major-mode is nil, then
doc-view-fallback-mode calls normal-mode, which calls set-auto-mode,
which eventually checks magic-fallback-mode-alist and so switches to
archive-mode.  For my case, using non-nil doc-view-previous-major-mode
gives a worse result than calling normal-mode.  Is it possible to just
always fall back by calling normal-mode?  Or when is it really
preferable to switch to the "previous" major mode (which really means
the global value of major-mode)?

Steve Berman




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Problem with doc-view-previous-major-mode
  2013-04-11 20:30 Problem with doc-view-previous-major-mode Stephen Berman
@ 2013-04-12  1:57 ` Stefan Monnier
  2013-04-12  8:09   ` Stephen Berman
  2013-04-14  2:56 ` Stefan Monnier
  1 sibling, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2013-04-12  1:57 UTC (permalink / raw)
  To: Stephen Berman; +Cc: emacs-devel

> what happens with -Q.  But I have customized the global value of
> major-mode to text-mode,

Why?


        Stefan



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Problem with doc-view-previous-major-mode
  2013-04-12  1:57 ` Stefan Monnier
@ 2013-04-12  8:09   ` Stephen Berman
  2013-04-12 16:24     ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: Stephen Berman @ 2013-04-12  8:09 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

On Thu, 11 Apr 2013 21:57:49 -0400 Stefan Monnier <monnier@iro.umontreal.ca> wrote:

>> what happens with -Q.  But I have customized the global value of
>> major-mode to text-mode,
>
> Why?

Because I found that I often wanted to do quick tests in text-mode by
typing `C-x b a'.  Your question suggests suggests that this
customization is ill-advised; if so, why (other than the problem that my
OP described, which I still would like to know if it causes problems for
doc-view always to get the fallback mode via normal-mode rather than the
"previous" major mode)?  And if it is ill-advised, then major-mode
shouldn't be customizable, should it?

Steve Berman



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Problem with doc-view-previous-major-mode
  2013-04-12  8:09   ` Stephen Berman
@ 2013-04-12 16:24     ` Stefan Monnier
  2013-04-13 14:57       ` Stephen Berman
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2013-04-12 16:24 UTC (permalink / raw)
  To: Stephen Berman; +Cc: emacs-devel

>>> what happens with -Q.  But I have customized the global value of
>>> major-mode to text-mode,
>> Why?
> Because I found that I often wanted to do quick tests in text-mode by
> typing `C-x b a'.

I see.

> Your question suggests suggests that this customization is
> ill-advised;

No.  Customizing default-major-mode has been supported "for ever" and
your use case makes sense, but the way it works makes for some annoying
corner cases, such as the one you've bumped into.

So I'd like to use another mechanism, such that you could still
configure the mode to use for a new buffer created via C-x b, but
without it affecting things like your doc-view case.

> And if it is ill-advised, then major-mode shouldn't be customizable,
> should it?

If I could rewrite history, indeed the default value of major-mode would
not be customizable.


        Stefan



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Problem with doc-view-previous-major-mode
  2013-04-12 16:24     ` Stefan Monnier
@ 2013-04-13 14:57       ` Stephen Berman
  0 siblings, 0 replies; 7+ messages in thread
From: Stephen Berman @ 2013-04-13 14:57 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

On Fri, 12 Apr 2013 12:24:34 -0400 Stefan Monnier <monnier@iro.umontreal.ca> wrote:

>>>> what happens with -Q.  But I have customized the global value of
>>>> major-mode to text-mode,
>>> Why?
>> Because I found that I often wanted to do quick tests in text-mode by
>> typing `C-x b a'.
>
> I see.
>
>> Your question suggests suggests that this customization is
>> ill-advised;
>
> No.  Customizing default-major-mode has been supported "for ever" and
> your use case makes sense, but the way it works makes for some annoying
> corner cases, such as the one you've bumped into.
>
> So I'd like to use another mechanism, such that you could still
> configure the mode to use for a new buffer created via C-x b, but
> without it affecting things like your doc-view case.

Do you have something already in the works, or are you soliciting ideas?
If the latter, maybe we could add a prefix argument to switch-to-buffer
that sets the major-mode (using completion and defaulting to the value
of a user option) if the buffer switched to is new.

>> And if it is ill-advised, then major-mode shouldn't be customizable,
>> should it?
>
> If I could rewrite history, indeed the default value of major-mode would
> not be customizable.

When an alternative is in place, the customizability could be obsoleted.

Steve Berman



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Problem with doc-view-previous-major-mode
  2013-04-11 20:30 Problem with doc-view-previous-major-mode Stephen Berman
  2013-04-12  1:57 ` Stefan Monnier
@ 2013-04-14  2:56 ` Stefan Monnier
  2013-04-14 12:55   ` Stephen Berman
  1 sibling, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2013-04-14  2:56 UTC (permalink / raw)
  To: Stephen Berman; +Cc: emacs-devel

> what happens with -Q.  But I have customized the global value of
> major-mode to text-mode, and when I type C-c C-c on the image of a .docx
> file, instead of getting the archive listing I only see the binary
> content in text-mode.  The reason for this is that in doc-view-mode,
> doc-view-previous-major-mode is assigned the global value of major-mode,
> unless this is fundamental-mode, and then doc-view-fallback-mode calls
> the mode function stored in doc-view-previous-major-mode, in my case
> text-mode.  But if doc-view-previous-major-mode is nil, then

I've installed a patch which seems to fix this problem,


        Stefan



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Problem with doc-view-previous-major-mode
  2013-04-14  2:56 ` Stefan Monnier
@ 2013-04-14 12:55   ` Stephen Berman
  0 siblings, 0 replies; 7+ messages in thread
From: Stephen Berman @ 2013-04-14 12:55 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

On Sat, 13 Apr 2013 22:56:09 -0400 Stefan Monnier <monnier@iro.umontreal.ca> wrote:

>> what happens with -Q.  But I have customized the global value of
>> major-mode to text-mode, and when I type C-c C-c on the image of a .docx
>> file, instead of getting the archive listing I only see the binary
>> content in text-mode.  The reason for this is that in doc-view-mode,
>> doc-view-previous-major-mode is assigned the global value of major-mode,
>> unless this is fundamental-mode, and then doc-view-fallback-mode calls
>> the mode function stored in doc-view-previous-major-mode, in my case
>> text-mode.  But if doc-view-previous-major-mode is nil, then
>
> I've installed a patch which seems to fix this problem,

Confirmed, and thanks.

Steve Berman



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-04-14 12:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-11 20:30 Problem with doc-view-previous-major-mode Stephen Berman
2013-04-12  1:57 ` Stefan Monnier
2013-04-12  8:09   ` Stephen Berman
2013-04-12 16:24     ` Stefan Monnier
2013-04-13 14:57       ` Stephen Berman
2013-04-14  2:56 ` Stefan Monnier
2013-04-14 12:55   ` Stephen Berman

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