* Return values of (find-file-noselect), etc.
@ 2019-01-06 19:06 Douglas Lewan
2019-01-06 22:13 ` Stefan Monnier
0 siblings, 1 reply; 7+ messages in thread
From: Douglas Lewan @ 2019-01-06 19:06 UTC (permalink / raw)
To: help-gnu-emacs
I'm writing cpio-mode for emacs whose definition calls
(switch-to-buffer) to present an affiliated buffer that contains a
dired-like interface.
If I have my emacs environment set up to call (cpio-mode) when it
detects that a file is a cpio archive, then, e.g. (find-file-noselect
"cpio-archive"), returns the dired-style buffer, not the buffer of the
found file. So, any processing based on the newly found file is done
with the dired-style buffer instead of the buffer with the newly found file.
Is that the expected behavior? The docstring(s) are vague about the
return value for finding one file. It's explicit about finding multiple
files using wildcards. The info documentation, however, is explicit
about the return value for finding one file. On the other hand, these
functions boil down to (find-file-noselect-1), which returns the value
from (current-buffer). That is, it may be returning a value that wasn't
made explicit.
I'm really just curious.
Thanks.
--
,Doug
Douglas Lewan
+1 (908) 720-7908
Give me "assloads of config" over "some other person thought they could decide what I like" any day. - Szmo, on reddit, 2017 Sep 05
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Return values of (find-file-noselect), etc.
2019-01-06 19:06 Return values of (find-file-noselect), etc Douglas Lewan
@ 2019-01-06 22:13 ` Stefan Monnier
2019-01-07 0:49 ` Douglas Lewan
0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2019-01-06 22:13 UTC (permalink / raw)
To: help-gnu-emacs
> If I have my emacs environment set up to call (cpio-mode) when it
> detects that a file is a cpio archive, then, e.g. (find-file-noselect
> "cpio-archive"), returns the dired-style buffer, not the buffer of the
> found file. So, any processing based on the newly found file is done
> with the dired-style buffer instead of the buffer with the newly found file.
It should return the buffer whose buffer-file-name is that of the file.
I think in your case, that should be the dired-style buffer and *also*
the buffer from which cpio-mode was called (i.e. the buffer which
originally held the file's content).
In RMAIL we satisfy these constraints using buffer-swap-text.
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Return values of (find-file-noselect), etc.
2019-01-06 22:13 ` Stefan Monnier
@ 2019-01-07 0:49 ` Douglas Lewan
2019-01-07 3:06 ` Stefan Monnier
0 siblings, 1 reply; 7+ messages in thread
From: Douglas Lewan @ 2019-01-07 0:49 UTC (permalink / raw)
To: help-gnu-emacs
On 01/06/2019 05:13 PM, Stefan Monnier wrote:
>> If I have my emacs environment set up to call (cpio-mode) when it
>> detects that a file is a cpio archive, then, e.g. (find-file-noselect
>> "cpio-archive"), returns the dired-style buffer, not the buffer of the
>> found file. So, any processing based on the newly found file is done
>> with the dired-style buffer instead of the buffer with the newly found file.
> It should return the buffer whose buffer-file-name is that of the file.
> I think in your case, that should be the dired-style buffer and *also*
> the buffer from which cpio-mode was called (i.e. the buffer which
> originally held the file's content).
> In RMAIL we satisfy these constraints using buffer-swap-text.
Either way, that's not what I'm seeing. Should this be recorded as a bug?
--
,Doug
Douglas Lewan
+1 (908) 720-7908
Give me "assloads of config" over "some other person thought they could decide what I like" any day. - Szmo, on reddit, 2017 Sep 05
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Return values of (find-file-noselect), etc.
2019-01-07 0:49 ` Douglas Lewan
@ 2019-01-07 3:06 ` Stefan Monnier
2019-01-07 7:36 ` Douglas Lewan
0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2019-01-07 3:06 UTC (permalink / raw)
To: help-gnu-emacs
> Either way, that's not what I'm seeing. Should this be recorded as a bug?
I think it's a bug for a major mode function to change the current
buffer, so what you're seeing is likely the result of find-file-noselect
not protecting itself against such misbehaving major modes ;-)
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Return values of (find-file-noselect), etc.
2019-01-07 3:06 ` Stefan Monnier
@ 2019-01-07 7:36 ` Douglas Lewan
2019-01-08 18:07 ` Stefan Monnier
0 siblings, 1 reply; 7+ messages in thread
From: Douglas Lewan @ 2019-01-07 7:36 UTC (permalink / raw)
To: help-gnu-emacs
On 01/06/2019 10:06 PM, Stefan Monnier wrote:
>> Either way, that's not what I'm seeing. Should this be recorded as a bug?
> I think it's a bug for a major mode function to change the current
> buffer, so what you're seeing is likely the result of find-file-noselect
> not protecting itself against such misbehaving major modes ;-)
>
>
> Stefan
>
>
Hmmm. I suppose I could make (cpio-mode) a function instead of a mode,
but that seems to be somehow inappropriate. It would avoid the bug of
being a misbehaving major mode, but . . . well . . . . I do suppose
there could be a legitimate style issue here.
I think I'll leave it the way it is and wait to see if anyone screams.
Thanks for taking the time to think about this. :-)
--
,Doug
Douglas Lewan
+1 (908) 720-7908
Give me "assloads of config" over "some other person thought they could decide what I like" any day. - Szmo, on reddit, 2017 Sep 05
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Return values of (find-file-noselect), etc.
2019-01-07 7:36 ` Douglas Lewan
@ 2019-01-08 18:07 ` Stefan Monnier
2019-01-08 19:12 ` Douglas Lewan
0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2019-01-08 18:07 UTC (permalink / raw)
To: help-gnu-emacs
>>> Either way, that's not what I'm seeing. Should this be recorded as a bug?
>> I think it's a bug for a major mode function to change the current
>> buffer, so what you're seeing is likely the result of find-file-noselect
>> not protecting itself against such misbehaving major modes ;-)
> Hmmm. I suppose I could make (cpio-mode) a function instead of a mode,
I think using buffer-swap-text, you should be able to fairly easily make
it so that cpio-mode is a proper major mode (e.g. doesn't change
current-buffer) and yet moves the current buffer's contents to some
auxiliary buffer and puts the dired-style interface in the current buffer.
(and setup a change-major-mode-hook to reverse this if the user decides
to change the major mode to something else like fundamental-mode).
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Return values of (find-file-noselect), etc.
2019-01-08 18:07 ` Stefan Monnier
@ 2019-01-08 19:12 ` Douglas Lewan
0 siblings, 0 replies; 7+ messages in thread
From: Douglas Lewan @ 2019-01-08 19:12 UTC (permalink / raw)
To: help-gnu-emacs
Ok. I'll look into it. Don't expect this immediately though. (One
problem I see right away is that associating an entry contents buffer
correctly might require a different mechanism.
On 01/08/2019 01:07 PM, Stefan Monnier wrote:
>>>> Either way, that's not what I'm seeing. Should this be recorded as a bug?
>>> I think it's a bug for a major mode function to change the current
>>> buffer, so what you're seeing is likely the result of find-file-noselect
>>> not protecting itself against such misbehaving major modes ;-)
>> Hmmm. I suppose I could make (cpio-mode) a function instead of a mode,
> I think using buffer-swap-text, you should be able to fairly easily make
> it so that cpio-mode is a proper major mode (e.g. doesn't change
> current-buffer) and yet moves the current buffer's contents to some
> auxiliary buffer and puts the dired-style interface in the current buffer.
> (and setup a change-major-mode-hook to reverse this if the user decides
> to change the major mode to something else like fundamental-mode).
>
>
> Stefan
>
>
--
,Doug
Douglas Lewan
+1 (908) 720-7908
Give me "assloads of config" over "some other person thought they could decide what I like" any day. - Szmo, on reddit, 2017 Sep 05
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-01-08 19:12 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-06 19:06 Return values of (find-file-noselect), etc Douglas Lewan
2019-01-06 22:13 ` Stefan Monnier
2019-01-07 0:49 ` Douglas Lewan
2019-01-07 3:06 ` Stefan Monnier
2019-01-07 7:36 ` Douglas Lewan
2019-01-08 18:07 ` Stefan Monnier
2019-01-08 19:12 ` Douglas Lewan
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.