From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Stefan Monnier " Newsgroups: gmane.emacs.help Subject: Re: Elegance in elisp, need advices Date: 29 Jan 2003 14:04:59 -0500 Organization: Yale University Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <5ly9537p5w.fsf@rum.cs.yale.edu> References: <874r7r7v1d.fsf@noos.fr> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1043868225 8920 80.91.224.249 (29 Jan 2003 19:23:45 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 29 Jan 2003 19:23:45 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18dxoF-0002Jj-00 for ; Wed, 29 Jan 2003 20:23:43 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18dxgH-0004gN-08 for gnu-help-gnu-emacs@m.gmane.org; Wed, 29 Jan 2003 14:15:29 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!logbridge.uoregon.edu!news.ycc.yale.edu!rum.cs.yale.edu!rum.cs.yale.edu Original-Newsgroups: gnu.emacs.sources,gnu.emacs.help Original-Followup-To: gnu.emacs.help Original-Lines: 31 Original-NNTP-Posting-Host: rum.cs.yale.edu User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 X-Original-NNTP-Posting-Host: rum.cs.yale.edu X-Original-Trace: 29 Jan 2003 14:04:59 -0500, rum.cs.yale.edu Original-Xref: shelby.stanford.edu gnu.emacs.sources:9354 gnu.emacs.help:109539 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:6059 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:6059 [ redirecting follow-ups to gnu.emacs.help ] > For instance, the connection is set up with open-network-stream and > set-process-filter. I keep a buffer-like string (buffer as in C not as > in emacs), to which I concatenate every received string. When I am [...] > What would be the 'good' way to do that ? Other than details of the layout of your code (more than 80 cols, docstring on the same line as the `defun', ...) it looks OK. I don't know of any way to make it much better. You could of course use a real Emacs buffer rather than a string, so you can use `insert / delete-region' rather than `concat / substring', but fundamentally, it can't be very different. Admittedly, many process filters do such things, so it might be worth it to provide a generic way to solve it, but I don't know of anybody who's done that yet. > Also, to decode/encode int8 int16 and int32 into mldonkey format, I > use this kind of infamous functions : I remember someone posting some generic code to do packing/unpacking of binary data (maybe it was called struct.el or something like that). >>> (defun int32-to-proto (n) (string (mod n 256) (mod (/ n 256) 256) (mod (/ n 65536) 256) (mod (/ n 16777216) 256))) BTW, on 32bit machines, Emacs' integers only use 28bits (i.e. from -2^17 to 2^17-1). Stefan