From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 21416 invoked from network); 6 Sep 2020 22:22:47 -0000 Received: from lists1.math.uh.edu (129.7.128.208) by inbox.vuxu.org with ESMTPUTF8; 6 Sep 2020 22:22:47 -0000 Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by lists1.math.uh.edu with smtp (Exim 4.94) (envelope-from ) id 1kF33I-00CMwx-NC; Sun, 06 Sep 2020 17:22:24 -0500 Received: from mx1.math.uh.edu ([129.7.128.32]) by lists1.math.uh.edu with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1kF33D-00CMuy-RR for ding@lists.math.uh.edu; Sun, 06 Sep 2020 17:22:19 -0500 Received: from quimby.gnus.org ([95.216.78.240]) by mx1.math.uh.edu with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1kF33C-007DWy-7h for ding@lists.math.uh.edu; Sun, 06 Sep 2020 17:22:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Transfer-Encoding:Content-Type:Mime-Version:References :Message-ID:Date:Subject:From:To:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=tca7pgz8Lx0A+/X5c6+gmTz04UCMsqorwW4lamzaxFg=; b=GtLmZ/GS3aBSvUr+OlU9IhrtqR s5pfdo8msCdprFDEKaI35pZUoLGGPxra3R5uzuIJGzm9oF++Pm+cuDeX4a+Kas6K9DLBWqwFc3QIf D8OR5uZKhpPHUUZL6rdf8ZyR/QAPUS/jK/9vC0tsAMkghLFu6Aoy5omiLLa1F1v0eIzY=; Received: from static.214.254.202.116.clients.your-server.de ([116.202.254.214] helo=ciao.gmane.io) by quimby with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kF333-0006bc-TI for ding@gnus.org; Mon, 07 Sep 2020 00:22:13 +0200 Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1kF332-000199-SW for ding@gnus.org; Mon, 07 Sep 2020 00:22:08 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: ding@gnus.org From: Eric Abrahamsen Subject: Re: GitLab integration take two, light edition Date: Sun, 06 Sep 2020 15:22:03 -0700 Message-ID: <87pn6ysfzo.fsf@ericabrahamsen.net> References: <87k0xi79qt.fsf@tullinup.koldfront.dk> <87wo1hffz0.fsf@ericabrahamsen.net> <87d02yss6h.fsf@tullinup.koldfront.dk> <87tuwashjf.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cancel-Lock: sha1:VgMyeD8qvRT8i5FmKxNEmY1RdrY= List-ID: Precedence: bulk Eric Abrahamsen writes: > Adam Sjøgren writes: > >> Eric writes: >> > > [...] > >> It's just a list of lists of conses, so if only I could remember which >> is which of car and cadr, it would indeed be easy. >> >> This is what I have currently: >> >> (defun adsj-article-treat-gitlab () >> "Show thumbsup on GitLab comments" >> (when (and gnus-treat-type (string= gnus-treat-type "text/html")) >>;;; (gnus-with-article-buffer >> (let ((project-id (gnus-fetch-field "X-GitLab-Project-Id")) >> (issue-iid (gnus-fetch-field "X-GitLab-Issue-IID")) >> (message-id (gnus-fetch-field "Message-ID"))) >> (when project-id >> (string-match "> (ignore-errors >> (let ((emojis (ghub-request "GET" (format "/projects/%s/issues/%s/notes/%s/award_emoji" project-id issue-iid (match-string 1 message-id)) nil :auth 'nngitlab :host "gitlab.nzcorp.net/api/v4" :username "adsj" :forge 'gitlab)) >> (name-to-emoji '(("thumbsup". "👍")))) >> (widen) >> (message-goto-eoh) >> (dolist (emoji emojis) >> (let ((name (cdr (assoc-string "name" emoji)))) >> (insert "GitLab-Emoji: " (cdr (or (assoc-string name name-to-emoji) `("default" . ,name))) "\n")))))))))) >> >> (add-hook 'gnus-part-display-hook 'adsj-article-treat-gitlab) >> >> The mapping of name-to-emoji needs to be expanded. >> >> Ideally I'd rewrite it to do a map and join over the list, so I'd get a >> single header with a comma-separated list of emojis, if there is more >> than one. > > `mapconcat' is what you're looking for there, something like: > > (insert "GitLab-Emoji: " > (mapconcat > (lambda (emo) > (assoc-string emo name-to-emoji)) > emojis)) Bah, brain fart: mapconcat takes a third argument, the string to insert between all the elements.