From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#49944: parse-partial-sexp fails to signal an error when (> START LIMIT). Date: Tue, 10 Aug 2021 10:41:30 -0400 Message-ID: References: <87r1f36by6.fsf@gnus.org> <87pmum4wnm.fsf@gnus.org> <87a6lpz9vq.fsf@gnus.org> <83mtppflcu.fsf@gnu.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38624"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: acm@muc.de, Lars Ingebrigtsen , 49944@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Aug 10 16:42:16 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mDSxM-0009oN-IB for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 10 Aug 2021 16:42:16 +0200 Original-Received: from localhost ([::1]:57498 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mDSxL-0005FA-He for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 10 Aug 2021 10:42:15 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59478) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mDSx9-00059W-8j for bug-gnu-emacs@gnu.org; Tue, 10 Aug 2021 10:42:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48715) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mDSx9-0008AB-1C for bug-gnu-emacs@gnu.org; Tue, 10 Aug 2021 10:42:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mDSx8-0002UJ-Vt for bug-gnu-emacs@gnu.org; Tue, 10 Aug 2021 10:42:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 10 Aug 2021 14:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49944 X-GNU-PR-Package: emacs Original-Received: via spool by 49944-submit@debbugs.gnu.org id=B49944.16286065119537 (code B ref 49944); Tue, 10 Aug 2021 14:42:02 +0000 Original-Received: (at 49944) by debbugs.gnu.org; 10 Aug 2021 14:41:51 +0000 Original-Received: from localhost ([127.0.0.1]:60260 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mDSwt-0002Tb-PS for submit@debbugs.gnu.org; Tue, 10 Aug 2021 10:41:51 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:14174) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mDSwl-0002Sm-02 for 49944@debbugs.gnu.org; Tue, 10 Aug 2021 10:41:46 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 282DB809BD; Tue, 10 Aug 2021 10:41:33 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id CC8548090F; Tue, 10 Aug 2021 10:41:31 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1628606491; bh=IspDI06MtjTBNHijohm5HxTs1evnJ/hjs2EP8ThKBgc=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=o5N8dzM023QH0/JCfgSm9eo0bdlBCvPqfz0NiMFiUSE9EQTW3Z0xIKISVm0FT7H9M TuE3duCh+6xG473du2QDmruKwQpjfV7LcjUqJ/E0GIJ3lmTTybUE/IBFZ95B2dhNs3 YQDaT7eLW8ePoRmiw6ZbPNGFXbsHecioHZ0NW+6VrXzDxZBKv+fOAF6AiLatAXV4dS UUQnGz0yQPtwGWouemP+6rCEcQatILNpLKzhcTJ1GH8J4YkO0v6prci9/TE+DbD1R6 nIS8/cmgKiUbvhfmHvT38Y12gNvtsH50Inl4iTdMooOjBHueotKDAvz6UGSci7zcXZ P1uJnimoKdHuA== Original-Received: from alfajor (104-222-120-40.cpe.teksavvy.com [104.222.120.40]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 97239120163; Tue, 10 Aug 2021 10:41:31 -0400 (EDT) In-Reply-To: <83mtppflcu.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 10 Aug 2021 17:03:13 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:211506 Archived-At: >> > We definitely have a bug here. The documentation in the elisp manual >> > says that the scanning is done "starting at START". You're saying it's >> > perfectly OK to start scanning at "LIMIT"? This violates the doc. >> >> This is what all function like this say. To take patient zero -- >> narrow-to-region: >> >> --- >> When calling from Lisp, pass two arguments START and END: >> positions (integers or markers) bounding the text that should >> remain visible. >> --- >> >> Nothing here about allowing END to come before START, but it does allow >> that, and so do most (all?) similar commands. > > Indeed, if the results are predictable, I see no reason not to support > START and END in any order, as we do in many places. I think the case of `parse-partial-sexp` is different because it receives the argument OLDSTATE which provides the parser's state which should apply at START. If START and END are swapped you'll generally get an incorrect result. So, I don't care if we signal an error when START > END or if we "do nothing" (as is customary in some language's `for` loops), but we should always consider that OLDSTATE is the state that belongs with START and hence we can't start parsing at END towards START because we don't know what parsing state to use at END. Stefan