From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Mauger Newsgroups: gmane.emacs.devel Subject: Re: Proposal: emacsclient --readonly Date: Wed, 27 Mar 2013 06:47:21 -0700 (PDT) Message-ID: <1364392041.32259.YahooMailNeo@web160906.mail.bf1.yahoo.com> References: <87zjxtq304.fsf@michael-laptop.hsd1.ma.comcast.net> <1364142142.92134.YahooMailNeo@web160904.mail.bf1.yahoo.com> <1364266566.22342.YahooMailNeo@web160905.mail.bf1.yahoo.com> <1364349727.76978.YahooMailNeo@web160905.mail.bf1.yahoo.com> Reply-To: Michael Mauger NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1364392055 18508 80.91.229.3 (27 Mar 2013 13:47:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 27 Mar 2013 13:47:35 +0000 (UTC) Cc: "emacs-devel@gnu.org" To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Mar 27 14:48:00 2013 Return-path: Envelope-to: ged-emacs-devel@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 1UKqhm-0002XR-Ex for ged-emacs-devel@m.gmane.org; Wed, 27 Mar 2013 14:47:54 +0100 Original-Received: from localhost ([::1]:42445 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKqhO-00052X-HS for ged-emacs-devel@m.gmane.org; Wed, 27 Mar 2013 09:47:30 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:45576) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKqhJ-00050p-LS for emacs-devel@gnu.org; Wed, 27 Mar 2013 09:47:27 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UKqhH-0001Te-KV for emacs-devel@gnu.org; Wed, 27 Mar 2013 09:47:25 -0400 Original-Received: from nm37.bullet.mail.bf1.yahoo.com ([72.30.239.57]:47967) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKqhH-0001TE-9V for emacs-devel@gnu.org; Wed, 27 Mar 2013 09:47:23 -0400 Original-Received: from [98.139.214.32] by nm37.bullet.mail.bf1.yahoo.com with NNFMP; 27 Mar 2013 13:47:21 -0000 Original-Received: from [98.139.212.230] by tm15.bullet.mail.bf1.yahoo.com with NNFMP; 27 Mar 2013 13:47:21 -0000 Original-Received: from [127.0.0.1] by omp1039.mail.bf1.yahoo.com with NNFMP; 27 Mar 2013 13:47:21 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 561544.28725.bm@omp1039.mail.bf1.yahoo.com Original-Received: (qmail 32916 invoked by uid 60001); 27 Mar 2013 13:47:21 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1364392041; bh=62HCMSt4TwP/AQQ8XEsw3x8lCtuUNF0DJ5hbxASNAK4=; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-RocketYMMF:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=xYD+d3HRBL4X639z2sJnhnHhhSyzB5PyzTDLMwA3IQWwQEbCownEWJ2g51yi48py3r9TpasZims0rZNPd/mdAlH2A+WY11D/awA7mgWzyT7Hw0eXjpsK/XVRisO2L4QybYhBtT6/5QMxwoG1LAcx6i0OsQGPgzIHHvkjQgwgGqA= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-RocketYMMF:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=Dee+/H5ybbHPhyJcCdAANIgGBmLfTsQ8VixGba2nDVU60Sxr4X8ZAQjAfpt/sDIGiSEtFZwzSgJ7lMSNputNVKBJd6L8HRc4nDmKieeTUWoq9pD+2b0lu6NsgenAdpzs0Exdt7Ze/Eevxu6RLd0yTEu1+3Pi7apQ/xfyF718JDU=; X-YMail-OSG: .EREWK4VM1mpNVfb7xn97X9JxjqOEiDME7otn92HKPAA7wg WotYBc7.gCD6a0LOWNjEUV8DKniYuAxfiPnvgN9ohMWIMHzDCJoHN5Y1tuiF aApiaYqWCLFv7yYVcFOZm4gWGWs5mMrnT5M2jADW0j94xFCRb5MUMQ93ZIjh GAUbu_z8bmZ5GhA9hcdBWWb66NHxReVzx.6m8wLjhatBv78.WiRm3gchE._M nklx6lM3tOPqLdwOhV6pHrkdXvr4i17neY6GINV9xcG3DQd.kp5HNn69Tdmk IWzxtYA6Xx1G1u0tV7Y8yeP9FN.OdzfvJHe6uQj1GHz4dLaLmudpe_WJrBsb HHrtpDtvZa.ooNv9FYiuETenJqsdr2wW346hHCNaY6KsHE88r.6PWQvN68BH l6qYPo6EIvE3O9lM9xFgYoaNzt0l.VwrLVip.g7HsK9rvRDMrbIVJOBnxu4p dnIKBGQcB6JGv4P49vk3pPYl.BNoM91HTZ1PliJ6UmiaoAs9mvnsw1_fOPN0 t2Og- Original-Received: from [98.216.52.54] by web160906.mail.bf1.yahoo.com via HTTP; Wed, 27 Mar 2013 06:47:21 PDT X-Rocket-MIMEInfo: 002.001, PsKgCgo.PiAgSW4gdGhlIEMgY29kZSwgaWYgdGhlcmUgYXJlIGFueSB1bnJlY29nbml6ZWQgb3B0aW9ucyB0aGV5IHdpbGwgYmUgc2VudCAKPiBvdmVywqAKPj4gIGFzIGEgLWN1c3RvbSBvcHRpb24gZm9sbG93ZWQgYnkgdGhlIG5vbi1vcHRpb24gcGFyYW1ldGVycyBhcyAtYXJncwo.IAo.IEknbSBub3Qgc3VyZSBJIHVuZGVyc3RhbmQgcmlnaHQsIGJ1dCBpdCBkb2Vzbid0IHNvdW5kIGxpa2UgaXQncyAKPiBnb2luZwo.IGEgZGlyZWN0aW9uIEkgbGlrZTogSSdkIGxpa2UgdG8gcmVkdWNlIHRoZSBkaWZmZXIBMAEBAQE- X-RocketYMMF: mmaug X-Mailer: YahooMailWebService/0.8.139.530 In-Reply-To: X-detected-operating-system: by eggs.gnu.org: FreeBSD 8.x X-Received-From: 72.30.239.57 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:158302 Archived-At: >=A0=0A=0A>> In the C code, if there are any unrecognized options they wil= l be sent =0A> over=A0=0A>> as a -custom option followed by the non-option= parameters as -args=0A> =0A> I'm not sure I understand right, but it doesn= 't sound like it's =0A> going=0A> a direction I like: I'd like to reduce th= e difference between the=0A> C-level command line argument vector received = by emacsclient and the=0A> list of strings received by server.el.=0A>=A0=0A= =0ANot sure how this is possible because the parameters are not=0Asent as t= hey are encountered. =A0Based on the settings the client=0Aprograms behavio= r is altered so I will try to accomplish this as=0Abest as I can.=0A=0A>> = On the server side, the elisp will call the handler for each -custom =0A> o= ption=A0=0A>> and=A0pass the args along with it.=0A> =0A> The --diff and -= -eval options don't take just one "argument", =0A> which is=0A> why I don't= want to hardcode this idea of a "--option ARG" format.=0A> =0A=0A=0AI clea= rly wasn't very eloquent =A0last nite, in fact, after reading what I=A0=0Aw= rote, I'm=A0not sure I knew what I meant. =A0I started to hack at this=A0= =0Aand=A0I think I can describe it with more clarity now:=0A=0AIn the C cod= e, we use getopt_long_only to parse the command=A0=0Aline args, so I want t= o make sure that the custom options behave=0Aas the built-in options do, so= there is some complexity here.=0A=0AIf an option is encountered that is no= t recognized, then we will=A0=0Aparse the argument string to see if it is i= n the format OPTION=3DARG,=0Aif it is, then we send the following "-custom = OPTION -arg ARG".=0AIn this case, that is the only option value and parsing= continues=0Awith the next comand line arg. =A0=0A=0AIf the option lacks an= equal sign, then the option is sent with=0A"-custom OPTION", it then scans= thru the following arguments=A0=0Aand any that don't start with a hyphen w= ill be sent as "-arg XXX"=0Aso that there may be many -arg entries followin= g the -custom.=0A=0AThe danger, of course, is that we may associate an arg = with an=0Aoption because the C program knows nothing about the option=0Aor = the number of args it takes. =A0So the elisp side will have to take=0Aany u= nused args and treat them as either -file or -eval entries.=0AThere be drag= ons here. =A0If the --eval option was specified, the flag=0Ais not sent so = the elisp side doesn't know to treat the unused args=A0=0Aas expressions ra= ther than file names unless there are other non-=0Aoption arguments supplie= d. =A0This is going to require some addl=0Ainfo being sent to elisp but it'= s not a real complication.=0A=0AHere's an example:=0A=0A=A0 =A0 emacsclient= --eval --my-new-option A B C=0A=0ASends:=0A=A0 =A0 -... standard entries d= ispay, dir, env, et al=0A=A0 =A0 -custom my-new-option -arg A -arg B -arg C= =0A=0AIf my-new-option requires two args then it consumes A and B.=0A=0AThi= s leaves C as a unused entry. =A0Since there are no -file or=A0=0A-eval ent= ries we don't know how to handle the unused unless=0Athere is a separate en= try to indicate how unused args should=0Abe handled.=0A=0AThe=A0ambiguity= =A0can be addressed by specifying the arguments=A0=0Aas:=0A=0A=A0 =A0 emacs= client --eval C --my-new-option A B=0Aor=0A=A0 =A0 emacsclient --my-new-opt= ion A B --eval C=0A=0AThere may be some issues since the options and parame= ters=0Aare not sent to the elisp code in the same order they are=A0=0Aspeci= fied. =A0This isn't easy to correct so I expect that some=A0=0Acustom optio= ns may have unintended behavior because the=0Asequence of file-opens or exp= ression-evaluations may not=A0=0Ahappen in the same order. =A0=0A=0A> =0A> = Refactoring sounds fine.=0A> =0A=0A=0AI hope this clarifies things a bit. = =A0As I said, I've got some of=A0=0Athe code ready and should wrap it up to= nite. =A0I'll then try to=0Aimplement --readonly and --diff to demonstrate = how this will=0Aall look.=0A=0A-- Michael