From: Noam Postavsky <npostavs@gmail.com>
To: Pierre Neidhardt <mail@ambrevar.xyz>
Cc: 35018@debbugs.gnu.org
Subject: bug#35018: 26.1; Use diff as en ert-explainer for string=
Date: Mon, 01 Apr 2019 21:05:01 -0400 [thread overview]
Message-ID: <87imvxgqte.fsf@gmail.com> (raw)
In-Reply-To: <87a7hgpqlg.fsf@ambrevar.xyz> (Pierre Neidhardt's message of "Wed, 27 Mar 2019 11:19:07 +0100")
severity 35018 wishlist
quit
Pierre Neidhardt <mail@ambrevar.xyz> 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).
next prev parent reply other threads:[~2019-04-02 1:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-27 10:19 bug#35018: 26.1; Use diff as en ert-explainer for string= Pierre Neidhardt
2019-04-02 1:05 ` Noam Postavsky [this message]
2019-04-02 7:59 ` Pierre Neidhardt
2021-06-23 13:42 ` Lars Ingebrigtsen
2021-06-24 7:06 ` Pierre Neidhardt
2021-06-24 14:52 ` Lars Ingebrigtsen
2021-06-24 15:59 ` Pierre Neidhardt
2021-10-12 15:33 ` Lars Ingebrigtsen
2021-10-12 17:23 ` Pierre Neidhardt
2021-10-13 11:21 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87imvxgqte.fsf@gmail.com \
--to=npostavs@gmail.com \
--cc=35018@debbugs.gnu.org \
--cc=mail@ambrevar.xyz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).