From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Pierre Neidhardt Newsgroups: gmane.emacs.bugs Subject: bug#35018: 26.1; Use diff as en ert-explainer for string= Date: Wed, 27 Mar 2019 11:19:07 +0100 Message-ID: <87a7hgpqlg.fsf@ambrevar.xyz> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="128212"; mail-complaints-to="usenet@blaine.gmane.org" To: 35018@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Mar 27 11:20:14 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h95fK-000XGi-4t for geb-bug-gnu-emacs@m.gmane.org; Wed, 27 Mar 2019 11:20:14 +0100 Original-Received: from localhost ([127.0.0.1]:45141 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h95fJ-0005Bg-3H for geb-bug-gnu-emacs@m.gmane.org; Wed, 27 Mar 2019 06:20:13 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:43877) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h95fA-0005BN-2P for bug-gnu-emacs@gnu.org; Wed, 27 Mar 2019 06:20:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h95f8-0005GC-W3 for bug-gnu-emacs@gnu.org; Wed, 27 Mar 2019 06:20:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:47332) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h95f8-0005G6-SK for bug-gnu-emacs@gnu.org; Wed, 27 Mar 2019 06:20:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1h95f8-00055x-LA for bug-gnu-emacs@gnu.org; Wed, 27 Mar 2019 06:20:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Pierre Neidhardt Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 27 Mar 2019 10:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 35018 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.155368196119520 (code B ref -1); Wed, 27 Mar 2019 10:20:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 27 Mar 2019 10:19:21 +0000 Original-Received: from localhost ([127.0.0.1]:60876 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h95eS-00054m-To for submit@debbugs.gnu.org; Wed, 27 Mar 2019 06:19:21 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:57623) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h95eR-00054Y-CI for submit@debbugs.gnu.org; Wed, 27 Mar 2019 06:19:19 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:40828) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h95eM-00052p-8F for submit@debbugs.gnu.org; Wed, 27 Mar 2019 06:19:14 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:43772) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h95eL-0004jW-4l for bug-gnu-emacs@gnu.org; Wed, 27 Mar 2019 06:19:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h95eK-00052C-0E for bug-gnu-emacs@gnu.org; Wed, 27 Mar 2019 06:19:13 -0400 Original-Received: from relay7-d.mail.gandi.net ([217.70.183.200]:57729) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h95eJ-00050H-K4 for bug-gnu-emacs@gnu.org; Wed, 27 Mar 2019 06:19:11 -0400 X-Originating-IP: 92.169.116.19 Original-Received: from bababa (lfbn-1-4117-19.w92-169.abo.wanadoo.fr [92.169.116.19]) (Authenticated sender: pierre@atlas.engineer) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id D3CD62000D for ; Wed, 27 Mar 2019 10:19:07 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:156850 Archived-At: --=-=-= Content-Type: text/plain I've just committed webfeeder.el to ELPA. In his review, Stefan Monnier suggested we merged the following code snippet upstream: --8<---------------cut here---------------start------------->8--- (defun webfeeder--string=-explainer (string-a string-b) "Return the diff output of STRING-A and STRING-B" (unless (string= string-a string-b) (let (file-a file-b) (unwind-protect (let (result) (setq file-a (make-temp-file "webfeeder") file-b (make-temp-file "webfeeder")) (with-temp-file file-a (insert string-a)) (with-temp-file file-b (insert string-b)) (setq result (with-temp-buffer ;; The following generates a *Diff* buffer which is ;; convenient for coloration. (diff file-a file-b nil 'no-async) (diff-no-select file-a file-b nil 'no-async (current-buffer)) (buffer-string))) result) (delete-file file-a) (delete-file file-b))))) ;; FIXME: Add this to ERT! (put 'string= 'ert-explainer #'webfeeder--string=-explainer) --8<---------------cut here---------------end--------------->8--- I've used this feature extensively in my ERT tests: it displays a "diff" of string A and string B, which is a pretty nice default when the strings are longer than a single line. Food for thoughts :) --=-=-= Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" --==-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable =2D-=20 Pierre Neidhardt https://ambrevar.xyz/ --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEUPM+LlsMPZAEJKvom9z0l6S7zH8FAlybThsACgkQm9z0l6S7 zH/r9Qf+K2yYToMAJppMy0GAEXcabQKsHTn7rzGSgJO4dadDP2gxQhdxaRDGFY08 djKuUR+NUzannI/3DUNx3QW7sK555VOn1f8b94jAmhogRVPabOqnx9cTMh+W24Rp tnXdeIlntRf536KBZ9U7a1rqPdKs80l8FR0k4A2y4xCHcQ5F5XM2b1uNA+kjhXgL BFMQqduqMTwswzAOjUpboQqK4I1p5B+Vs8ax4xHL3BLWW3esLLeTyJ5fXJiexZeB DlTLLaNwRFxQGjO0RmjNwVPBKevcSXalnv98nodbLIR6i0Cb8oF/SxZcJpn3kio1 +5kKgCRiOk8SjxHsgO73Q7VgtxSIBA== =gXXe -----END PGP SIGNATURE----- --==-=-=-- --=-=-=--