Browse Source

Follow links with RET even in read-only buffers

* lisp/org.el (org-return): Fix `interactive' arguments.
* testing/lisp/test-org.el (test-org/return): Add test.

Reported-by: Gregor Zattler <telegraph@gmx.net>
<http://lists.gnu.org/r/emacs-orgmode/2020-05/msg00247.html>
Nicolas Goaziou 5 years ago
parent
commit
99bb514f7f
2 changed files with 10 additions and 1 deletions
  1. 1 1
      lisp/org.el
  2. 9 0
      testing/lisp/test-org.el

+ 1 - 1
lisp/org.el

@@ -17702,7 +17702,7 @@ 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\"
 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
 object (e.g., within a comment).  In these case, you need to use
 `org-open-at-point' directly."
 `org-open-at-point' directly."
-  (interactive "*i\nP\np")
+  (interactive "i\nP\np")
   (let ((context (if org-return-follows-link (org-element-context)
   (let ((context (if org-return-follows-link (org-element-context)
 		   (org-element-at-point))))
 		   (org-element-at-point))))
     (cond
     (cond

+ 9 - 0
testing/lisp/test-org.el

@@ -1216,6 +1216,15 @@
 	   (org-link-search-must-match-exact-headline nil))
 	   (org-link-search-must-match-exact-headline nil))
        (org-return))
        (org-return))
      (looking-at-p "<<target>>")))
      (looking-at-p "<<target>>")))
+  ;; Non-nil `org-return-follows-link' ignores read-only state of
+  ;; a buffer.
+  (should
+   (org-test-with-temp-text "Link [[target<point>]] <<target>>"
+     (let ((org-return-follows-link t)
+	   (org-link-search-must-match-exact-headline nil))
+       (setq buffer-read-only t)
+       (org-return))
+     (looking-at-p "<<target>>")))
   ;; `org-return-follows-link' handle multi-line lines.
   ;; `org-return-follows-link' handle multi-line lines.
   (should
   (should
    (org-test-with-temp-text
    (org-test-with-temp-text