From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id sIYcB6QLYGLS+QAAbAwnHQ (envelope-from ) for ; Wed, 20 Apr 2022 15:33:24 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id SGkBB6QLYGL8oQAAauVa8A (envelope-from ) for ; Wed, 20 Apr 2022 15:33:24 +0200 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 9BD7CEC72 for ; Wed, 20 Apr 2022 15:33:23 +0200 (CEST) Received: from localhost ([::1]:57062 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhASQ-0004sv-QD for larch@yhetil.org; Wed, 20 Apr 2022 09:33:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36798) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhAJP-0002Ix-OM for emacs-orgmode@gnu.org; Wed, 20 Apr 2022 09:24:03 -0400 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]:45730) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhAJN-0003Jv-VA for emacs-orgmode@gnu.org; Wed, 20 Apr 2022 09:24:03 -0400 Received: by mail-pg1-x52a.google.com with SMTP id k29so1592118pgm.12 for ; Wed, 20 Apr 2022 06:24:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:in-reply-to:references:message-id:date:mime-version; bh=TWmxbT7CdIKz4hnQ86+5I7L4bDxdAKlNxxJIIHjtAOk=; b=as20FgIupqxDKvs8PPfEPA3ZpfMDmJDg+HsBza9liZFgUTuBJt6MfFcoMDrwI+f0nv Jlc4AM7jHAM6POUpHZfC97Tkwwj9mqNpiWF5j7nXz1J/vZw6IDV0nRS21Xm+sxR2f0so 4JV0X+cODVTcNfXb/QNfXSeXLMzvg0fykR+BHGuog3fFJpyClyru8kraEZA0cFfZt20O xdOoYhSx3o+STEznQIkW0hl48V49XO9NgQ1EMVtWMwov1vcLqz9R9RVsRK6JSLX6njMl LZ7wYqK6vsVmgqERPb1QSGs132XiCVnXDcu36RTCKyDl+Jt1NX5bJd2tqExqDQxtPcvg mR1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:in-reply-to:references :message-id:date:mime-version; bh=TWmxbT7CdIKz4hnQ86+5I7L4bDxdAKlNxxJIIHjtAOk=; b=4shHrPv0iIKmVLkk8dnrlSJsrJiAumVZXdjgYozFR1NLM8W3IUwN1Ok7BSM8qg5+z9 rDVWOQ6PJUUVuN39Z18A+hRkuJ/Djkps3b/ffwU3NtdFVCvCROgyVISSNl6Gzt1b7jKg IM04XZ1O4+aEVLgLPqJ4sU2Xdcks8jd1eG4OVpXmC9TLOjVemKKD3BUTjOI9dbrYSDnm xF+s9WLLEXhhwjrsxlQG7x88ZoR6Fw0iMW4OQJv96gMrF4/fdeG+malKQMI/FbyH6uCb AFXcvSONXApH/fphpCt1GT3zfA1oNC6A2L2suULnw+5Hu2fvhYaDfcI1lc7cbD0Ofgi1 urMQ== X-Gm-Message-State: AOAM533OWd7TXA6BqcqNji0HRg2+myhmKDVBfpVJ1+gwgeAj5mzxZfAs 8LG9/MnirCJtJ4GAwKsccAsGJb3MtSo/uA== X-Google-Smtp-Source: ABdhPJw2qgAZAGk9Z6QnTdROP3twuk8Dyh+yi/9jh0Ulk0qQRK57NTeRnMQh6TuWp17QjhyhS2vVFw== X-Received: by 2002:a65:4787:0:b0:39d:96b7:bfaa with SMTP id e7-20020a654787000000b0039d96b7bfaamr19623283pgs.495.1650461040160; Wed, 20 Apr 2022 06:24:00 -0700 (PDT) Received: from localhost ([64.32.23.62]) by smtp.gmail.com with ESMTPSA id ca11-20020a056a00418b00b0050a55c55fe5sm15504030pfb.75.2022.04.20.06.23.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 06:23:59 -0700 (PDT) From: Ihor Radchenko To: emacs-orgmode@gnu.org Subject: [PATCH v2 07/38] org-at-heading-p: Accept optional argument* lisp/org.el (org-at-heading-p): Use second argument to allow In-Reply-To: References: Message-Id: <4b8e487ab51db0a1cd6e19d8003920488a8a723a.1650460489.git.yantar92@gmail.com> Date: Wed, 20 Apr 2022 21:24:52 +0800 MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::52a; envelope-from=yantar92@gmail.com; helo=mail-pg1-x52a.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1650461603; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=TWmxbT7CdIKz4hnQ86+5I7L4bDxdAKlNxxJIIHjtAOk=; b=oBoeWWbElhvJy8zPjh8YHvCTPeuH/MXtR6DM566NG4I12mOoJk5umPJnmxaxEuzekq05yF f8nxGJfVyNIcu3mE7aXoAODtng93rJhzmtJzqUy287A6rjlePe7/QGeLRKk/afOoNZ6k+A 99lRDRIuJwNIQispZISLvdVcznRUVEo/Bfua7TR+CG9uzbHmNPxSREW7i0QPtL1iHqyc4K DPfDn8L+S6IPO3YX1KidJZ0YgA985wcKrq5PG+B+WSrwudz3bBzsLLTWy+2+qJ9MyJe6hc +xTzgk+JjsRV5OMGrWrfiQ92hy0Gn+QmsiAYMyCkcBHJ/vmkLFsAprNupQSavA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1650461603; a=rsa-sha256; cv=none; b=RaaHW+3Y69LMyWHPsZ8kL7WWDIvQnLH89wRwjwhVXsp0oo2G9ld54KHIXckimRi9cHmY5T wS5HKixhSVN4wL6suyzz3khSRXiNDbGaSr/Qi7MX7vAYDug3xnALLn4rz8/o9u87dwQ88I fKISvAd5H+3rjMT4JiWCDYch8K7QKlJgHtVDHvaXyaT6zBdd8qWYJDi/6vM8E5kvrULMpk dUhzzI0NMkrU+9wzvFKieRximfL6NE8Et8yXNhlexMYz5oqbyH361u1rQCbbkQ5nbLMy+T vrpRgOJXMUHrJVSRVau7hIqJ+QJd1Y6shspxzrxTUcRzP6eNiWCJpgm/X1s8Eg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=as20FgIu; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.04 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=as20FgIu; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 9BD7CEC72 X-Spam-Score: -3.04 X-Migadu-Scanner: scn0.migadu.com X-TUID: TBv04Chsnzmt * lisp/org.el (org-at-heading-p): Use second argument to allow checking for visible headings. Note that by default, unlike `outline-on-heading-p', `org-at-heading-p' returns non-nil for invisible headings. Passing second argument is just like `(outline-on-heading-p)'. (org-indent-line): * lisp/org-agenda.el (org-agenda-add-entry-to-org-agenda-diary-file): * lisp/org-colview.el (org-columns--call): (org-columns-store-format): Update arguments in `org-at-heading-p' calls. --- lisp/org-agenda.el | 2 +- lisp/org-colview.el | 4 ++-- lisp/org.el | 14 +++++++++----- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index b55e00803..862243f28 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -10527,7 +10527,7 @@ (defun org-agenda-add-entry-to-org-agenda-diary-file (type text &optional d1 d2) (anniversary (or (re-search-forward "^\\*[ \t]+Anniversaries" nil t) (progn - (or (org-at-heading-p t) + (or (org-at-heading-p) (progn (outline-next-heading) (insert "* Anniversaries\n\n") diff --git a/lisp/org-colview.el b/lisp/org-colview.el index 082d6def0..15cab35f0 100644 --- a/lisp/org-colview.el +++ b/lisp/org-colview.el @@ -699,7 +699,7 @@ (defun org-columns--call (fun) (let ((hide-body (and (/= (line-end-position) (point-max)) (save-excursion (move-beginning-of-line 2) - (org-at-heading-p t))))) + (org-at-heading-p))))) (unwind-protect (funcall fun) (when hide-body (outline-hide-entry))))) @@ -1026,7 +1026,7 @@ (defun org-columns-store-format () ;; No COLUMNS keyword in the buffer. Insert one at the ;; beginning, right before the first heading, if any. (goto-char (point-min)) - (unless (org-at-heading-p t) (outline-next-heading)) + (unless (org-at-heading-p) (outline-next-heading)) (let ((inhibit-read-only t)) (insert-before-markers "#+COLUMNS: " fmt "\n")))) (setq-local org-columns-default-format fmt)))))) diff --git a/lisp/org.el b/lisp/org.el index b9d2d7834..8c823a7c8 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -17259,7 +17259,7 @@ (defun org-toggle-heading (&optional nstars) ;; Case 1. Started at an heading: de-star headings. ((org-at-heading-p) (while (< (point) end) - (when (org-at-heading-p t) + (when (org-at-heading-p) (looking-at org-outline-regexp) (replace-match "") (setq toggled t)) (forward-line))) @@ -17861,7 +17861,7 @@ (defun org-context () (p (point)) clist o) ;; First the large context (cond - ((org-at-heading-p t) + ((org-at-heading-p) (push (list :headline (point-at-bol) (point-at-eol)) clist) (when (progn (beginning-of-line 1) @@ -19611,9 +19611,13 @@ (defun org-before-first-heading-p () (end-of-line) (null (re-search-backward org-outline-regexp-bol nil t)))))) -(defun org-at-heading-p (&optional _) - "Non-nil when on a headline." - (outline-on-heading-p t)) +(defun org-at-heading-p (&optional invisible-not-ok) + "Return t if point is on a (possibly invisible) heading line. +If INVISIBLE-NOT-OK is non-nil, an invisible heading line is not ok." + (save-excursion + (beginning-of-line) + (and (bolp) (or (not invisible-not-ok) (not (org-fold-folded-p))) + (looking-at outline-regexp)))) (defun org-in-commented-heading-p (&optional no-inheritance element) "Non-nil if point is under a commented heading. -- 2.35.1 -- Ihor Radchenko, PhD, Center for Advancing Materials Performance from the Nanoscale (CAMP-nano) State Key Laboratory for Mechanical Behavior of Materials, Xi'an Jiaotong University, Xi'an, China Email: yantar92@gmail.com, ihor_radchenko@alumni.sutd.edu.sg