[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to preprocess emacsclient with a mode choice?
From: |
Rustom Mody |
Subject: |
Re: How to preprocess emacsclient with a mode choice? |
Date: |
Fri, 29 Nov 2013 09:49:09 -0800 (PST) |
User-agent: |
G2/1.0 |
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.