all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to open file unconditionally?
@ 2022-10-16  9:13 Jean Louis
  2022-10-16 10:29 ` Thibaut Verron
  0 siblings, 1 reply; 4+ messages in thread
From: Jean Louis @ 2022-10-16  9:13 UTC (permalink / raw)
  To: Help GNU Emacs

I wish to open file unconditionally. In my case I am opening
dynamically generated pictures. Once picture is in Emacs, another
dynamic picture is generated. I wish that find-file does not ask me
yes/no when opening a file that already has a buffer. I want to simply
open it without disturbance.

I have tried following:

	     (let ((confirm-nonexistent-file-or-buffer 1))
	       (find-file svg)))))))

but that does not get noticed by find-file


--
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/




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

* Re: How to open file unconditionally?
  2022-10-16  9:13 How to open file unconditionally? Jean Louis
@ 2022-10-16 10:29 ` Thibaut Verron
  2022-10-17  4:01   ` Jean Louis
  0 siblings, 1 reply; 4+ messages in thread
From: Thibaut Verron @ 2022-10-16 10:29 UTC (permalink / raw)
  To: Jean Louis; +Cc: Help GNU Emacs

Le dim. 16 oct. 2022 à 11:16, Jean Louis <bugs@gnu.support> a écrit :

> I wish to open file unconditionally. In my case I am opening
> dynamically generated pictures. Once picture is in Emacs, another
> dynamic picture is generated. I wish that find-file does not ask me
> yes/no when opening a file that already has a buffer. I want to simply
> open it without disturbance.
>

Unless I'm mistaken, this message will only appear if the buffer or the
file has been modified.

Do you want to switch to the existing buffer, or create a new buffer?

If it is the latter, this answer should do it:
https://emacs.stackexchange.com/a/52513/184

If it is the former, and assuming that you want to show the on-disk content
of the file, find-file-noselect has a 'nowarn second argument disabling the
prompt.
So (switch-to-buffer (find-file-noselect FILE t)) should work.



>
> I have tried following:
>
>              (let ((confirm-nonexistent-file-or-buffer 1))
>                (find-file svg)))))))
>
> but that does not get noticed by find-file
>

confirm-nonexistent-file-or-buffer seems to be about the opposite problem,
whether to query when the file/buffer does not exist, rather than create a
new one.

Best wishes,
Thibaut


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

* Re: How to open file unconditionally?
  2022-10-16 10:29 ` Thibaut Verron
@ 2022-10-17  4:01   ` Jean Louis
  2022-10-17  8:59     ` Thibaut Verron
  0 siblings, 1 reply; 4+ messages in thread
From: Jean Louis @ 2022-10-17  4:01 UTC (permalink / raw)
  To: Thibaut Verron; +Cc: Help GNU Emacs

* Thibaut Verron <thibaut.verron@gmail.com> [2022-10-16 13:30]:
> 
> If it is the latter, this answer should do it:
> https://emacs.stackexchange.com/a/52513/184

That solution is incomplete. I am opening image, the above solution is showing me the source of the SVG file, and not the SVG as image.

> If it is the former, and assuming that you want to show the on-disk content
> of the file, find-file-noselect has a 'nowarn second argument disabling the
> prompt.
> So (switch-to-buffer (find-file-noselect FILE t)) should work.

I have tried the above one, it does not overwrite the file in
buffer. It switches to the buffer. But newly modified picture is not
loaded.

Do you have other idea?

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



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

* Re: How to open file unconditionally?
  2022-10-17  4:01   ` Jean Louis
@ 2022-10-17  8:59     ` Thibaut Verron
  0 siblings, 0 replies; 4+ messages in thread
From: Thibaut Verron @ 2022-10-17  8:59 UTC (permalink / raw)
  To: Thibaut Verron, Help GNU Emacs

Le lun. 17 oct. 2022 à 06:05, Jean Louis <bugs@gnu.support> a écrit :

> * Thibaut Verron <thibaut.verron@gmail.com> [2022-10-16 13:30]:
> >
> > If it is the latter, this answer should do it:
> > https://emacs.stackexchange.com/a/52513/184
>
> That solution is incomplete. I am opening image, the above solution is
> showing me the source of the SVG file, and not the SVG as image.
>

Crude answer: turning on image-mode (or whatever you use, I don't really
know how people use emacs for images) in the new buffer should work.
A more surgical answer would have to go through auto-mode-alist,
magic-mode-alist and interpreter-mode-alist to select the correct mode for
the new buffer.


>
> > If it is the former, and assuming that you want to show the on-disk
> content
> > of the file, find-file-noselect has a 'nowarn second argument disabling
> the
> > prompt.
> > So (switch-to-buffer (find-file-noselect FILE t)) should work.
>
> I have tried the above one, it does not overwrite the file in
> buffer. It switches to the buffer. But newly modified picture is not
> loaded.
>

Does adding a (revert-buffer nil t) work?

If you always want to load the new picture as soon as it's generated,
enabling auto-revert-mode in the buffer would also do the trick.

Thibaut


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

end of thread, other threads:[~2022-10-17  8:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-16  9:13 How to open file unconditionally? Jean Louis
2022-10-16 10:29 ` Thibaut Verron
2022-10-17  4:01   ` Jean Louis
2022-10-17  8:59     ` Thibaut Verron

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.