From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.devel Subject: Re: Some testing issues Date: Mon, 17 Jul 2017 12:02:25 +0200 Message-ID: <87tw2bv0su.fsf@rosalinde> References: <8737a8j61r.fsf@rosalinde> <87wp7jnfpz.fsf@rosalinde> <87mv87gx4r.fsf@rosalinde> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1500285831 26849 195.159.176.226 (17 Jul 2017 10:03:51 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 17 Jul 2017 10:03:51 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jul 17 12:03:47 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dX2sT-0006fo-Pn for ged-emacs-devel@m.gmane.org; Mon, 17 Jul 2017 12:03:45 +0200 Original-Received: from localhost ([::1]:49131 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX2sZ-0003Ri-C5 for ged-emacs-devel@m.gmane.org; Mon, 17 Jul 2017 06:03:51 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56127) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX2rQ-0003QE-SM for emacs-devel@gnu.org; Mon, 17 Jul 2017 06:02:41 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dX2rM-0008JR-RA for emacs-devel@gnu.org; Mon, 17 Jul 2017 06:02:40 -0400 Original-Received: from mout.gmx.net ([212.227.17.20]:56132) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dX2rM-0008IB-GU for emacs-devel@gnu.org; Mon, 17 Jul 2017 06:02:36 -0400 Original-Received: from rosalinde ([83.135.12.56]) by mail.gmx.com (mrgmx102 [212.227.17.168]) with ESMTPSA (Nemesis) id 0LmNHK-1e6eae3yVe-00ZweC; Mon, 17 Jul 2017 12:02:27 +0200 In-Reply-To: (Stefan Monnier's message of "Fri, 14 Jul 2017 09:44:10 -0400") X-Provags-ID: V03:K0:VeHibtBxPyTgoMLevhv3uJsYyVf89xTxgwMKLstPYH31yxRAnuw g3wPbwNDYFEWEiIjLGGDm7dJkmHedQOXH5PYJaXzwxhlViLLtg5WDPj0m3FnG5YJBz1sBEO lp80Zk89xTl82r1znyWgLufSAMY6cF82npG46rY8QJq/9Ylz+CgTKaSzcs0r0OeAsqbBb5o Pm4dokOSmevG3cZaYWguw== X-UI-Out-Filterresults: notjunk:1;V01:K0:1yLd74RrRzI=:qpNNdnOiv84vtCm3pjc0AQ OFhBXbnKEfgBLnJDiv/c4repzqVyV6qkSuncFb5dPJJVrGAxG6Jf+AD7Afd2SxTZLDqHKV5TY 8w97Es5rfE6Z3Ufu6dll9hDsEd8nNawyNC+8qhnYFuXbtUzie6gmS/t+zoKFdqxFXHGaIxm7j u1SOSz37pmvB3xz4pw+mupYTIhc7411PhrF2zgVf2ksoOLaEuljCdjP/mqHs8qPP3YsZ33T16 VrVOt9MK8b95rbVKnaYqkyiI+siIAceW4/8Flx705iWPxelZIuHhD5C1GbWwOsaomQz5tT+Xh kGpXewtHGcsXLE2hEQzm+HVajBNQiMSFjqL7WP3z8Zo3v3Ne0hK2prQQTw0i2YoNMlhXdVsAw Fs48n2PFjF5IYIqCpkoLFju3iH7lWuD1Sm4ynlSq4Dkp/23kWfe0tSPiK1w7qmCZqe0PMp4bT tyO1jCAGlL69rEtbCY9G8kvUHkUdG4bWsTiDHj9qpqlNV2sXfCo067zCe86Rk1QnzuAxCuVvB sAEqjm35gspplA7NLP9HIKS0DAK+dWAw7kL5l/SWepRHlqKT0wjQn/c2gsNt46X/eYqni/rbP BU6JokTmRW7yWiH+6z9z3daQy+VWKdE3eoVLe2o9MRixEqnV9iN/hQMGA/bkEN3ctIHdT3Glg NvxIyYS2pJTtA76ltKd+LbnUXqIPvfk4uWqr/S5t38ekYBJksrb+IG10RLE8EXEFaUeHQFCaZ E9WsI1j+7CAMnnxLHuf8z2LeKR/m88usm43DuPh7bjijrIuZ94Gjjrsjksadq0435/mEeO4y X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.17.20 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:216765 Archived-At: On Fri, 14 Jul 2017 09:44:10 -0400 Stefan Monnier 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