all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to set 'buffer-save-without-query' from external program?
@ 2012-11-09 17:02 Thorsten Jolitz
  2012-11-09 17:09 ` Drew Adams
       [not found] ` <mailman.12642.1352481549.855.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 9+ messages in thread
From: Thorsten Jolitz @ 2012-11-09 17:02 UTC (permalink / raw)
  To: help-gnu-emacs


Hi List, 

I open an emacs buffer for editing from an external program and face
three problems related with Emacs querying for user input: 

1. User-query "Revert the buffer"? 

This could be solved by setting a regexp to identify the buffer-name in
in customizable variable:

,---------------------
| revert-without-query
`---------------------

2. User-query "Save before exiting the buffer" (with C-x # or
   server-edit)?

I could not find a variable that allowed to specifiy this behaviour only
for certain files matching a regexp like above. I found the buffer-local
variable 'buffer-save-without-query' though and try to set it to non-nil
from the external program: 

,--------------------------------------------------
| # set input channel to file *F already opened
| # in an Emacsclient buffer
| (in "*F"
|    # try to set variable via call to 
|    # Emacsclient
|    (call 'emacsclient
|       "-s" "emacs1"
|       "-e" "(setq buffer-save-without-query t)" ) ...
`--------------------------------------------------

But this doesn't work, I'm still queried if I want to save the buffer on
exit, and C-h v in the *F buffer shows

,---------------------------------------------------------------
| buffer-save-without-query is a variable defined in `files.el'.
| Its value is nil
`---------------------------------------------------------------

How could I 'design' an external call to emacsclient that actually sets
this variable for the buffer editing the file that is used as input
channel by the external program?

1. Unwanted change in buffer focus after exiting

When I confirm the save-query and Emacsclient exits after 'server-edit
C-x #', the focus is returned to another Emacsclient window, and in that
window the visible buffer changes to the buffer I used to start the
client with, i.e. when I started the other Emacsclient with 

,---------------------------------------
| emacsclient -s emacs1 -c "~/notes.org"
`---------------------------------------

then the visible buffer is changed to notes.org, although I might have
been editing another buffer. 

How can I suppress this behaviour? The best solution would be if the
focus would return to the commandline of the external program that
called (and then closed) an emacsclient instance for editing, and not to
another open emacsclient window.

-- 
cheers,
Thorsten





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

* RE: How to set 'buffer-save-without-query' from external program?
  2012-11-09 17:02 How to set 'buffer-save-without-query' from external program? Thorsten Jolitz
@ 2012-11-09 17:09 ` Drew Adams
  2012-11-09 17:13   ` Thorsten Jolitz
       [not found] ` <mailman.12642.1352481549.855.help-gnu-emacs@gnu.org>
  1 sibling, 1 reply; 9+ messages in thread
From: Drew Adams @ 2012-11-09 17:09 UTC (permalink / raw)
  To: 'Thorsten Jolitz', help-gnu-emacs

> I open an emacs buffer for editing from an external program and face
> three problems related with Emacs querying for user input: 
> 
> 1. User-query "Revert the buffer"? 
> 2. User-query "Save before exiting the buffer" (with C-x # or
>    server-edit)?

Sorry, just a quick response, ignoring 99% of your mail.

You should be able to use (set-buffer-modified-p nil) to prevent such checks.




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

* Re: How to set 'buffer-save-without-query' from external program?
  2012-11-09 17:09 ` Drew Adams
@ 2012-11-09 17:13   ` Thorsten Jolitz
  2012-11-09 17:18     ` Drew Adams
  0 siblings, 1 reply; 9+ messages in thread
From: Thorsten Jolitz @ 2012-11-09 17:13 UTC (permalink / raw)
  To: help-gnu-emacs

"Drew Adams" <drew.adams@oracle.com> writes:

>> I open an emacs buffer for editing from an external program and face
>> three problems related with Emacs querying for user input: 
>> 
>> 1. User-query "Revert the buffer"? 
>> 2. User-query "Save before exiting the buffer" (with C-x # or
>>    server-edit)?
>
> Sorry, just a quick response, ignoring 99% of your mail.
>
> You should be able to use (set-buffer-modified-p nil) to prevent such checks.

But I want the buffer to be reverted and saved - only without being
queried. Would this still happen if I set the set-buffer-modified-p flag
to nil?


-- 
cheers,
Thorsten




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

* RE: How to set 'buffer-save-without-query' from external program?
  2012-11-09 17:13   ` Thorsten Jolitz
@ 2012-11-09 17:18     ` Drew Adams
  2012-11-09 17:32       ` Thorsten Jolitz
  0 siblings, 1 reply; 9+ messages in thread
From: Drew Adams @ 2012-11-09 17:18 UTC (permalink / raw)
  To: 'Thorsten Jolitz', help-gnu-emacs

> > You should be able to use (set-buffer-modified-p nil) to 
> > prevent such checks.
> 
> But I want the buffer to be reverted and saved - only without being
> queried. Would this still happen if I set the set-buffer-modified-p
> flag to nil?

Sorry, I don't have the time right now to get into it.
Hopefully someone else can help more.

But "revert and save" doesn't mean much to me.
After reverting there is no need to save.

Setting the modified-p flag just pretends that you have not modified the buffer.
So you get no queries about wanting to save it.

If you instead do want to save it, then just save it, systematically.




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

* Re: How to set 'buffer-save-without-query' from external program?
  2012-11-09 17:18     ` Drew Adams
@ 2012-11-09 17:32       ` Thorsten Jolitz
  2012-11-09 17:34         ` Drew Adams
  0 siblings, 1 reply; 9+ messages in thread
From: Thorsten Jolitz @ 2012-11-09 17:32 UTC (permalink / raw)
  To: help-gnu-emacs

"Drew Adams" <drew.adams@oracle.com> writes:

>> > You should be able to use (set-buffer-modified-p nil) to 
>> > prevent such checks.
>> 
>> But I want the buffer to be reverted and saved - only without being
>> queried. Would this still happen if I set the set-buffer-modified-p
>> flag to nil?
>
> Sorry, I don't have the time right now to get into it.
> Hopefully someone else can help more.
>
> But "revert and save" doesn't mean much to me.
> After reverting there is no need to save.
>
> Setting the modified-p flag just pretends that you have not modified
> the buffer. So you get no queries about wanting to save it.
>
> If you instead do want to save it, then just save it, systematically.

Ok, thanks for your help, I think this would do the job, but the error
is probably in the emacsclient call, because it does not take effect on
the buffer that should be closed without querying. 

If an external program opened a new emacsclient instance for editing,
and the file opened in the editing buffer is set as the input channel
for the external program - isn't that buffer automatically the target
buffer for further emacsclient calls that evaluate elisp code via the
"-e" option? 

-- 
cheers,
Thorsten




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

* RE: How to set 'buffer-save-without-query' from external program?
  2012-11-09 17:32       ` Thorsten Jolitz
@ 2012-11-09 17:34         ` Drew Adams
  0 siblings, 0 replies; 9+ messages in thread
From: Drew Adams @ 2012-11-09 17:34 UTC (permalink / raw)
  To: 'Thorsten Jolitz', help-gnu-emacs

> Ok, thanks for your help, I think this would do the job, but the error
> is probably in the emacsclient call, because it does not take 
> effect on the buffer that should be closed without querying. 
> 
> If an external program opened a new emacsclient instance for editing,
> and the file opened in the editing buffer is set as the input channel
> for the external program - isn't that buffer automatically the target
> buffer for further emacsclient calls that evaluate elisp code via the
> "-e" option? 

Sorry, dunno (but someone will).  Perhaps look at the emacsclient code for info.




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

* Re: How to set 'buffer-save-without-query' from external program?
       [not found] ` <mailman.12642.1352481549.855.help-gnu-emacs@gnu.org>
@ 2012-11-09 18:53   ` Barry Margolin
  2012-11-09 19:13     ` Thorsten Jolitz
  0 siblings, 1 reply; 9+ messages in thread
From: Barry Margolin @ 2012-11-09 18:53 UTC (permalink / raw)
  To: help-gnu-emacs

In article <mailman.12642.1352481549.855.help-gnu-emacs@gnu.org>,
 "Drew Adams" <drew.adams@oracle.com> wrote:

> > > You should be able to use (set-buffer-modified-p nil) to 
> > > prevent such checks.
> > 
> > But I want the buffer to be reverted and saved - only without being
> > queried. Would this still happen if I set the set-buffer-modified-p
> > flag to nil?
> 
> Sorry, I don't have the time right now to get into it.
> Hopefully someone else can help more.
> 
> But "revert and save" doesn't mean much to me.
> After reverting there is no need to save.
> 
> Setting the modified-p flag just pretends that you have not modified the 
> buffer.
> So you get no queries about wanting to save it.
> 
> If you instead do want to save it, then just save it, systematically.

He's reverting the buffer, editing it, and then he wants to exit the 
server without saving it. But he still plans on saving it later.

But if he marks it not-modified, when he goes back to the buffer it 
won't let him save it -- it will say "no changes need to be saved".

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


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

* Re: How to set 'buffer-save-without-query' from external program?
  2012-11-09 18:53   ` Barry Margolin
@ 2012-11-09 19:13     ` Thorsten Jolitz
  2012-11-09 20:11       ` Thorsten Jolitz
  0 siblings, 1 reply; 9+ messages in thread
From: Thorsten Jolitz @ 2012-11-09 19:13 UTC (permalink / raw)
  To: help-gnu-emacs

Barry Margolin <barmar@alum.mit.edu> writes:

> In article <mailman.12642.1352481549.855.help-gnu-emacs@gnu.org>,
>  "Drew Adams" <drew.adams@oracle.com> wrote:

>> But "revert and save" doesn't mean much to me.
>> After reverting there is no need to save.
>> 
>> Setting the modified-p flag just pretends that you have not modified the 
>> buffer.
>> So you get no queries about wanting to save it.
>> 
>> If you instead do want to save it, then just save it, systematically.
>
> He's reverting the buffer, editing it, and then he wants to exit the 
> server without saving it. But he still plans on saving it later.

No, I do want to save it when exiting - but without being queried by
Emacs about it. 

So '(setq buffer-save-without-query t)' looks like the right thing to do
for me, but I'm not quite sure how to address the right emacsclient
instance / the right buffer with an external call to emacsclient. At
least what I tried (see original message) has no effect.

-- 
cheers,
Thorsten




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

* Re: How to set 'buffer-save-without-query' from external program?
  2012-11-09 19:13     ` Thorsten Jolitz
@ 2012-11-09 20:11       ` Thorsten Jolitz
  0 siblings, 0 replies; 9+ messages in thread
From: Thorsten Jolitz @ 2012-11-09 20:11 UTC (permalink / raw)
  To: help-gnu-emacs

Thorsten Jolitz <tjolitz@googlemail.com> writes:

> No, I do want to save it when exiting - but without being queried by
> Emacs about it. 
>
> So '(setq buffer-save-without-query t)' looks like the right thing to do
> for me, but I'm not quite sure how to address the right emacsclient
> instance / the right buffer with an external call to emacsclient. At
> least what I tried (see original message) has no effect.


Ok, I found a solution simply by using another way of exiting the edit
buffer: instead of using 'C-c #' (server-edit) I can use 'C-u C-x C-c'

,---------------------------------------------------------------------
| It is bound to C-x C-c, <menu-bar> <file> <exit-emacs>.
| 
| (save-buffers-kill-terminal &optional ARG)
| 
| Offer to save each buffer, then kill the current connection.
| If the current frame has no client, kill Emacs itself.
| 
| With prefix ARG, silently save all file-visiting buffers, then kill.
`---------------------------------------------------------------------

which not only exits without querying, but returns the focus to the
commandline of the calling external program, exactly what I want:

Thanks for the help. 









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

end of thread, other threads:[~2012-11-09 20:11 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-09 17:02 How to set 'buffer-save-without-query' from external program? Thorsten Jolitz
2012-11-09 17:09 ` Drew Adams
2012-11-09 17:13   ` Thorsten Jolitz
2012-11-09 17:18     ` Drew Adams
2012-11-09 17:32       ` Thorsten Jolitz
2012-11-09 17:34         ` Drew Adams
     [not found] ` <mailman.12642.1352481549.855.help-gnu-emacs@gnu.org>
2012-11-09 18:53   ` Barry Margolin
2012-11-09 19:13     ` Thorsten Jolitz
2012-11-09 20:11       ` Thorsten Jolitz

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.