From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nicolas Petton Newsgroups: gmane.emacs.devel Subject: [OT] Working with patches inlined in emails (was: Using gv in map and seq?) Date: Thu, 18 Jun 2015 10:31:20 +0200 Message-ID: <87zj3x5sfb.fsf@petton.fr> References: <87egldxn7p.fsf@petton.fr> <878ublkrqe.fsf@petton.fr> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Trace: ger.gmane.org 1434616330 23683 80.91.229.3 (18 Jun 2015 08:32:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 18 Jun 2015 08:32:10 +0000 (UTC) Cc: emacs-devel To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jun 18 10:31:56 2015 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 1Z5VEp-0006pg-2X for ged-emacs-devel@m.gmane.org; Thu, 18 Jun 2015 10:31:55 +0200 Original-Received: from localhost ([::1]:50880 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5VEo-0005DN-IN for ged-emacs-devel@m.gmane.org; Thu, 18 Jun 2015 04:31:54 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50227) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5VEP-0004mR-Tb for emacs-devel@gnu.org; Thu, 18 Jun 2015 04:31:31 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z5VEJ-0004kr-Qq for emacs-devel@gnu.org; Thu, 18 Jun 2015 04:31:29 -0400 Original-Received: from out5-smtp.messagingengine.com ([66.111.4.29]:33280) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5VEJ-0004im-LI for emacs-devel@gnu.org; Thu, 18 Jun 2015 04:31:23 -0400 Original-Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 081FE20B4B for ; Thu, 18 Jun 2015 04:31:22 -0400 (EDT) Original-Received: from frontend1 ([10.202.2.160]) by compute1.internal (MEProxy); Thu, 18 Jun 2015 04:31:22 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=smtpout; bh=YKJK1IeXmjxQTvYdYR93kgniheY=; b=gvpkr r/k46iZH3wDiYKndMEZMQOQ2J9NLBBT7E9wZhjVzRPtATDcZgW3kI5uX/xfXNbHc KYpXZWLFFfLfsD/fD6iFWC2LU9b77PcYyIfC/CEij4V6r919BodW6a3xvAXKRRnB M7VY+FrrVdrf1FrdPFkxNCyMD0tON5HoWb8K+8= X-Sasl-enc: xpZPA/BW/kIONbAdQnsF6bnHhK5havTqn1QF7FSaYV3C 1434616281 Original-Received: from blueberry (unknown [31.211.216.84]) by mail.messagingengine.com (Postfix) with ESMTPA id 61254C0001F; Thu, 18 Jun 2015 04:31:21 -0400 (EDT) In-Reply-To: User-Agent: Notmuch/0.19 (http://notmuchmail.org) Emacs/24.5.1 (x86_64-redhat-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.29 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:187272 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Stefan Monnier writes: > diff --git a/lisp/emacs-lisp/map.el b/lisp/emacs-lisp/map.el > index dd7fb91..26ad6ce 100644 > --- a/lisp/emacs-lisp/map.el > +++ b/lisp/emacs-lisp/map.el > @@ -82,25 +82,19 @@ The following keyword types are meaningful: `:list', >=20=20 > An error is thrown if MAP is neither a list, hash-table nor array. >=20=20 > -Return RESULT if non-nil or the result of evaluation of the > -form. > +Return RESULT if non-nil or the result of evaluation of the form. >=20=20 > \(fn (VAR MAP [RESULT]) &rest ARGS)" > (declare (debug t) (indent 1)) > (unless (listp spec) > (setq spec `(,spec ,spec))) > - (let ((map-var (car spec)) > - (result-var (make-symbol "result"))) > - `(let ((,map-var ,(cadr spec)) > - ,result-var) > - (setq ,result-var > - (cond ((listp ,map-var) ,(plist-get args :list)) > - ((hash-table-p ,map-var) ,(plist-get args :hash-table= )) > - ((arrayp ,map-var) ,(plist-get args :array)) > - (t (error "Unsupported map: %s" ,map-var)))) > - ,@(when (cddr spec) > - `((setq ,result-var ,@(cddr spec)))) > - ,result-var))) > + (let ((map-var (car spec))) > + `(let* ,(unless (eq map-var (cadr spec)) `((,map-var ,(cadr spec)))) > + (cond ((listp ,map-var) ,(plist-get args :list)) > + ((hash-table-p ,map-var) ,(plist-get args :hash-table)) > + ((arrayp ,map-var) ,(plist-get args :array)) > + (t (error "Unsupported map: %s" ,map-var))) > + ,@(cddr spec)))) >=20=20 > (defun map-elt (map key &optional default) > "Perform a lookup in MAP of KEY and return its associated value. > @@ -109,27 +103,23 @@ If KEY is not found, return DEFAULT which defaults = to nil. > If MAP is a list, `equal' is used to lookup KEY. >=20=20 > MAP can be a list, hash-table or array." > + (declare > + (gv-expander > + (lambda (do) > + (macroexp-let2* nil > + ;; Eval them once and for all in the right order. > + ((map map) (key key) (default default)) > + `(map--dispatch map > + :list ,(gv-get `(alist-get ,key ,map ,default) do) > + :hash-table ,(funcall do `(gethash ,key ,map ,default) > + (lambda (v) `(puthash ,key ,v ,map))) > + :array ,(funcall do `(aref ,map ,key) > + (lambda (v) `(aset ,map ,key ,v)))))))) > (map--dispatch map > :list (map--elt-list map key default) > :hash-table (gethash key map default) > :array (map--elt-array map key default))) >=20=20 > -(defmacro map-put (map key value) > - "In MAP, associate KEY with VALUE and return MAP. > -If KEY is already present in MAP, replace the associated value > -with VALUE. > - > -MAP can be a list, hash-table or array." > - (declare (debug t)) > - (let ((symbol (symbolp map))) > - `(progn > - (map--dispatch (m ,map m) > - :list (if ,symbol > - (setq ,map (cons (cons ,key ,value) m)) > - (error "Literal lists are not allowed, %s must be a sym= bol" ',map)) > - :hash-table (puthash ,key ,value m) > - :array (aset m ,key ,value))))) > - > (defmacro map-delete (map key) > "In MAP, delete the key KEY if present and return MAP. > If MAP is an array, store nil at the index KEY. This is a bit off-topic, but I'm wondering how people work with emails in Emacs containing patches in the body of the email. With patches sent as attachments it's straightforward, but for example here for this patch I had to yank the content in a new buffer, trim the spaces at the beginning of each line, etc. which is clearly not efficient (I use notmuch). Cheers, Nico =2D-=20 Nicolas Petton http://nicolas-petton.fr --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: GPGTools - http://gpgtools.org iQEcBAEBAgAGBQJVgoHYAAoJECM1h6R8IHkQwDoIAKPJTKbse7dDpnR1o8oKbV9J 1Q0ASK6U4n+5qmmOlPRMhz9qzIwAcSddg8WPW5rtju9Hn9FSMoJtNSg8e7WVZlfm KoMyB52WhYNbR9mM8hQZA8ugCGEglkPLATPHNjWnPYG4xXiWZ4zM7Jep9/Rw5MiJ v+/awo+RUY+uVnTg/tEauiJogrEIxkXc/xOT1X3YZBVePuKH5FB7YDB85G/ZdYku eJrF+cgwN4jgDYMBEx2XWJ+0miQmLJvUPQOHcPCIXITDrpjWM0a+nfPhkvYkvw5/ jxobUI/GJzZs5xZBL5wkS0XEdFruEVWDCPAaY4yYqFRcahcqo7lCIwBwdvO9Ea0= =to2w -----END PGP SIGNATURE----- --=-=-=--