From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jeremiah Dodds Newsgroups: gmane.emacs.help Subject: Looking for some general approaches to problems I'm having writing an elisp library Date: Thu, 25 Oct 2012 18:33:49 -0400 Message-ID: <87ip9ygp0y.fsf@friendface.i-did-not-set--mail-host-address--so-tickle-me> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1351204438 10945 80.91.229.3 (25 Oct 2012 22:33:58 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 25 Oct 2012 22:33:58 +0000 (UTC) To: Emacs Help Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Oct 26 00:34:06 2012 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 1TRW06-0008Hb-AH for geh-help-gnu-emacs@m.gmane.org; Fri, 26 Oct 2012 00:34:06 +0200 Original-Received: from localhost ([::1]:44522 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TRVzy-0008A7-Ha for geh-help-gnu-emacs@m.gmane.org; Thu, 25 Oct 2012 18:33:58 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:41741) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TRVzt-00089p-5a for help-gnu-emacs@gnu.org; Thu, 25 Oct 2012 18:33:54 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TRVzs-0002I9-0d for help-gnu-emacs@gnu.org; Thu, 25 Oct 2012 18:33:53 -0400 Original-Received: from mail-ia0-f169.google.com ([209.85.210.169]:44755) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TRVzr-0002H9-RV for help-gnu-emacs@gnu.org; Thu, 25 Oct 2012 18:33:51 -0400 Original-Received: by mail-ia0-f169.google.com with SMTP id h37so2144422iak.0 for ; Thu, 25 Oct 2012 15:33:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:user-agent:mime-version :content-type; bh=+9iJALdRp15jgkbxiDIHJRk3Ew+ce2ggQi3I2btKqk8=; b=Y+dr0GhYRMxsIuYN2od8b6/KsiFNIRytfMU2JjJhOJqZHKCpjW0X6/YM2l9xPz3pDp +RIaQqJRZrwnhGroshco5CSNapuXxCqs8Txv5J/hhtPJ9h49UDZdWaKIyPRDmqBU8DS8 aFZT+g9ggTrkww6mvOmLYkX8vdp79/SEBkexJqS1GSht1WRUAI6dgjraSdf7f31o1s6r hv+d9zKnEtaHlznG1Vy/zGzfAAuyQXUioiAiy0sdCG3bX4bZ48FlCzJM+e078/rd9tpD wZWklxXmLIVz5Qv2OiMU7XBN+mNDgeiD0vRhSIcOqPXwzOZTqJobeemAps4e0zXyTHBm PKQA== Original-Received: by 10.50.185.168 with SMTP id fd8mr204069igc.51.1351204431204; Thu, 25 Oct 2012 15:33:51 -0700 (PDT) Original-Received: from friendface (cpe-98-27-142-179.neo.res.rr.com. [98.27.142.179]) by mx.google.com with ESMTPS id bh3sm5341590igc.0.2012.10.25.15.33.49 (version=SSLv3 cipher=OTHER); Thu, 25 Oct 2012 15:33:50 -0700 (PDT) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.210.169 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:87425 Archived-At: I'm writing an elisp library that's meant to be used by other elisp code. It provides communication with a REST API, the goal is to allow other packages to talk to the API via relevantly-named function calls, I'm writing one client package in tandem with the library. The API requires an authorization token to be passed in order to allow read access to "private" things, or write access to anything. I could use a single auth token for the library itself, but that seems like a bad idea -- it's more of a middleman than the application performing operations. The obvious solution is to store an auth token per client-application, the issue I'm having is how this should be exposed. I'd like to avoid forcing client code to be redundant. Approaches I've thought up: + require client code to pass it's name on each request. + when a client application becomes known to the library, define wrappers for the various api functions. I feel like the "right" way to go about this is something like the second approach, I know this is the type of thing that lisps are fine at handling, but I'm not familiar enough with elisp to know but what the appropriate way to handle this is. Does anyone who breathes elisp have a "best practice" for something like the following simplified scenario: Client packages A and B both use library C. C provides a function, 'c-get-some-data' that both A and B would like to call. 'c-get-some-data' needs to be able to use a value that is specific to the package calling it, that value is unlikely to change once set. How can I make sure that if A and B are both making calls to 'c-get-some-data' that the correct value is being used without resorting to making the call look like (c-get-some-data "A") or similar? Or does it sound like I'm thinking about the problem incorrectly? -- Jeremiah Dodds blog : http://jdodds.github.com github : https://github.com/jdodds freenode : exhortatory twitter : kaens