From: Stephen Berman <stephen.berman@gmx.net>
To: Stefan Monnier <monnier@IRO.UMontreal.CA>
Cc: emacs-devel@gnu.org
Subject: Re: Some testing issues
Date: Mon, 17 Jul 2017 12:02:25 +0200 [thread overview]
Message-ID: <87tw2bv0su.fsf@rosalinde> (raw)
In-Reply-To: <jwv1spj9lwy.fsf-monnier+Inbox@gnu.org> (Stefan Monnier's message of "Fri, 14 Jul 2017 09:44:10 -0400")
On Fri, 14 Jul 2017 09:44:10 -0400 Stefan Monnier <monnier@IRO.UMontreal.CA> wrote:
>> Well, as I noted, when pos-visible-in-window-p is called in
>> todo-toggle-view-done-items, the selected window is displaying the
>> current buffer and AFAICT that can't go wrong when using todo-mode as
>> intended (i.e., not invoking todo-toggle-view-done-items outside of
>> todo-mode).
>
> Then I suggest you add a (cl-assert (eq (current-buffer)
> (window-buffer))) and then declare that it's the caller's responsibility
> (e.g. the test environment) to make sure this is true.
The tests have assumed this responsibility with the invocation of
set-window-buffer.
> This said, another approach is to say that `recenter` is simply not
> needed in case the buffer is not displayed anywhere (which could
> presumably happen if you call this code from some ad-hoc Elisp
> function), so if (eq (current-buffer) (window-buffer)) is nil, just
> don't bother checking visibility nor recentering.
If I'm not misunderstanding you, I think adding this check, or the above
assertion, to this defun in todo-mode.el is an unwarrented precaution,
because it assumes a use of todo-toggle-view-done-items other than the
one it was defined for. In principle that's possible, but the same goes
for any Elisp command, and the vast majority of them surely take no such
precautions. There are a few todo-mode commands that are intended to be
called from outside of todo-mode, and for these I have tried to make
sure they DTRT, but for the others, as with most specialized elisp
commands, don't you think it's reasonable, and sufficient, to rely on
the user's common sense? (The case of tests is, of course, different,
but as you note, it is (or should be) their responsibility to satisfy
the assumptions of the code being tested, I think even if the
assumptions aren't made explicit in the code.)
Steve Berman
next prev parent reply other threads:[~2017-07-17 10:02 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-07 21:22 Some testing issues Stephen Berman
2017-07-08 4:20 ` Noam Postavsky
2017-07-08 14:50 ` Stephen Berman
2017-07-08 22:01 ` Noam Postavsky
2017-07-14 9:55 ` Stephen Berman
2017-07-08 4:45 ` Stefan Monnier
2017-07-08 14:52 ` Stephen Berman
2017-07-10 17:33 ` Stefan Monnier
2017-07-14 9:56 ` Stephen Berman
2017-07-14 13:44 ` Stefan Monnier
2017-07-17 10:02 ` Stephen Berman [this message]
2017-07-17 18:22 ` Stefan Monnier
2017-07-08 7:18 ` martin rudalics
2017-07-08 14:51 ` Stephen Berman
2017-07-09 7:46 ` martin rudalics
2017-07-14 9:55 ` Stephen Berman
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87tw2bv0su.fsf@rosalinde \
--to=stephen.berman@gmx.net \
--cc=emacs-devel@gnu.org \
--cc=monnier@IRO.UMontreal.CA \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.