[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: good examples of Emacs modules?

From: Eli Zaretskii
Subject: Re: good examples of Emacs modules?
Date: Fri, 01 Apr 2016 09:23:13 +0300

> From: Óscar Fuentes <address@hidden>
> Date: Thu, 31 Mar 2016 22:23:56 +0200
> Some APIs are session-based. Those give the user an object that lives
> through the session and needs to be disposed at the end. On the case of
> VC or Magit, Emacs would request from libgit2 to work with a given repo,
> operate on it and close the session. That means that if the user kills
> the magit-status buffer that was visiting a repo, the associated session
> object must be closed (this is a simplistic scenario, in practice things
> are more complicated.) It would be nice to explain how to handle this
> use case on a robust way (the failure to properly close a session,
> transaction, whatever on some packages can produce very annoying
> consequences.) How objects created by the module system interact with
> garbage collection is an start.

I think you want to wrap some kind of "handle" that is meaningful to
libgit2 into a user-ptr object (see the existing docs about modules
for details about these).  A user-ptr object has a finalizer, a
function that is called by GC when the object goes out of scope.  The
finalizer function should do whatever libgit2 needs to close the
session and free whatever resources the session used.

You have a demo if using a user-ptr in modules/mod-test/.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]