From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:8:6d80::]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id bEjsD0B3iWD1LwEAgWs5BA (envelope-from ) for ; Wed, 28 Apr 2021 16:54:56 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id GMmHCkB3iWBHEgAAbx9fmQ (envelope-from ) for ; Wed, 28 Apr 2021 14:54:56 +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 DA9902D1FE for ; Wed, 28 Apr 2021 16:54:54 +0200 (CEST) Received: from localhost ([::1]:38552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lblaW-00063g-QG for larch@yhetil.org; Wed, 28 Apr 2021 10:54:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52672) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lbla0-00061a-AJ for emacs-orgmode@gnu.org; Wed, 28 Apr 2021 10:54:20 -0400 Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]:40510) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lblZy-0000U5-1Y; Wed, 28 Apr 2021 10:54:20 -0400 Received: by mail-lf1-x12c.google.com with SMTP id h36so45537988lfv.7; Wed, 28 Apr 2021 07:54:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:in-reply-to:references:cc:date:message-id :mime-version; bh=9PppGe8Xhdx7h901jxVklPLmwNv0wrH2NIyzgJJ4+Nc=; b=K0bc1HQfxyXmK8TF7uuwWu2RFzEMbe8JRJd2UFChqtxrnLee4LvkqgktmePRn9sVIg WCbdVn2OqCIwc6mrKz/CcnXCO8bd6dlbQRljkzF27X9603oFpEcmVRA2l99fdBLb7Xg9 s7bEPbuGi4Fmx852LTcqsu7oJBAA01f4+patdynVEoeXbJBnyeqlVBngRAK/1/XOuHon KxQDqU5pUOLRwCwFDw8SjoCS8yJtTJCCLou/o6TKIaYW18YgZJRbv3cmuHSz2g8cWiDz lxWBD8Qd+s4o2vW6gdrlPj4czZBYQHTrcXS+AF50l3Ss5Lh1yljfDDU4XNZwbkV+HBJy icUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:in-reply-to:references:cc:date :message-id:mime-version; bh=9PppGe8Xhdx7h901jxVklPLmwNv0wrH2NIyzgJJ4+Nc=; b=M8613rRHb8M8dJT9xalojeV4sdKvWY6OYV0sI6D/2ZNDMquYJmxCskPH4EcD7KSpTQ MHgjFLaWR19yW2y609/jiFeLpbKAuNbvKkgURLmGyKEY3GhyxltMO3DT8cCoKVqZXiMz x1UxhENmqITOH4LJu6jKOLkYz+TfeIWP1kqZAONAnMuLjkKLsNexmj5sZkqnIBBbNd9w eKwjkrB2Q47QrlGDL1hIPU0gIZ6+ePqk3koaFvpF2YyWwucEDG2IVOitDyjNS3SN1o4c E0i4qKXgTUKkt3ymqocbL56LdnYQMMQvLfTrijTFuXlZKxJBgcDEzVquJZWEqmgefK+P 5J2g== X-Gm-Message-State: AOAM533uYVsNG9GWH6xzelB5htr14IH6YrrKkgLeqDZniiaUmjolb3WZ +H1Y63gAaT7jMagsgav4sumuBIzlf2a2eQ== X-Google-Smtp-Source: ABdhPJwwa5faeb8v2BP9gELRXnMkrV2d1CtJeekZsVKekv9RKE5m9cpZVyzIKd/wNHzu98BtAAY81Q== X-Received: by 2002:a05:6512:74d:: with SMTP id c13mr21062528lfs.150.1619621655162; Wed, 28 Apr 2021 07:54:15 -0700 (PDT) Received: from localhost ([158.255.2.9]) by smtp.gmail.com with ESMTPSA id r83sm28813lff.79.2021.04.28.07.54.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Apr 2021 07:54:14 -0700 (PDT) From: Ihor Radchenko To: Bastien Subject: Re: org-goto and org-store-link/org-id-get-create In-Reply-To: <87wnsn12v2.fsf@gnu.org> References: <8ffe2da5-e2cb-f44c-0a46-b19873c0bdf2@gmx.de> <87pn1l4q62.fsf@localhost> <87wnsn12v2.fsf@gnu.org> X-Woof-Patch: t Date: Wed, 28 Apr 2021 22:58:37 +0800 Message-ID: <871raua21u.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2a00:1450:4864:20::12c; envelope-from=yantar92@gmail.com; helo=mail-lf1-x12c.google.com 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: Peter Klenner , emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1619621695; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=9PppGe8Xhdx7h901jxVklPLmwNv0wrH2NIyzgJJ4+Nc=; b=SYOShuRtLfxROW9avCtR++SLe+MWg4C91r2rUbYqxKmwxDtlc0AY2ohzRM2fBcCLXFZmx1 /kvN8CJksKn2HwcfBoSM0yg3tbq8UloAJzGzdxP8M3dK8cemtmMsw5cmypUKCL/qVr2Gal NT2FsmL4dMOmJlGK1venEhGt9fiXWIxw6pWTJ3+cwsXGzK3NSGb8AiLwxKfb1iisB0QCXA nZ58muAiJVQj2u5hBVZqbXqXZ8uIeCsEs5qq5k831gqhs4Q4Ry+xCXspSxwnBFNgCF7WRZ pV5dFU2Xd1GKB3P2531txn8ueU8zU7ZNIMwIYoHcKSLa09/dWF90z8YEa8ZBCQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1619621695; a=rsa-sha256; cv=none; b=g27ewimUkcibbvL9xAmGFqu4WZbwIbwWEhW5EgsWKiDy+QIp2Zq6J/FDFe2BO6nv3/u14N 4DbeYEyl9KjIy+ssLDgrYDJK2JKUw2tPmi95/JtQWnY7+1VzBWYRIdFfMYnftKwLJXyXwB MxaUzAqZ7NPsPLRURv8DcJVHnX75FWVd8Uw41zLzs/ym6zA+QUov1MhUo36Lw+h8TSEkoN F7kqQ8uuhMDJHP79M8A6+we34VP0fwL0isgnb0w2eyM5BdNeIN7LNeo/pRcJg7ObvNn6Tv elX22yWqCyn2Bpz3wKpNpHSruyg2xF5OPt1g4hb9R7XLXl7WDbyXIBmzsZgO/g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=K0bc1HQf; 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-Migadu-Spam-Score: -2.65 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=K0bc1HQf; 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-Migadu-Queue-Id: DA9902D1FE X-Spam-Score: -2.65 X-Migadu-Scanner: scn0.migadu.com X-TUID: 6wX5HI6RvLTK --=-=-= Content-Type: text/plain Bastien writes: > Can you provide a patch for this? Sure. Attached. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Bypass-read-only-state-in-org-entry-put.patch >From d914acea52d251e2099681ac9541e4cb42e0953f Mon Sep 17 00:00:00 2001 Message-Id: From: Ihor Radchenko Date: Wed, 28 Apr 2021 22:51:53 +0800 Subject: [PATCH] Bypass read-only state in org-entry-put * lisp/org.el (org-entry-put): Ignore read-only state of the buffer. Fixes bug when ID property is not insered when creating ID in an indirect read-only org-goto buffer. [1] [1] https://orgmode.org/list/8ffe2da5-e2cb-f44c-0a46-b19873c0bdf2@gmx.de/ --- lisp/org.el | 113 ++++++++++++++++++++++++++-------------------------- 1 file changed, 57 insertions(+), 56 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index eb4b2db88..dbc245534 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -12340,62 +12340,63 @@ (defun org-entry-put (pom property value) ((not (stringp value)) (error "Properties values should be strings")) ((not (org--valid-property-p property)) (user-error "Invalid property name: \"%s\"" property))) - (org-with-point-at pom - (if (or (not (featurep 'org-inlinetask)) (org-inlinetask-in-task-p)) - (org-back-to-heading-or-point-min t) - (org-with-limited-levels (org-back-to-heading-or-point-min t))) - (let ((beg (point))) - (cond - ((equal property "TODO") - (cond ((not (org-string-nw-p value)) (setq value 'none)) - ((not (member value org-todo-keywords-1)) - (user-error "\"%s\" is not a valid TODO state" value))) - (org-todo value) - (org-align-tags)) - ((equal property "PRIORITY") - (org-priority (if (org-string-nw-p value) (string-to-char value) ?\s)) - (org-align-tags)) - ((equal property "SCHEDULED") - (forward-line) - (if (and (looking-at-p org-planning-line-re) - (re-search-forward - org-scheduled-time-regexp (line-end-position) t)) - (cond ((string= value "earlier") (org-timestamp-change -1 'day)) - ((string= value "later") (org-timestamp-change 1 'day)) - ((string= value "") (org-schedule '(4))) - (t (org-schedule nil value))) - (if (member value '("earlier" "later" "")) - (call-interactively #'org-schedule) - (org-schedule nil value)))) - ((equal property "DEADLINE") - (forward-line) - (if (and (looking-at-p org-planning-line-re) - (re-search-forward - org-deadline-time-regexp (line-end-position) t)) - (cond ((string= value "earlier") (org-timestamp-change -1 'day)) - ((string= value "later") (org-timestamp-change 1 'day)) - ((string= value "") (org-deadline '(4))) - (t (org-deadline nil value))) - (if (member value '("earlier" "later" "")) - (call-interactively #'org-deadline) - (org-deadline nil value)))) - ((member property org-special-properties) - (error "The %s property cannot be set with `org-entry-put'" property)) - (t - (let* ((range (org-get-property-block beg 'force)) - (end (cdr range)) - (case-fold-search t)) - (goto-char (car range)) - (if (re-search-forward (org-re-property property nil t) end t) - (progn (delete-region (match-beginning 0) (match-end 0)) - (goto-char (match-beginning 0))) - (goto-char end) - (insert "\n") - (backward-char)) - (insert ":" property ":") - (when value (insert " " value)) - (org-indent-line))))) - (run-hook-with-args 'org-property-changed-functions property value))) + (org-no-read-only + (org-with-point-at pom + (if (or (not (featurep 'org-inlinetask)) (org-inlinetask-in-task-p)) + (org-back-to-heading-or-point-min t) + (org-with-limited-levels (org-back-to-heading-or-point-min t))) + (let ((beg (point))) + (cond + ((equal property "TODO") + (cond ((not (org-string-nw-p value)) (setq value 'none)) + ((not (member value org-todo-keywords-1)) + (user-error "\"%s\" is not a valid TODO state" value))) + (org-todo value) + (org-align-tags)) + ((equal property "PRIORITY") + (org-priority (if (org-string-nw-p value) (string-to-char value) ?\s)) + (org-align-tags)) + ((equal property "SCHEDULED") + (forward-line) + (if (and (looking-at-p org-planning-line-re) + (re-search-forward + org-scheduled-time-regexp (line-end-position) t)) + (cond ((string= value "earlier") (org-timestamp-change -1 'day)) + ((string= value "later") (org-timestamp-change 1 'day)) + ((string= value "") (org-schedule '(4))) + (t (org-schedule nil value))) + (if (member value '("earlier" "later" "")) + (call-interactively #'org-schedule) + (org-schedule nil value)))) + ((equal property "DEADLINE") + (forward-line) + (if (and (looking-at-p org-planning-line-re) + (re-search-forward + org-deadline-time-regexp (line-end-position) t)) + (cond ((string= value "earlier") (org-timestamp-change -1 'day)) + ((string= value "later") (org-timestamp-change 1 'day)) + ((string= value "") (org-deadline '(4))) + (t (org-deadline nil value))) + (if (member value '("earlier" "later" "")) + (call-interactively #'org-deadline) + (org-deadline nil value)))) + ((member property org-special-properties) + (error "The %s property cannot be set with `org-entry-put'" property)) + (t + (let* ((range (org-get-property-block beg 'force)) + (end (cdr range)) + (case-fold-search t)) + (goto-char (car range)) + (if (re-search-forward (org-re-property property nil t) end t) + (progn (delete-region (match-beginning 0) (match-end 0)) + (goto-char (match-beginning 0))) + (goto-char end) + (insert "\n") + (backward-char)) + (insert ":" property ":") + (when value (insert " " value)) + (org-indent-line))))) + (run-hook-with-args 'org-property-changed-functions property value)))) (defun org-buffer-property-keys (&optional specials defaults columns) "Get all property keys in the current buffer. -- 2.26.3 --=-=-=--