From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#35018: 26.1; Use diff as en ert-explainer for string= Date: Mon, 01 Apr 2019 21:05:01 -0400 Message-ID: <87imvxgqte.fsf@gmail.com> References: <87a7hgpqlg.fsf@ambrevar.xyz> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="66562"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1.91 (gnu/linux) Cc: 35018@debbugs.gnu.org To: Pierre Neidhardt Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Apr 02 03:06:20 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 1hB7sa-000HBb-7L for geb-bug-gnu-emacs@m.gmane.org; Tue, 02 Apr 2019 03:06:20 +0200 Original-Received: from localhost ([127.0.0.1]:50133 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hB7sZ-0001eq-4W for geb-bug-gnu-emacs@m.gmane.org; Mon, 01 Apr 2019 21:06:19 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:43347) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hB7sS-0001Yg-Vy for bug-gnu-emacs@gnu.org; Mon, 01 Apr 2019 21:06:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hB7sN-0008G9-Az for bug-gnu-emacs@gnu.org; Mon, 01 Apr 2019 21:06:09 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54842) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hB7sH-0008C7-Vg for bug-gnu-emacs@gnu.org; Mon, 01 Apr 2019 21:06:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hB7sH-0007oo-MC for bug-gnu-emacs@gnu.org; Mon, 01 Apr 2019 21:06:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 02 Apr 2019 01:06:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35018 X-GNU-PR-Package: emacs Original-Received: via spool by 35018-submit@debbugs.gnu.org id=B35018.155416711229983 (code B ref 35018); Tue, 02 Apr 2019 01:06:01 +0000 Original-Received: (at 35018) by debbugs.gnu.org; 2 Apr 2019 01:05:12 +0000 Original-Received: from localhost ([127.0.0.1]:40153 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hB7rU-0007nS-Ic for submit@debbugs.gnu.org; Mon, 01 Apr 2019 21:05:12 -0400 Original-Received: from mail-qk1-f178.google.com ([209.85.222.178]:44968) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hB7rS-0007n5-0D; Mon, 01 Apr 2019 21:05:10 -0400 Original-Received: by mail-qk1-f178.google.com with SMTP id y5so6888083qkc.11; Mon, 01 Apr 2019 18:05:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=9yTaVMbTfdkxPYTynoecC4Rz8cN+ZLX3itujc/XKHX4=; b=FQzFFl9BCuUmL7CxV+fSOLASKEX3RkTgECtHAtspQTiFwr1bwlipDFiG3NifjTPfGZ sXjSqR/5naFlApOB3LAk5yn8eSg1tcIDyWq5PAxV77cWyRBIN+SO7ukGRTxwpbU1x2Uq N28jEI1q8PffQUJmTmNX650LXyc518F+HkLlODUiiIGApdNhVFZURdfXo7H++ODsgTjw Nkd62JI6Fu+InHxgOkYdwrbv7DQH1INv+hIeuKc/fCSlLdgL3Q9Z8q+QCILVBXtGTWwL WwTZaiTeApZIA/fNBBdZvyZCllLEAbaP4/PqRpAAV5FMctCkREPdlnPoMz3PyYzbpCXt btwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=9yTaVMbTfdkxPYTynoecC4Rz8cN+ZLX3itujc/XKHX4=; b=JyIbT2bkfDlhoNRZgDGPF2URR3pmdRVUC4a1tExqW14vum4JDLP2UougscGZ+hpRqJ YiPS28rFQQNdeQ/LOPzMQuwy4wEc/IGkN5nuARqSjGEUOrzkcTXSg1BLwagdGeD8m7IU C7G7GxeySF/RHW+785eZWZWp7FIg2HaevlKqn5Rj+i8GcQjmTqLQ0ZbMoWaVsP3cTyWF 1Yiha/BFT5ivvBpKvgCg/JRxcyJEEQnz/tX6KCCCZ41hRmvNktThryuUxm6PDJt4e1vB Rp+j3vo7UgXwYA+DZ0qTcm4NKX6zReh7tJpDomf2HLWhm1L8tH0dtBd9xAERt2lNPRah r2LQ== X-Gm-Message-State: APjAAAWN/hqSZjVVfcFQtfwz8xWFZIdoTP5E5WhFsdyKVJGbhU3bQ/ll fg8SxXcZaLwACWzrhorr4/wttBEJ X-Google-Smtp-Source: APXvYqzJKiiJmUukdGpshQ+/9HOA2JO86HuVOXvgPS8CQW1Xwh/6GAcog638ZWFZa5Nbw4L6oWINfg== X-Received: by 2002:ae9:e21a:: with SMTP id c26mr54370089qkc.293.1554167104204; Mon, 01 Apr 2019 18:05:04 -0700 (PDT) Original-Received: from minid (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.googlemail.com with ESMTPSA id 46sm7804747qtz.87.2019.04.01.18.05.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Apr 2019 18:05:03 -0700 (PDT) In-Reply-To: <87a7hgpqlg.fsf@ambrevar.xyz> (Pierre Neidhardt's message of "Wed, 27 Mar 2019 11:19:07 +0100") 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:157069 Archived-At: severity 35018 wishlist quit Pierre Neidhardt writes: > I've just committed webfeeder.el to ELPA. In his review, Stefan Monnier > suggested we merged the following code snippet upstream: > > (defun webfeeder--string=-explainer (string-a string-b) > "Return the diff output of STRING-A and STRING-B" > (unless (string= string-a string-b) I guess a diff won't help so much for single line strings, so maybe the condition should check for that? e.g. (or (string= string-a string-b) (not (string-match-p "\n" string-a)) (not (string-match-p "\n" 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)) Isn't the diff-no-select redudant, since diff already calls it? > (buffer-string))) > result) You don't need the 'result' variable here, just make the (with-temp-buffer...) the last expression in the let (which could then be converted to progn). > (delete-file file-a) > (delete-file file-b))))) You should check that each of file-a and file-b are non-nil before trying to delete (in case either make-temp-file signals an error).