all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* org-goto and org-store-link/org-id-get-create
@ 2021-01-30 13:21 Peter Klenner
  2021-01-31  5:43 ` Ihor Radchenko
  0 siblings, 1 reply; 8+ messages in thread
From: Peter Klenner @ 2021-01-30 13:21 UTC (permalink / raw)
  To: emacs-orgmode

Calling either org-store-link or org-id-get-create in an indirect
org-goto buffer results in an empty ID-property drawer with (setq
org-id-link-to-org-use-id t).

There is a recent thread about "Indirect buffers, ~org-store-link~, and
~org-insert-link~"
(https://orgmode.org/list/rhob8q$t26$1@ciao.gmane.io/) which seems to
have resulted in a fix for org-store-link in indirect buffers. Yet, for
an org-goto buffer the described problem of an empty target remains.

System: Emacs 27.1, Windows 10, org 9.4.4

Thanks in advance for any pointers!



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: org-goto and org-store-link/org-id-get-create
  2021-01-30 13:21 org-goto and org-store-link/org-id-get-create Peter Klenner
@ 2021-01-31  5:43 ` Ihor Radchenko
  2021-01-31  9:32   ` Peter Klenner
  2021-04-28  3:53   ` Bastien
  0 siblings, 2 replies; 8+ messages in thread
From: Ihor Radchenko @ 2021-01-31  5:43 UTC (permalink / raw)
  To: Peter Klenner, emacs-orgmode

Peter Klenner <peterklenner@gmx.de> writes:

> Calling either org-store-link or org-id-get-create in an indirect
> org-goto buffer results in an empty ID-property drawer with (setq
> org-id-link-to-org-use-id t).

Confirmed.

This is because org-goto buffer is in read-only state, which is ignored
when inserting empty property drawer, but respected when trying to
insert :ID: property, which is indeed inconsistent.

Currently, the following functions disregard the read-only state in org
buffers: org-store-log-note, org-insert-property-drawer,
org-agenda-undo, org-agenda-todo, org-agenda-add-note,
org-agenda-priority, org-agenda-set-tags, org-agenda-set-property,
org-agenda-set-effort, org-agenda-toggle-archive-tag,
and org-columns-store-format.

A fix to this particular issue could be using org-no-read-only in
org-entry-put. Though more functions may suffer from similar issues in
read-only org buffers.

Best,
Ihor



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: org-goto and org-store-link/org-id-get-create
  2021-01-31  5:43 ` Ihor Radchenko
@ 2021-01-31  9:32   ` Peter Klenner
  2021-04-28  3:53   ` Bastien
  1 sibling, 0 replies; 8+ messages in thread
From: Peter Klenner @ 2021-01-31  9:32 UTC (permalink / raw)
  To: Ihor Radchenko, emacs-orgmode

 >A fix to this particular issue could be using org-no-read-only in
 >org-entry-put. Though more functions may suffer from similar issues in
 >read-only org buffers.

Brilliant! Wrapping org-entry-put into org-no-read-only fixes the issue
for me.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: org-goto and org-store-link/org-id-get-create
  2021-01-31  5:43 ` Ihor Radchenko
  2021-01-31  9:32   ` Peter Klenner
@ 2021-04-28  3:53   ` Bastien
  2021-04-28 14:58     ` Ihor Radchenko
  1 sibling, 1 reply; 8+ messages in thread
From: Bastien @ 2021-04-28  3:53 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Peter Klenner, emacs-orgmode

Hi Ihor,

Ihor Radchenko <yantar92@gmail.com> writes:

> A fix to this particular issue could be using org-no-read-only in
> org-entry-put. Though more functions may suffer from similar issues in
> read-only org buffers.

Can you provide a patch for this?


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: org-goto and org-store-link/org-id-get-create
  2021-04-28  3:53   ` Bastien
@ 2021-04-28 14:58     ` Ihor Radchenko
  2021-04-28 15:26       ` Bastien
  2021-05-01 16:45       ` Bastien
  0 siblings, 2 replies; 8+ messages in thread
From: Ihor Radchenko @ 2021-04-28 14:58 UTC (permalink / raw)
  To: Bastien; +Cc: Peter Klenner, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 86 bytes --]


Bastien <bzg@gnu.org> writes:

> Can you provide a patch for this?

Sure. Attached.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Bypass-read-only-state-in-org-entry-put.patch --]
[-- Type: text/x-diff, Size: 5912 bytes --]

From d914acea52d251e2099681ac9541e4cb42e0953f Mon Sep 17 00:00:00 2001
Message-Id: <d914acea52d251e2099681ac9541e4cb42e0953f.1619621773.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: org-goto and org-store-link/org-id-get-create
  2021-04-28 14:58     ` Ihor Radchenko
@ 2021-04-28 15:26       ` Bastien
  2021-05-01 16:45       ` Bastien
  1 sibling, 0 replies; 8+ messages in thread
From: Bastien @ 2021-04-28 15:26 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Peter Klenner, emacs-orgmode

Hi Ihor,

applied in master as commit 232d9a060, thanks a lot!

-- 
 Bastien


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: org-goto and org-store-link/org-id-get-create
  2021-04-28 14:58     ` Ihor Radchenko
  2021-04-28 15:26       ` Bastien
@ 2021-05-01 16:45       ` Bastien
  2021-05-01 16:55         ` Bastien
  1 sibling, 1 reply; 8+ messages in thread
From: Bastien @ 2021-05-01 16:45 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Peter Klenner, emacs-orgmode

Applied in maint with commit 0a8079b4d, thanks a lot!

Ihor Radchenko <yantar92@gmail.com> writes:

> Bastien <bzg@gnu.org> writes:
>
>> Can you provide a patch for this?
>
> Sure. Attached.

-- 
 Bastien


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: org-goto and org-store-link/org-id-get-create
  2021-05-01 16:45       ` Bastien
@ 2021-05-01 16:55         ` Bastien
  0 siblings, 0 replies; 8+ messages in thread
From: Bastien @ 2021-05-01 16:55 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Peter Klenner, emacs-orgmode

Bastien <bzg@gnu.org> writes:

> Applied in maint with commit 0a8079b4d, thanks a lot!

Er, sorry, I should have explained why I applied it to maint too,
on top of applying it to master three days ago: first of all, this
is a bugfix, and I also want to take the opportunity of releasing
Org 9.4.6 so that more people can test it before Org 9.5.

-- 
 Bastien


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-05-01 16:56 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-30 13:21 org-goto and org-store-link/org-id-get-create Peter Klenner
2021-01-31  5:43 ` Ihor Radchenko
2021-01-31  9:32   ` Peter Klenner
2021-04-28  3:53   ` Bastien
2021-04-28 14:58     ` Ihor Radchenko
2021-04-28 15:26       ` Bastien
2021-05-01 16:45       ` Bastien
2021-05-01 16:55         ` Bastien

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.