From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.bugs Subject: bug#66994: 30.0.50; Emacs hangs in Todo mode when moving an item to another todo file Date: Wed, 08 Nov 2023 00:13:36 +0100 Message-ID: <877cmt17j3.fsf@gmx.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27156"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: 66994@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 08 00:14:41 2023 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 1r0VHN-0006uZ-82 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 08 Nov 2023 00:14:41 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0VH7-0000nJ-86; Tue, 07 Nov 2023 18:14:26 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0VH6-0000n9-7S for bug-gnu-emacs@gnu.org; Tue, 07 Nov 2023 18:14:24 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r0VH5-0006kF-VI for bug-gnu-emacs@gnu.org; Tue, 07 Nov 2023 18:14:23 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r0VHi-0003FI-3W for bug-gnu-emacs@gnu.org; Tue, 07 Nov 2023 18:15:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stephen Berman Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 07 Nov 2023 23:15:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 66994 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.169939886912411 (code B ref -1); Tue, 07 Nov 2023 23:15:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 7 Nov 2023 23:14:29 +0000 Original-Received: from localhost ([127.0.0.1]:43733 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r0VHA-0003E6-Mp for submit@debbugs.gnu.org; Tue, 07 Nov 2023 18:14:29 -0500 Original-Received: from lists.gnu.org ([2001:470:142::17]:56540) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r0VH8-0003Ds-2k for submit@debbugs.gnu.org; Tue, 07 Nov 2023 18:14:26 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0VGQ-0008Tr-8h for bug-gnu-emacs@gnu.org; Tue, 07 Nov 2023 18:13:42 -0500 Original-Received: from mout.gmx.net ([212.227.15.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0VGO-0006gv-6p for bug-gnu-emacs@gnu.org; Tue, 07 Nov 2023 18:13:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=s31663417; t=1699398816; x=1700003616; i=stephen.berman@gmx.net; bh=HKVerjUHu0tI+i0TTtDfd5jxIpi3SRzvqGagFnyR+xI=; h=X-UI-Sender-Class:From:To:Subject:Date; b=d4LjVq7qzZE9zQV92Lry7FzpQodnpA/4godMjMp0haJ5o36GuiYUkSA5KudPNGCB b1tU8G3yG5LaO69AF9Id8IxUHWFqoxuMR9wzA4X3QNvXZUSqwlr2iF7m8XF+1lKTI Y+G5i+qHNql9u+oHxCVeLoTER3NV9aGa9knINnpN6QA8QITE3w8eiANG3QdTK8vPw g49umCJ34cKoIZDyc/IE16H/m0CkifQME+s92Ll1xGWwgIKMXKRPZ+G2lJdJxTZL+ 6T6sqsMsIO47IopzS2Q/RVOirbUwUV7V4Gi2AADJ8HnSWOEOo/adA7Fvfe3hiqEzT 1eVrGnaZi9uOL4hNpA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from strobelfs2 ([94.134.196.128]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MAONd-1r6sFH2rIB-00BvQM for ; Wed, 08 Nov 2023 00:13:36 +0100 X-Provags-ID: V03:K1:izaGMARRGb0xE3RUhjw77IC9OTEVVRdnyEV95DV54An2hVtFWPy +SehDHc59yk2vbFA/OV6ClWDnf+O9P352GwWLq3zfZMSbhKuk3ZVCSipVlhc4EQLn5ODb7P H23elomyOHDfT5F+ttgKEl1i+a6kT6041xwbnOu/vY3Nlew0czI/ETgxxfGGbt0wW+Bflgg eTpwoDJHSMb06uf9XqeOA== UI-OutboundReport: notjunk:1;M01:P0:rIhjfrL2yH4=;7VsM1IM8D4VvnCtduqXxO7A0OT5 +pXi8UBP7UjKA/uKD6Ccv3LuoC2fWAUBSDnWXAEs774os9hX5ZDJWjBST4AyffiSRU/4G4jeq yHp5w9vBqq+zSSUuf10wmouBY6n0I38vugNiW7siHIfpo6qbTauBkKaTFmbXFGujzdSLt6K5B az5Eiobgwzjx/k21FOoivPLzbdoAPz4TdXEXJ6i2NSCijXWlUMuA9PcdLh/KtUeZvSfIrRg/R dWYMKhPOWpoVLGb4T62lzl43UjghSJU9R74631X9IhQMtfzylMTCf8rABLw0uVZIP4Og5kNZI E4ml0BIvtKV/I2D1iGRJ8l3KwmNoWJ993RomsXoOTZkLMLuwMmXvJedpmV4j5qke8YQXa4nkf jZTlMGSEEPA2TkjU/DzfnkxiMctQ0FJZA490irbkQxfxLzRlDmcY4qvIctCUsh9deYXY7X8Ep /gb2Fl41HOlNlecRUlCOFWrNeG0jZf/8jZq2Iinu6HqqCDxh5F2OrNN6cdxjLuvXTb4Ce8MGj mzk2V59ps6DKMA8dx2Ya+bjfzsS1xccatBdnggYSZY57RZXqCx7YcO+1klAWP3h330MRcmdiR 69aq1tbYkEXUmQ/CnYkI+Jjt+bzrCsKEf9KMVUrgC56lb+0EjbG2LWYhl+bg1iJV/+Jpzw1ir 0N+YCKjJCq8iM7x3PUlP24ohOHrHfgMW6ndlnd01W9IU23AUQoz1JKfW4Tj8iNzNB+xUciQ2f d/vsu8qk8RZkpwcLuEs2ec/yAYTF97lbH4psgGoCO8Q7GKzgdO2qgNngl3uZ7y4XRsb+gJP1 Received-SPF: pass client-ip=212.227.15.18; envelope-from=stephen.berman@gmx.net; helo=mout.gmx.net X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_SORBS_WEB=1.5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:273952 Archived-At: --=-=-= Content-Type: text/plain If you have at least two files created using todo-mode, you can move an item from a category in one todo file to a category in another todo file by typing `C-u m' with point on the item to be moved. But if the file the item is to be moved to is not yet visiting a buffer in todo-mode when the command is invoked, this results in an infinite loop. The patch below prevents this and allows the move to succeed. For those interested, an analysis of the bug follows. The call chain leading to the hang is this: todo-move-item -> todo-set-item-priority -> todo-marked-item-p -> todo-get-overlay -> todo-item-start. The latter function tests conditions under which point is not on an item; if these tests fail, a loop does a search backwards in the file to find the item start. But the tests overlook the case at hand, where a todo file is loaded into a buffer but todo-mode is not yet set: then point is at the start of the file, whose first line contains metadata that is hidden in todo-mode. Since this case is not tested and the other tests fail, the backwards search begins, but since point is already at position 1, it is impossible to find an item start, so the loop is never exited. Looking through the commit history, it seems this bug has existed since I first added the code, which was before my rewrite of todo-mode.el was merged into Emacs. Evidently I had never tested precisely this use case. (One reason for that may be that it is also possible to move an item between files by typing just `m', when the goal file's name is in the list `todo-category-completions-files'; but in this case the file is set to todo-mode before the movement, so the condition triggering the hang is not met. I have often used this functionality, but evidently not the movement with `C-u m'.) But I now encountered this bug while testing changes in todo-mode.el to support changing the format of item date headers, as announced in bug#66395. Given that it's an old bug that has apparently never been triggered in normal use of todo-mode, I have no problem committing the fix to master. But since an infinite loop is always nasty and the fix is straightforward and AFAICT safe, I think it's suitable for the release branch. I'll wait for the maintainers' decision. In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38, cairo version 1.18.0) of 2023-11-06 built on strobelfs2 Repository revision: bf81706988f6b1b9d6e8033c8227f0129e04ef03 Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12101008 System Description: Linux From Scratch r12.0-63 Configured using: 'configure -C --with-xwidgets 'CFLAGS=-Og -g3' PKG_CONFIG_PATH=/opt/qt5/lib/pkgconfig' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBSYSTEMD LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS WEBP X11 XDBE XIM XINPUT2 XPM XWIDGETS GTK3 ZLIB --=-=-= Content-Type: text/x-patch Content-Disposition: inline Content-Description: todo-item-start patch diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el index 093ea0e22b6..86bf3afbce7 100644 --- a/lisp/calendar/todo-mode.el +++ b/lisp/calendar/todo-mode.el @@ -5277,7 +5277,9 @@ todo-item-start ;; Point is on done items separator. (save-excursion (beginning-of-line) (looking-at todo-category-done)) ;; Buffer is widened. - (looking-at (regexp-quote todo-category-beg))) + (looking-at (regexp-quote todo-category-beg)) + ;; With `C-u m' to a file that is then loaded into a buffer. + (= (point) 1)) (goto-char (line-beginning-position)) (while (not (looking-at todo-item-start)) (forward-line -1)) --=-=-=--