Browse Source

org-src: Add RET to go from overlay to edit buffer

* lisp/org-src.el (org-edit-src-goto): org-edit-src-goto factors out
the functionality from org-edit-src-continue.  The latter needs an event.

The return key is bound to org-edit-src-goto for the overlay.
Marco Wahl 2 years ago
parent
commit
0d39ea6ef3
2 changed files with 9 additions and 0 deletions
  1. 2 0
      etc/ORG-NEWS
  2. 7 0
      lisp/org-src.el

+ 2 - 0
etc/ORG-NEWS

@@ -291,6 +291,8 @@ purpose of the variable.  The replacement variable
 accepts =listings= and =verbatim= in place of =t= and =nil= (which
 still work, but are no longer listed as valid options).
 
+*** New function ~org-edit-src-goto~ 
+
 * Version 9.5
 
 ** Important announcements and breaking changes

+ 7 - 0
lisp/org-src.el

@@ -413,6 +413,7 @@ END."
     (overlay-put overlay 'keymap
 		 (let ((map (make-sparse-keymap)))
 		   (define-key map [mouse-1] 'org-edit-src-continue)
+                   (define-key map [return] #'org-edit-src-goto)
 		   map))
     (let ((read-only
 	   (list
@@ -1273,6 +1274,12 @@ Throw an error if there is no such buffer.
 EVENT is passed to `mouse-set-point'."
   (interactive "e")
   (mouse-set-point event)
+  (org-edit-src-goto))
+
+(defun org-edit-src-goto ()
+  "Unconditionally return to buffer editing area under point.
+Throw an error if there is no such buffer."
+  (interactive)
   (let ((buf (get-char-property (point) 'edit-buffer)))
     (if buf (org-src-switch-to-buffer buf 'continue)
       (user-error "No sub-editing buffer for area at point"))))