Calling M-x newline when in org src block. Turns it yellow and prevents editing (it opens org edit src ) I have tried the latest emacs and org-mode. And run the following code in an emacs -q note: I changed the key-maps to include just ones available in default emacs (defun setup-buf1 () (with-current-buffer (get-buffer-create test-buffer-name) (erase-buffer) (insert " #+begin_src elisp :result output (setq a \"grass\") #+end_src ") (org-mode))) (defun code-that-activates-bad-behaviour () (interactive) (switch-to-buffer test-buffer-name) (goto-char (point-min)) (save-excursion (search-forward "grass") (goto-char (point-at-eol)) (call-interactively 'newline) (insert "h") (forward-sexp 1))) (progn (add-to-list 'load-path "~/emacsd-main/el-get/org-mode/lisp") (require 'org) (setq test-buffer-name "my-test-buf") (setq org-src-preserve-indentation t) (setq org-src-window-setup 'current-window) (setq org-src-strip-leading-and-trailing-blank-lines t) (setq org-edit-src-content-indentation 2) (setq org-src-tab-acts-natively t)) (add-to-list 'load-path "~/emacs-config/dem/setup-dem/") (defun org-src-edit-mode-setup () (let* ((b (ignore-errors (current-buffer))) (bufn (and b (buffer-name b)))) (when (string-match "\\`*Org Src " bufn) (let ((mpk-map (copy-keymap org-mode-map)) (qa-map (copy-keymap emacs-lisp-mode-map)) (f-map (copy-keymap abbrev-map))) (define-key mpk-map (kbd "o") qa-map) (define-key qa-map (kbd "f") f-map) (define-key f-map (kbd "s") 'find-file) (define-key mpk-map (kbd "s") Info-mode-map) (define-key org-src-mode-map (kbd "b") mpk-map))))) (add-hook 'org-src-mode-hook 'org-src-edit-mode-setup) (setup-buf1) (code-that-activates-bad-behaviour) In GNU Emacs 27.0.50 (build 4, x86_64-pc-linux-gnu, GTK+ Version 3.22.30, cairo version 1.15.10) of 2019-07-02 built on Slug Repository revision: b35f378d6e7d52393f1afc32a6f9880b9240af91 Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.11906000 System Description: Ubuntu 18.04.2 LTS Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. Invalid image ‘:rotation’ parameter [10 times] delete-backward-char: Text is read-only Making completion list... Loading /home/dericbytes/emacs-config/dem/test-init/init-org-src-fix-test.el (source)...done Configured using: 'configure --with-mailutils --with-xwidgets --with-cairo --with-modules --with-imagemagick' Configured features: XPM JPEG TIFF GIF PNG RSVG CAIRO IMAGEMAGICK SOUND DBUS GSETTINGS GLIB NOTIFY INOTIFY GNUTLS LIBXML2 FREETYPE HARFBUZZ ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS XWIDGETS PDUMPER LCMS2 GMP Important settings: value of $LANG: en_GB.UTF-8 locale-coding-system: utf-8-unix Major mode: Org Minor modes in effect: tooltip-mode: t global-eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug sendmail edmacro kmacro org-element cl-seq avl-tree generator ol-eww ol-rmail ol-mhe ol-irc ol-info ol-gnus nnir gnus-sum gnus-group gnus-undo gnus-start gnus-cloud nnimap nnmail mail-source utf7 netrc nnoo parse-time gnus-spec gnus-int gnus-range message rmc puny rfc822 mml mml-sec password-cache epa derived epg epg-config mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader gnus-win gnus nnheader gnus-util rmail rmail-loaddefs rfc2047 rfc2045 ietf-drums text-property-search seq byte-opt gv bytecomp byte-compile cconv mail-utils mm-util mail-prsvr wid-edit ol-docview doc-view jka-compr image-mode ol-bibtex bibtex ol-bbdb ol-w3m org ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro org-footnote org-src ob-comint org-pcomplete pcomplete comint ansi-color ring org-list org-faces org-entities time-date noutline outline org-version ob-emacs-lisp ob-core ob-eval org-table ol org-keys org-compat advice org-macs org-loaddefs format-spec find-func cal-menu calendar cal-loaddefs cl-loaddefs cl-lib vc-git diff-mode easymenu easy-mmode dired dired-loaddefs elec-pair mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote threads dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting xwidget-internal cairo move-toolbar gtk x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 142197 9860) (symbols 48 16806 1) (strings 32 53628 2358) (string-bytes 1 1847588) (vectors 16 25566) (vector-slots 8 280844 11248) (floats 8 174 71) (intervals 56 416 0) (buffers 992 17))