From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Oleksandr Gavenko Newsgroups: gmane.emacs.help Subject: Re: Look for data serialisation format to implement communication between Emacs and external program. Date: Mon, 07 Jan 2013 15:35:01 +0200 Organization: Oleksandr Gavenko , http://gavenkoa.users.sf.net Message-ID: <871udxt8u2.fsf@gavenkoa.example.com> References: <87ehhyc7g1.fsf@gavenkoa.example.com> <87k3rqudz6.fsf@zigzag.favinet> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1357565734 22117 80.91.229.3 (7 Jan 2013 13:35:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 7 Jan 2013 13:35:34 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jan 07 14:35:51 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 1TsCrk-0003JD-GI for geh-help-gnu-emacs@m.gmane.org; Mon, 07 Jan 2013 14:35:48 +0100 Original-Received: from localhost ([::1]:46442 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsCrU-000820-SP for geh-help-gnu-emacs@m.gmane.org; Mon, 07 Jan 2013 08:35:32 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:42866) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsCrL-00081t-5B for help-gnu-emacs@gnu.org; Mon, 07 Jan 2013 08:35:27 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TsCrJ-0006rC-Su for help-gnu-emacs@gnu.org; Mon, 07 Jan 2013 08:35:23 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:38146) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsCrJ-0006r4-Me for help-gnu-emacs@gnu.org; Mon, 07 Jan 2013 08:35:21 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1TsCrW-0002xg-Dk for help-gnu-emacs@gnu.org; Mon, 07 Jan 2013 14:35:34 +0100 Original-Received: from 37.229.4.200 ([37.229.4.200]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 07 Jan 2013 14:35:34 +0100 Original-Received: from gavenkoa by 37.229.4.200 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 07 Jan 2013 14:35:34 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 45 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 37.229.4.200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) Cancel-Lock: sha1:TlCxa6P2K6gER41ha/bZ5NYhnes= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 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:88500 Archived-At: On 2013-01-07, Thien-Thi Nguyen wrote: > () Oleksandr Gavenko > () Sun, 06 Jan 2013 23:44:46 +0200 > > Another formats like JSON or sexp also look nice but I don't know > about Emacs support for this formats. > > Go with sexp. If you must touch XML, at least dress it up as SXML, > which, aside from being less ugly, extends interop to include Scheme. > E.g., sexp + SXML is the approach IXIN uses. Latest announcement: > . > One thing stop me from using sexp - my Python code can be possible used in another cases where sexp parser can be absent. > If you absolutely need a binary (non-text) format, then i would next > recommend bindat.el (info "(elisp) Byte Packing") for the job. Perhaps > ASN.1 can be layered on top of bindat.el, but that doesn't sound so fun. > (But what do i know about ASN.1 and/or fun?) > Thank for suggestion. I completed simple type-length-value example: (setq bin-str (unibyte-string ?s 4 ?h ?a ?l ?o)) (setq bin-header '((:type u8) (:len u8) (:val vec (:len)))) (setq bin-data (bindat-unpack bin-header bin-str)) (bindat-pack bin-header bin-data) But as input come from external process I need manually check for input end because parsing of incomplete input take error "args-out-of-range". I don't know how to resolve this issue. I expect to find a way to get data validation for free (like XSD/RNC for XML). Also I don't see have can I split data into packets with "bindat" (Emacs send request and Python send response in a loop without dropping connection while returned data is valid). As solution - make 10 attempt with 1 sec delay and then report error - incomplete or invalid packet... > Lastly, on the other side of the pipe, why not consider Emacs itself, or > Guile, or something that can ‘read’ a sexp? -- Best regards!