From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id kLPlK4EKSV9kcgAA0tVLHw (envelope-from ) for ; Fri, 28 Aug 2020 13:45:37 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id oMatJ4EKSV8xZwAA1q6Kng (envelope-from ) for ; Fri, 28 Aug 2020 13:45:37 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id DD469940A5F for ; Fri, 28 Aug 2020 13:45:36 +0000 (UTC) Received: from localhost ([::1]:52690 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kBehC-0001yx-Ut for larch@yhetil.org; Fri, 28 Aug 2020 09:45:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39444) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBeg5-0000il-Uo for emacs-orgmode@gnu.org; Fri, 28 Aug 2020 09:44:25 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:45580) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kBeg3-0008Da-W1 for emacs-orgmode@gnu.org; Fri, 28 Aug 2020 09:44:25 -0400 Received: by mail-pg1-x542.google.com with SMTP id 67so466905pgd.12 for ; Fri, 28 Aug 2020 06:44:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=qyXZxvpCpBvs2OKz4BLV78Bt4djB/Y1a96ENupJsVhE=; b=mzdRQdZSkZceM4uVgy9dvC6BWFZSeALSfpscuzTZ84u6DhV1ErOKqRv6ghiiYcygED WnFvYeUVcR6uM9Z8zGGijEOyZvKVSHb8NK1JSabO1VibBYi0cEiQ8iF7AACD3tnOuIw+ Mq087ztEgpdhGiqUVuV+t1Ah+PRxdRgAACQvi5Ro1WmgjcMpw3v9fTaqSKQ6CnZkWnE+ BkEI87QEhvr/Pqcnan+sX2jYT0aPzw2pBc75O+YWWkVvOac0KyVRtog0iJNyRZTta8Ut jCrQlDtcq9niIh5QRMDy6SNeXWA486Qf9/xLyBjY8Hh/iIUL0SuR9vciNsnODGmwIvQN n1lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=qyXZxvpCpBvs2OKz4BLV78Bt4djB/Y1a96ENupJsVhE=; b=jv8Jfz/gn0rhwpF/iyD8GlFvjXApP0RZgdPars+0QiazsDqKiHByM1/cQbfOQ2vQlj 2N40By54O2E+CZHjpbWD36WZ6bKZI2yqXQcE3L57REHZp2rT1zKI7IBlq3cdITF3rVK4 Lb5a9dldoMQVRAxST80znqghNIu1lE1oW90DrII/ZlBj8bab+3WNLguEpbH/a0OiNMIm bncY2mnpO9S8tA/Sh+6FBcHfccxjOrmdIEfNdongY7ZAYJPxFYOGYLK4bZlMinB+ladR a4kz9iz5SvRZUcWzEKjq5D69TAyxt8hQYGhBh/EFY18vcYjHDwIREmxpdPO0z5DG2wC4 DR4w== X-Gm-Message-State: AOAM531kZw//5rCG3Bzm3VpIX6VEfPMEKXA8ww1Q5GU0kphZ3oYaPcWp xGaQeZkdYCdbLTyRLPBUfWOQ5Te9oCoAcQ== X-Google-Smtp-Source: ABdhPJw7FVMc/Job2hj5Mg/OLSKt4aHKxUa8OQw6OaBtFWsksceC/KgTysqgHnhikNSHC/yfTrMHKQ== X-Received: by 2002:aa7:9219:: with SMTP id 25mr1336906pfo.4.1598622261812; Fri, 28 Aug 2020 06:44:21 -0700 (PDT) Received: from localhost ([104.250.131.79]) by smtp.gmail.com with ESMTPSA id w28sm1882643pfj.161.2020.08.28.06.44.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Aug 2020 06:44:20 -0700 (PDT) From: Ihor Radchenko To: D Subject: Re: [PATCH] Re: Re: org-forward-heading-same-level and the invisible-ok argument In-Reply-To: <67d953fc-3396-8038-4302-6e1ad4cde72c@posteo.net> References: <87a6yi42ie.fsf@localhost> <61342cad-ed4c-59ef-d2fe-685de58df5de@posteo.net> <87tuwo2tr3.fsf@localhost> <67d953fc-3396-8038-4302-6e1ad4cde72c@posteo.net> Date: Fri, 28 Aug 2020 21:43:24 +0800 Message-ID: <87tuwm7uo3.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::542; envelope-from=yantar92@gmail.com; helo=mail-pg1-x542.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=mzdRQdZS; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -1.21 X-TUID: V8fo1Uv+R1kj > + (mapcar #'org-invisible-p > + (number-sequence (line-beginning-position) > + (1- (line-end-position))))) This is a bad idea. org--line-visible-p will be called for every single invisible headline. If you check every single point at every single invisible headline, it can be extremely slow. Better do something like below (or maybe even without narrow-to-region, not sure if that may cause significant overhead): (defun org--line-visible-p () "Return t if the current line is partially visible." (save-restriction (narrow-to-region (line-beginning-position) (1- (line-end-position))) (let ((visible t) (p (point-min))) (while (and visible (< p (point-max))) (when (org-invisible-p p) (setq visible nil)) (setq p (next-single-char-property-change p 'invisible))) visible))) Best, Ihor D writes: >> I do not think that setting visibility the leading stars is a correct >> approach to control the movement commands. After second though about the >> issue you raised in the first email, I think that it would make more >> sense for org-forward-heading-same-level to check if any part of the >> heading line is visible to decide if we need to skip it (instead of >> current approach checking only the point at the beginning of the >> headline). Any mode aiming to make org-forward-heading-same-level skip a >> heading will then just need to make the whole heading invisible. >> Skipping partially visible headlines would be a violation of the >> docstring. > > Good point! I think this would be a more or less reasonable patch, then. > > Cheers, > D. > From 4c0f638104f689780de317af5f715384152459bd Mon Sep 17 00:00:00 2001 > From: "D. Williams" > Date: Fri, 28 Aug 2020 14:15:31 +0200 > Subject: [PATCH] org.el: let heading navigation check the entire heading for > visibility > > * org.el (org-forward-heading-same-level): check complete heading instead of the first char > > TINYCHANGE > --- > lisp/org.el | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/lisp/org.el b/lisp/org.el > index 71dbc611e..26f815e19 100644 > --- a/lisp/org.el > +++ b/lisp/org.el > @@ -20478,6 +20478,15 @@ entry." > ((looking-at-p re) (forward-line)) > (t (throw 'exit t)))))))) > > +(defun org--line-visible-p () > + "Return t if the current line is partially visible." > + (and > + (memq nil > + (mapcar #'org-invisible-p > + (number-sequence (line-beginning-position) > + (1- (line-end-position))))) > + t)) > + > (defun org-forward-heading-same-level (arg &optional invisible-ok) > "Move forward to the ARG'th subheading at same level as this one. > Stop at the first and last subheadings of a superior heading. > @@ -20499,8 +20508,7 @@ non-nil it will also look at invisible ones." > (cond ((< l level) (setq count 0)) > ((and (= l level) > (or invisible-ok > - (not (org-invisible-p > - (line-beginning-position))))) > + (org--line-visible-p))) > (cl-decf count) > (when (= l level) (setq result (point))))))) > (goto-char result)) > -- > 2.26.2