* How to preprocess emacsclient with a mode choice?
@ 2013-11-28 14:48 Rustom Mody
2013-11-29 16:21 ` Kevin Rodgers
[not found] ` <mailman.7480.1385742029.10748.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 7+ messages in thread
From: Rustom Mody @ 2013-11-28 14:48 UTC (permalink / raw)
To: help-gnu-emacs
If I want to jump-into a running emacs with visiting file foo I can do:
$ emacsclient foo
However this does not give me foo with the mode I want.
Lets say I want to visit foo with auto-fill-mode. So I try
$ emacsclient -e "(let ((find-file-hook (cons 'auto-fill-mode find-file-hook)))
(find-file \"foo\"))"
This kindof works but does not pop up the emacs window.
How to get pop-up behavior of first with the mode-choice of second?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to preprocess emacsclient with a mode choice?
2013-11-28 14:48 How to preprocess emacsclient with a mode choice? Rustom Mody
@ 2013-11-29 16:21 ` Kevin Rodgers
[not found] ` <mailman.7480.1385742029.10748.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 7+ messages in thread
From: Kevin Rodgers @ 2013-11-29 16:21 UTC (permalink / raw)
To: help-gnu-emacs
On 11/28/13 7:48 AM, Rustom Mody wrote:
> If I want to jump-into a running emacs with visiting file foo I can do:
> $ emacsclient foo
>
> However this does not give me foo with the mode I want.
That behavior is no different than if you did:
$ emacs foo
is it?
> Lets say I want to visit foo with auto-fill-mode. So I try
>
> $ emacsclient -e "(let ((find-file-hook (cons 'auto-fill-mode find-file-hook)))
> (find-file \"foo\"))"
>
> This kindof works but does not pop up the emacs window.
>
> How to get pop-up behavior of first with the mode-choice of second?
Just do the same thing you would do in a new emacs instance:
M-x auto-file-mode
Better yet, put something in the file to turn on auto-fill-mode,
either directly or via a major mode hook.
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to preprocess emacsclient with a mode choice?
[not found] ` <mailman.7480.1385742029.10748.help-gnu-emacs@gnu.org>
@ 2013-11-29 17:49 ` Rustom Mody
2013-11-29 19:46 ` Eli Zaretskii
[not found] ` <mailman.7495.1385754413.10748.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 7+ messages in thread
From: Rustom Mody @ 2013-11-29 17:49 UTC (permalink / raw)
To: help-gnu-emacs
On Friday, November 29, 2013 9:51:42 PM UTC+5:30, Kevin Rodgers wrote:
> On 11/28/13 7:48 AM, Rustom Mody wrote:
> > If I want to jump-into a running emacs with visiting file foo I can do:
> > $ emacsclient foo
> >
> > However this does not give me foo with the mode I want.
>
> That behavior is no different than if you did:
> $ emacs foo
>
> is it?
>
> > Lets say I want to visit foo with auto-fill-mode. So I try
> >
> > $ emacsclient -e "(let ((find-file-hook (cons 'auto-fill-mode find-file-hook)))
> > (find-file \"foo\"))"
> >
> > This kindof works but does not pop up the emacs window.
> >
> > How to get pop-up behavior of first with the mode-choice of second?
>
> Just do the same thing you would do in a new emacs instance:
> M-x auto-file-mode
>
> Better yet, put something in the file to turn on auto-fill-mode,
> either directly or via a major mode hook.
My original problem I solved by putting an explicit (raise-frame) after the
(find-file \"foo\")
Now the new problem is that that mode-line in this case is really ugly: the
entire command arbitrarily truncated.
Now I guess I could tweak that but somehow its all smelling wrong.
Your point:
> That behavior is no different than if you did:
> $ emacs foo
> is it?
is technically valid but it seems (to me!) to miss the point that emacsclient
is used in different circumstances than emacs, viz when some process wants to
hand-off some stuff to 'whatever is $EDITOR'
Anyhow let me just take what you are saying and rephrase my question:
How to programmatically (ie in elisp) visit a file with a specific mode?
say a .c file in text mode
Note 1. I wish to avoid having to issue any M-x commands
Note 2. I have no control over the file -- so no file-variables possible
Note 3. This is odd-case behavior ie we dont want to modify default behavior(s)
ie no auto-mode-alist changes
So, poking around I see that 'after-find-file' and 'find-file-hook' is
closest to what I want... but now the mode-line is a mess.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to preprocess emacsclient with a mode choice?
2013-11-29 17:49 ` Rustom Mody
@ 2013-11-29 19:46 ` Eli Zaretskii
[not found] ` <mailman.7495.1385754413.10748.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2013-11-29 19:46 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Fri, 29 Nov 2013 09:49:09 -0800 (PST)
> From: Rustom Mody <rustompmody@gmail.com>
>
> How to programmatically (ie in elisp) visit a file with a specific mode?
> say a .c file in text mode
What's wrong with turning on the mode as part of the arguments you
pass to emacsclient?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to preprocess emacsclient with a mode choice?
[not found] ` <mailman.7495.1385754413.10748.help-gnu-emacs@gnu.org>
@ 2013-11-30 0:47 ` Rustom Mody
2013-11-30 8:10 ` Eli Zaretskii
[not found] ` <mailman.7608.1385799063.10748.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 7+ messages in thread
From: Rustom Mody @ 2013-11-30 0:47 UTC (permalink / raw)
To: help-gnu-emacs
On Saturday, November 30, 2013 1:16:27 AM UTC+5:30, Eli Zaretskii wrote:
> > Date: Fri, 29 Nov 2013 09:49:09 -0800 (PST)
> > From: Rustom Mody
> >
> > How to programmatically (ie in elisp) visit a file with a specific mode?
> > say a .c file in text mode
>
> What's wrong with turning on the mode as part of the arguments you
> pass to emacsclient?
You mean like this?
emacsclient -e "(progn (find-file \"foo\") (auto-fill-mode) (raise-frame))"
Heh! thats better than anything I came up with -- thanks!
Still wonder what makes the raise-frame necessary...
Also something fundamentally is different in the client-server relation between this and:
emacsclient foo
In the latter I have to do C-x #. In the former not
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to preprocess emacsclient with a mode choice?
2013-11-30 0:47 ` Rustom Mody
@ 2013-11-30 8:10 ` Eli Zaretskii
[not found] ` <mailman.7608.1385799063.10748.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2013-11-30 8:10 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Fri, 29 Nov 2013 16:47:45 -0800 (PST)
> From: Rustom Mody <rustompmody@gmail.com>
> Injection-Date: Sat, 30 Nov 2013 00:47:46 +0000
>
> On Saturday, November 30, 2013 1:16:27 AM UTC+5:30, Eli Zaretskii wrote:
> > > Date: Fri, 29 Nov 2013 09:49:09 -0800 (PST)
> > > From: Rustom Mody
> > >
> > > How to programmatically (ie in elisp) visit a file with a specific mode?
> > > say a .c file in text mode
> >
> > What's wrong with turning on the mode as part of the arguments you
> > pass to emacsclient?
>
> You mean like this?
> emacsclient -e "(progn (find-file \"foo\") (auto-fill-mode) (raise-frame))"
Yes.
> Heh! thats better than anything I came up with -- thanks!
You are welcome.
> Still wonder what makes the raise-frame necessary...
> Also something fundamentally is different in the client-server relation between this and:
> emacsclient foo
>
> In the latter I have to do C-x #. In the former not
All of these because when you visit a file via --eval, Emacs doesn't
"know" you visited it via the client, so it doesn't do the special
magic for that.
However, since this is a very special case, I don't think a better
solution is needed.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: How to preprocess emacsclient with a mode choice?
[not found] ` <mailman.7608.1385799063.10748.help-gnu-emacs@gnu.org>
@ 2013-12-02 4:59 ` Rustom Mody
0 siblings, 0 replies; 7+ messages in thread
From: Rustom Mody @ 2013-12-02 4:59 UTC (permalink / raw)
To: help-gnu-emacs
On Saturday, November 30, 2013 1:40:36 PM UTC+5:30, Eli Zaretskii wrote:
> > Date: Fri, 29 Nov 2013 16:47:45 -0800 (PST)
> > From: Rustom Mody
> > Injection-Date: Sat, 30 Nov 2013 00:47:46 +0000
> >
> > On Saturday, November 30, 2013 1:16:27 AM UTC+5:30, Eli Zaretskii wrote:
> > > > Date: Fri, 29 Nov 2013 09:49:09 -0800 (PST)
> > > > From: Rustom Mody
> > > >
> > > > How to programmatically (ie in elisp) visit a file with a specific mode?
> > > > say a .c file in text mode
> > >
> > > What's wrong with turning on the mode as part of the arguments you
> > > pass to emacsclient?
> >
> > You mean like this?
> > emacsclient -e "(progn (find-file \"foo\") (auto-fill-mode) (raise-frame))"
>
> Yes.
>
> > Heh! thats better than anything I came up with -- thanks!
>
> You are welcome.
>
> > Still wonder what makes the raise-frame necessary...
> > Also something fundamentally is different in the client-server relation between this and:
> > emacsclient foo
> >
> > In the latter I have to do C-x #. In the former not
>
> All of these because when you visit a file via --eval, Emacs doesn't
> "know" you visited it via the client, so it doesn't do the special
> magic for that.
>
> However, since this is a very special case, I don't think a better
> solution is needed.
Just seeing (from another thread -- thanks Emmanuel) that emacs takes a
funcall argument. Checked… evidently emacs takes funcall as argument
whereas emacsclient does not. Maybe it should also?
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-12-02 4:59 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-28 14:48 How to preprocess emacsclient with a mode choice? Rustom Mody
2013-11-29 16:21 ` Kevin Rodgers
[not found] ` <mailman.7480.1385742029.10748.help-gnu-emacs@gnu.org>
2013-11-29 17:49 ` Rustom Mody
2013-11-29 19:46 ` Eli Zaretskii
[not found] ` <mailman.7495.1385754413.10748.help-gnu-emacs@gnu.org>
2013-11-30 0:47 ` Rustom Mody
2013-11-30 8:10 ` Eli Zaretskii
[not found] ` <mailman.7608.1385799063.10748.help-gnu-emacs@gnu.org>
2013-12-02 4:59 ` Rustom Mody
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).