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#65734: [BUG] kill-whole-line on folded subtrees [9.6.8 (release_9.6.8-3-g21171d @ /home/w/usr/emacs/0/29/0/lisp/org/)] Date: Wed, 19 Jun 2024 10:50:31 -0400 Message-ID: References: <87il8pao4l.fsf@whxvd.name> <87tts8vrpb.fsf@localhost> <83h6o84yz1.fsf@gnu.org> <875y4oaban.fsf@whxvd.name> <83bkeg4o1u.fsf@gnu.org> <87o7ifu2v8.fsf@localhost> <838r9j339x.fsf@gnu.org> <87tts78lve.fsf@whxvd.name> <87zg1u0yrp.fsf@whxvd.name> <8334zmrmnu.fsf@gnu.org> <87o7eew0is.fsf@whxvd.name> <83mstiu9c3.fsf@gnu.org> <87wmmlowuv.fsf@localhost> 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="6718"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 65734@debbugs.gnu.org, Eli Zaretskii , Sebastian Miele , Stefan Kangas To: Ihor Radchenko Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jun 19 16:51:29 2024 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 1sJwen-0001Xu-DJ for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 19 Jun 2024 16:51:29 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sJweK-0000oQ-O2; Wed, 19 Jun 2024 10:51:00 -0400 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 1sJweJ-0000o3-5O for bug-gnu-emacs@gnu.org; Wed, 19 Jun 2024 10:50:59 -0400 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 1sJweI-0006u4-UD for bug-gnu-emacs@gnu.org; Wed, 19 Jun 2024 10:50:58 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sJweM-0003P1-6G for bug-gnu-emacs@gnu.org; Wed, 19 Jun 2024 10:51: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: Wed, 19 Jun 2024 14:51:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65734 X-GNU-PR-Package: emacs Original-Received: via spool by 65734-submit@debbugs.gnu.org id=B65734.171880864613047 (code B ref 65734); Wed, 19 Jun 2024 14:51:02 +0000 Original-Received: (at 65734) by debbugs.gnu.org; 19 Jun 2024 14:50:46 +0000 Original-Received: from localhost ([127.0.0.1]:47190 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sJwe6-0003OM-EB for submit@debbugs.gnu.org; Wed, 19 Jun 2024 10:50:46 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:7330) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sJwe4-0003O6-OZ for 65734@debbugs.gnu.org; Wed, 19 Jun 2024 10:50:45 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id C590A441C01; Wed, 19 Jun 2024 10:50:34 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1718808633; bh=V58gCOSJkgEqCmBOLdj+9Lon3w1qovie8+BVOP11fh0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=HLtXTA18BNKSFRjKnAnVF5e2GKAMGdVss+sFNXrs550v7yfP3rJkr7UK7wcqQhccH 4s4/PLa+Em4vMxRwtFrFl1I2vnmPlxRmnu1/hN2tSodEnPw1iO7rFpPlKcSGtqnJxJ 35U+0kCvYhaTj4AjFSpedIY3Vz9JUF93t316aUD5JDO3gpZpQz1C0JqHBMq+/ki/oW a6vZuBaj3D6f3FgozxYucJBh7THiSuCLfGAOt6mjyj7UaSQKpzqeH+ofrWiCMjFEyD 3TrN3NLk3AuGGYmrzzVXWo32nEkqrlPCVPw5SuE1V/1QHAOs9J5npi+FDTFueNZfEt MzQlU8G4YXicg== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 39E4B441BEF; Wed, 19 Jun 2024 10:50:33 -0400 (EDT) Original-Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 23BF11205F0; Wed, 19 Jun 2024 10:50:33 -0400 (EDT) In-Reply-To: <87wmmlowuv.fsf@localhost> (Ihor Radchenko's message of "Wed, 19 Jun 2024 14:01:12 +0000") 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:287484 Archived-At: > + ;; - We need to kill in two steps, because the previous command > + ;; could have been a kill command, in which case the text before > + ;; point needs to be prepended to the current kill ring entry and > + ;; the text after point appended. > + ;; - We need to be careful to avoid copying text twice to the kill > + ;; ring in read-only buffers. > + ;; - We need to determine the boundaries of visible lines before we > + ;; do the first kill. Otherwise `after-change-functions' may > + ;; change visibility (bug#65734). > + (let (;; The beginning of both regions to kill > + (regions-begin (point-marker)) > + ;; The end of the first region to kill. Moreover, after > + ;; evaluation of the value form, (point) will be the end of > + ;; the second region to kill. > + (region1-end (cond ((zerop arg) > + (prog1 (save-excursion > + (forward-visible-line 0) > + (point-marker)) > + (end-of-visible-line))) > + ((< arg 0) > + (prog1 (save-excursion > + (end-of-visible-line) > + (point-marker)) > + (forward-visible-line (1+ arg)) > + (unless (bobp) (backward-char)))) > + (t > + (prog1 (save-excursion > + (forward-visible-line 0) > + (point-marker)) > + (forward-visible-line arg)))))) > + ;; - Pass the marker positions and not the markers themselves. > + ;; kill-region determines whether to prepend or append to a > + ;; previous kill by checking the direction of the region. But > + ;; it deletes the content and hence moves the markers before > + ;; that. That effectively makes every region delimited by > + ;; markers an (empty) forward region. > + ;; - Make the first kill-region emit a non-local exit only if the > + ;; second kill-region below would not operate on a non-empty > + ;; region. > + (let ((kill-read-only-ok (or kill-read-only-ok > + (/= regions-begin (point))))) > + (kill-region (marker-position regions-begin) > + (marker-position region1-end))) > + (kill-region (marker-position regions-begin) > + (point)) > + (set-marker regions-begin nil) > + (set-marker region1-end nil))) Thanks, that seems sensible. [ Tho at the same time, it's sad to think such a "trivial" operation requires such delicate treatment. ] Stefan