From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Rustom Mody Newsgroups: gmane.emacs.help Subject: Re: How to preprocess emacsclient with a mode choice? Date: Fri, 29 Nov 2013 09:49:09 -0800 (PST) Message-ID: <3471cd49-4b5e-4842-a99e-9b35ec277ceb@googlegroups.com> References: <8f3ccb5f-72ca-4ea8-bb4a-103e74e7b4c0@googlegroups.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1385747414 20030 80.91.229.3 (29 Nov 2013 17:50:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 29 Nov 2013 17:50:14 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Nov 29 18:50:20 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VmSCo-0001ZL-Ur for geh-help-gnu-emacs@m.gmane.org; Fri, 29 Nov 2013 18:50:19 +0100 Original-Received: from localhost ([::1]:48823 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VmSCo-0000uT-K3 for geh-help-gnu-emacs@m.gmane.org; Fri, 29 Nov 2013 12:50:18 -0500 X-Received: by 10.66.160.36 with SMTP id xh4mr17542673pab.11.1385747349670; Fri, 29 Nov 2013 09:49:09 -0800 (PST) X-Received: by 10.50.2.74 with SMTP id 10mr140316igs.15.1385747349597; Fri, 29 Nov 2013 09:49:09 -0800 (PST) Original-Path: usenet.stanford.edu!i10no3782107pba.1!news-out.google.com!p7ni4260qat.0!nntp.google.com!p15no2828507qaj.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=59.95.13.171; posting-account=mBpa7woAAAAGLEWUUKpmbxm-Quu5D8ui Original-NNTP-Posting-Host: 59.95.13.171 User-Agent: G2/1.0 Injection-Date: Fri, 29 Nov 2013 17:49:09 +0000 Original-Xref: usenet.stanford.edu gnu.emacs.help:202449 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:94718 Archived-At: 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.