all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] lisp/org.el: allow org-return to call org-open-at-point on citations
@ 2023-05-22 10:10 Bruno Cardoso
  2023-05-22 10:49 ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Bruno Cardoso @ 2023-05-22 10:10 UTC (permalink / raw)
  To: emacs-orgmode

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


Hello everyone.

This patch is a tiny change that allows `org-return' to call `org-open-at-point' when cursor is over org-cite citations.

Best,

Bruno.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-org.el-allow-org-return-to-call-org-open-at-poi.patch --]
[-- Type: text/x-patch, Size: 2165 bytes --]

From 19409cbf70958aa1d7f508cd7151f36a92212341 Mon Sep 17 00:00:00 2001
From: bruno <cardoso.bc@gmail.com>
Date: Sun, 21 May 2023 15:53:42 -0300
Subject: [PATCH] lisp/org.el: allow org-return to call org-open-at-point on
 citations

* lisp/org.el (org-return): When `org-return-follows-link' is non-nil
and point is over an org-cite citation or citantion reference, call `org-open-at-point'.

TINYCHANGE
---
 lisp/org.el | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 866af624e..8eab3ed22 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -17774,8 +17774,8 @@ When optional INDENT argument is non-nil, call
 and INTERACTIVE.
 
 When `org-return-follows-link' is non-nil and point is on
-a timestamp or a link, call `org-open-at-point'.  However, it
-will not happen if point is in a table or on a \"dead\"
+a timestamp, a link or a citation, call `org-open-at-point'.
+However, it will not happen if point is in a table or on a \"dead\"
 object (e.g., within a comment).  In these case, you need to use
 `org-open-at-point' directly."
   (interactive "i\nP\np")
@@ -17795,8 +17795,8 @@ object (e.g., within a comment).  In these case, you need to use
 	  (insert "\n")
 	(org-table-justify-field-maybe)
 	(call-interactively #'org-table-next-row)))
-     ;; On a link or a timestamp, call `org-open-at-point' if
-     ;; `org-return-follows-link' allows it.  Tolerate fuzzy
+     ;; On a link, a timestamp or a citation, call `org-open-at-point'
+     ;; if `org-return-follows-link' allows it.  Tolerate fuzzy
      ;; locations, e.g., in a comment, as `org-open-at-point'.
      ((and org-return-follows-link
 	   (or (and (eq 'link element-type)
@@ -17808,6 +17808,7 @@ object (e.g., within a comment).  In these case, you need to use
 			(> (point) origin))))
 	       (org-in-regexp org-ts-regexp-both nil t)
 	       (org-in-regexp org-tsr-regexp-both nil  t)
+               (org-element-lineage context '(citation citation-reference))
 	       (org-in-regexp org-link-any-re nil t)))
       (call-interactively #'org-open-at-point))
      ;; Insert newline in heading, but preserve tags.
-- 
2.40.1


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

* Re: [PATCH] lisp/org.el: allow org-return to call org-open-at-point on citations
  2023-05-22 10:10 [PATCH] lisp/org.el: allow org-return to call org-open-at-point on citations Bruno Cardoso
@ 2023-05-22 10:49 ` Ihor Radchenko
  2023-05-22 12:39   ` Bruno Cardoso
  0 siblings, 1 reply; 4+ messages in thread
From: Ihor Radchenko @ 2023-05-22 10:49 UTC (permalink / raw)
  To: Bruno Cardoso; +Cc: emacs-orgmode

Bruno Cardoso <cardoso.bc@gmail.com> writes:

> This patch is a tiny change that allows `org-return' to call `org-open-at-point' when cursor is over org-cite citations.

Thanks!
May you also update the docstring of `org-return-follows-link' and add
etc/ORG-NEWS entry?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


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

* Re: [PATCH] lisp/org.el: allow org-return to call org-open-at-point on citations
  2023-05-22 10:49 ` Ihor Radchenko
@ 2023-05-22 12:39   ` Bruno Cardoso
  2023-05-25 12:26     ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Bruno Cardoso @ 2023-05-22 12:39 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

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


On 2023-05-22, 10:49 +0000, Ihor Radchenko <yantar92@posteo.net> wrote:

> Thanks!
> May you also update the docstring of `org-return-follows-link' and add
> etc/ORG-NEWS entry?

Hi Ihor, here's the updated patch as suggested.

Best,

Bruno.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-org.el-allow-org-return-to-call-org-open-at-poi.patch --]
[-- Type: text/x-patch, Size: 3344 bytes --]

From 436cd212507cc948af8de6f9e57b5e14e29f23dd Mon Sep 17 00:00:00 2001
From: bruno <cardoso.bc@gmail.com>
Date: Sun, 21 May 2023 15:53:42 -0300
Subject: [PATCH] lisp/org.el: allow org-return to call org-open-at-point on
 citations

* lisp/org.el (org-return): When `org-return-follows-link' is non-nil
and point is over an org-cite citation or citation reference, call `org-open-at-point'.

TINYCHANGE
---
 etc/ORG-NEWS     | 5 +++++
 lisp/org-keys.el | 3 ++-
 lisp/org.el      | 9 +++++----
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 6b40198b5..ddf1e9110 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -221,6 +221,11 @@ Running shell blocks with the ~:session~ header freezes Emacs until
 execution completes.  The new ~:async~ header allows users to continue
 editing with Emacs while a ~:session~ block executes.
 
+*** ~org-return~ now acts on citations at point
+
+When ~org-return-follows-link~ is non-nil and cursor is over an
+org-cite citation, ~org-return~ will call ~org-open-at-point~.
+
 ** Miscellaneous
 *** =org-crypt.el= now applies initial visibility settings to decrypted entries
 
diff --git a/lisp/org-keys.el b/lisp/org-keys.el
index c62d62a1d..5f3ea8da3 100644
--- a/lisp/org-keys.el
+++ b/lisp/org-keys.el
@@ -299,7 +299,8 @@ implementation is bad."
 
 (defcustom org-return-follows-link nil
   "Non-nil means on links RET will follow the link.
-In tables, the special behavior of RET has precedence."
+In tables, the special behavior of RET has precedence.
+On a timestamp or a citation, call `org-open-at-point'."
   :group 'org-link-follow
   :type 'boolean
   :safe #'booleanp)
diff --git a/lisp/org.el b/lisp/org.el
index 866af624e..8eab3ed22 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -17774,8 +17774,8 @@ When optional INDENT argument is non-nil, call
 and INTERACTIVE.
 
 When `org-return-follows-link' is non-nil and point is on
-a timestamp or a link, call `org-open-at-point'.  However, it
-will not happen if point is in a table or on a \"dead\"
+a timestamp, a link or a citation, call `org-open-at-point'.
+However, it will not happen if point is in a table or on a \"dead\"
 object (e.g., within a comment).  In these case, you need to use
 `org-open-at-point' directly."
   (interactive "i\nP\np")
@@ -17795,8 +17795,8 @@ object (e.g., within a comment).  In these case, you need to use
 	  (insert "\n")
 	(org-table-justify-field-maybe)
 	(call-interactively #'org-table-next-row)))
-     ;; On a link or a timestamp, call `org-open-at-point' if
-     ;; `org-return-follows-link' allows it.  Tolerate fuzzy
+     ;; On a link, a timestamp or a citation, call `org-open-at-point'
+     ;; if `org-return-follows-link' allows it.  Tolerate fuzzy
      ;; locations, e.g., in a comment, as `org-open-at-point'.
      ((and org-return-follows-link
 	   (or (and (eq 'link element-type)
@@ -17808,6 +17808,7 @@ object (e.g., within a comment).  In these case, you need to use
 			(> (point) origin))))
 	       (org-in-regexp org-ts-regexp-both nil t)
 	       (org-in-regexp org-tsr-regexp-both nil  t)
+               (org-element-lineage context '(citation citation-reference))
 	       (org-in-regexp org-link-any-re nil t)))
       (call-interactively #'org-open-at-point))
      ;; Insert newline in heading, but preserve tags.
-- 
2.40.1


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

* Re: [PATCH] lisp/org.el: allow org-return to call org-open-at-point on citations
  2023-05-22 12:39   ` Bruno Cardoso
@ 2023-05-25 12:26     ` Ihor Radchenko
  0 siblings, 0 replies; 4+ messages in thread
From: Ihor Radchenko @ 2023-05-25 12:26 UTC (permalink / raw)
  To: Bruno Cardoso; +Cc: emacs-orgmode

Bruno Cardoso <cardoso.bc@gmail.com> writes:

> On 2023-05-22, 10:49 +0000, Ihor Radchenko <yantar92@posteo.net> wrote:
>
>> Thanks!
>> May you also update the docstring of `org-return-follows-link' and add
>> etc/ORG-NEWS entry?
>
> Hi Ihor, here's the updated patch as suggested.

Thanks!
I modified the patch, adding the necessary non-nil WITH-SELF argument
and changing the wording of `org-return-follows-link' docstring.
I also added tests.

https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=513534f2a
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=aa3980dd7

By accident, I forgot to adjust author field in the amended commit.
Hope, you don't mind. (Or we can add an extra commit with necessary
attributions).

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


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

end of thread, other threads:[~2023-05-25 12:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-22 10:10 [PATCH] lisp/org.el: allow org-return to call org-open-at-point on citations Bruno Cardoso
2023-05-22 10:49 ` Ihor Radchenko
2023-05-22 12:39   ` Bruno Cardoso
2023-05-25 12:26     ` Ihor Radchenko

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.