0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-08-25 10:32:52 +00:00

org-src.el: Allow to abort editing with C-c k

* org-src.el (org-src-mode-map): New binding C-c k to abort
editing.
(org-edit-src-code): Mention the keybinding to abort editing
and go back to the correct position.
(org-edit-src-abort): New command to abort editing.

Thanks to Zech for suggesting this.
This commit is contained in:
Bastien Guerry 2013-02-15 22:59:13 +01:00
parent 451e8be770
commit 7c9663eb4a

View file

@ -174,6 +174,7 @@ For example, there is no ocaml-mode in Emacs, but the mode to use is
(defvar org-src-mode-map (make-sparse-keymap))
(define-key org-src-mode-map "\C-c'" 'org-edit-src-exit)
(define-key org-src-mode-map "\C-ck" 'org-edit-src-abort)
(define-key org-src-mode-map "\C-x\C-s" 'org-edit-src-save)
(defvar org-edit-src-force-single-line nil)
@ -241,8 +242,8 @@ the display of windows containing the Org buffer and the code buffer."
end (move-marker end (nth 1 info))
msg (if allow-write-back-p
(substitute-command-keys
"Edit, then exit with C-c ' (C-c and single quote)")
"Exit with C-c ' (C-c and single quote)")
"Edit, then exit with C-c ' (C-c and single quote) -- C-c k to abort")
"Exit with C-c ' (C-c and single quote) -- C-c k to abort")
code (or code (buffer-substring-no-properties beg end))
lang (or (cdr (assoc (nth 2 info) org-src-lang-modes))
(nth 2 info))
@ -712,8 +713,9 @@ with \",*\", \",#+\", \",,*\" and \",,#+\"."
;; Block is hidden; put point at start of block
(beginning-of-line 0)
;; Block is visible, put point where it was in the code buffer
(org-goto-line (1- (+ (org-current-line) line)))
(org-move-to-column (if preserve-indentation col (+ col total-nindent delta))))
(when allow-write-back-p
(org-goto-line (1- (+ (org-current-line) line)))
(org-move-to-column (if preserve-indentation col (+ col total-nindent delta)))))
(unless (eq context 'save)
(move-marker beg nil)
(move-marker end nil)))
@ -722,6 +724,12 @@ with \",*\", \",#+\", \",,*\" and \",,#+\"."
(set-window-configuration org-edit-src-saved-temp-window-config)
(setq org-edit-src-saved-temp-window-config nil))))
(defun org-edit-src-abort ()
"Abort editing of the src code and return to the Org buffer."
(interactive)
(let (org-edit-src-allow-write-back-p)
(org-edit-src-exit 'exit)))
(defmacro org-src-in-org-buffer (&rest body)
`(let ((p (point)) (m (mark)) (ul buffer-undo-list) msg)
(save-window-excursion