GNU bug report logs - #35018
26.1; Use diff as en ert-explainer for string=

Previous Next

Package: emacs;

Reported by: Pierre Neidhardt <mail <at> ambrevar.xyz>

Date: Wed, 27 Mar 2019 10:20:02 UTC

Severity: wishlist

Tags: wontfix

Found in version 26.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #13 received at 35018 <at> debbugs.gnu.org (full text, mbox):

From: Pierre Neidhardt <mail <at> ambrevar.xyz>
To: Noam Postavsky <npostavs <at> gmail.com>
Cc: 35018 <at> debbugs.gnu.org
Subject: Re: bug#35018: 26.1; Use diff as en ert-explainer for string=
Date: Tue, 02 Apr 2019 09:59:59 +0200
[Message part 1 (text/plain, inline)]
Thanks for the review!

Noam Postavsky <npostavs <at> gmail.com> writes:

>> (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))

Yes, this is very nice!

>>     (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?

The first diff is a typo.  It should be diff-no-select only.

Cheers!

-- 
Pierre Neidhardt
https://ambrevar.xyz/
[signature.asc (application/pgp-signature, inline)]

This bug report was last modified 3 years and 223 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.