From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?UTF-8?Q?Aur=C3=A9lien_Aptel?= Newsgroups: gmane.emacs.devel Subject: Re: good examples of Emacs modules? Date: Thu, 31 Mar 2016 23:29:19 +0200 Message-ID: References: <56FC5E99.7090804@cs.ucla.edu> <8737r67jbo.fsf@wanadoo.es> <83a8levbaf.fsf@gnu.org> <87y48y60fi.fsf@wanadoo.es> <834mbmv95h.fsf@gnu.org> <87twjm5rc3.fsf@wanadoo.es> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1459459777 12279 80.91.229.3 (31 Mar 2016 21:29:37 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 31 Mar 2016 21:29:37 +0000 (UTC) Cc: Tom Tromey , syohex@gmail.com, Emacs development discussions To: =?UTF-8?Q?=C3=93scar_Fuentes?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Mar 31 23:29:29 2016 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 1alk9f-0003Fy-SA for ged-emacs-devel@m.gmane.org; Thu, 31 Mar 2016 23:29:28 +0200 Original-Received: from localhost ([::1]:34532 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1alk9f-0007I8-0b for ged-emacs-devel@m.gmane.org; Thu, 31 Mar 2016 17:29:27 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43230) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1alk9Z-0007Cb-8e for emacs-devel@gnu.org; Thu, 31 Mar 2016 17:29:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1alk9X-0001xw-Sd for emacs-devel@gnu.org; Thu, 31 Mar 2016 17:29:21 -0400 Original-Received: from mail-yw0-x231.google.com ([2607:f8b0:4002:c05::231]:36048) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1alk9X-0001xr-O2 for emacs-devel@gnu.org; Thu, 31 Mar 2016 17:29:19 -0400 Original-Received: by mail-yw0-x231.google.com with SMTP id g3so114678722ywa.3 for ; Thu, 31 Mar 2016 14:29:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-transfer-encoding; bh=Z1dC2/AIo9qe+ubY/dQ+rs/Entt7fMeMR96PTWxy/AU=; b=aTW4M2Pg732pazgdeRF9XTqbnuIvaambJsqWY+C3Q2Cfo4S6WsyO25QkJ2jlIEBcrw EOm/4+zH1/H64C9TeozIxeYhHexW0zSReQc+iUzP/rI7salwBv9OiLnvaUR4Lx3UM4iW ghKKTVHle113RoqEg5pdia0RNhNnZiKe1FkcceGySMY3zx1LiYV6q7+4UYp62D0JIEjl VY0AKtaKyU+yVSChbzZoOEkzw48f4QUlDfbJ+PX+reBVA67AKfivNZ17dL0K63wSQZJ/ VUzn8XaCBQLxdxnQXgdzPM2/romtm89INDWLPoEKs9QIZYJLysJyYNwKxoWWYOqksK3p HJzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc:content-transfer-encoding; bh=Z1dC2/AIo9qe+ubY/dQ+rs/Entt7fMeMR96PTWxy/AU=; b=cGesijPmuLRRnwm2l8F7ZJURh8R1WUqXywMl1eqP1K1i0uu61CDNiVpryH5eaBe5z9 To1+4dcWQBPuzREgboEGON/tRMMyfTbAzToxleZDNeka9Fvg8h90FqTkq9bIqszY2LA/ 3oitBKlqz74C54smWfs6i6MeKrXhbEPvWJulQhom7hbhfHG3ATmX8FVT6dmVJwi+M52B 0pNuD//a5MPaz7sgw9AOCUcKcgF7nOFJigdc3hb/jl+IVWCbwGzv2xQfLUTPU1swxqlk Eg3f3EgImEXfBSO1YYW7THztjgpRm6jvhlXikRqqq+QPCsQyoJXjmezp/jhTPf8DeL67 f3rA== X-Gm-Message-State: AD7BkJKgnuODhbOVMoZHD7hH78pjUPznqCCkiAVSAq2KyL+awrllFE/MEsur2ZMffdeW2HvK/+rq+AwY7Y+Xpg== X-Received: by 10.176.7.72 with SMTP id h66mr664749uah.11.1459459759163; Thu, 31 Mar 2016 14:29:19 -0700 (PDT) Original-Received: by 10.159.37.33 with HTTP; Thu, 31 Mar 2016 14:29:19 -0700 (PDT) In-Reply-To: <87twjm5rc3.fsf@wanadoo.es> X-Google-Sender-Auth: rvnaWbBzK8rPoWOPJDgsHgjUJIs X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4002:c05::231 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:202535 Archived-At: Hi all, On Thu, Mar 31, 2016 at 10:23 PM, =C3=93scar Fuentes wrote= : > consequences.) How objects created by the module system interact with > garbage collection is an start. Every emacs_value allocated inside a Lisp-exposed function becomes invalid when control of the function ends (when it exits) unless you return that value or you mark it global with the the env->make_global_ref() API call. As I was googling for a browseable emacs git repo to look quickly at emacs-module.h I've noticed that Syohei Yoshida (cc'ed) has figured a lot of things out by himself (kudos to you!) and has already made some simple and not-so-simple modules: - dead simple module that exposes an ioctl syscall to Lisp https://github.com/syohex/emacs-eject - json parser/encoder https://github.com/syohex/emacs-parson this one is interesting because he has done some benchmarks! - libGeoIP binding https://github.com/syohex/emacs-geoip - libbarcode binding https://github.com/syohex/emacs-barcode - libmemcached binding https://github.com/syohex/emacs-memcached - libyaml binding https://github.com/syohex/emacs-libyaml - libqrencode binding https://github.com/syohex/emacs-qrencode - embedded Lua interpreter https://github.com/syohex/emacs-lua - embedded Ruby interpreter https://github.com/syohex/emacs-mruby-test - wrapper that lets you implement modules in Nim https://github.com/yuutayamada/nim-emacs-module I've looked briefly at most of them and I think they are good examples. Especially how he only implements low-level functionality of package xyz in a xyz-core module which is exactly how I envisioned it. - Tom Tromey has also made a binding on libffi which means you can call C stuff from Lisp without writing a module. https://github.com/tromey/emacs-ffi It seems the japanese-speaking Emacs community has picked up on the modules feature quite fast. I found several article/blog about it. Too bad I can't read it, it looks interesting :) - article on how the emacs-eject module was done http://syohex.hatenablog.com/entry/2015/12/16/185458 - article on the module feature with *benchmarks* and side-by-side code comparison. Very cool! http://coldnew.github.io/blog/2015/01/03_emacsdynamic/ Syohei, I really like what you did and I would be interested in your feedback on what could be improved, what should we add&optimize in the module API, etc. Thanks!