Function: org-src-mode
org-src-mode is an interactive and byte-compiled function defined in
org-src.el.gz.
Signature
(org-src-mode &optional ARG)
Documentation
Minor mode for language major mode buffers generated by Org.
This minor mode is turned on in two situations:
- when editing a source code snippet with C-c ' (org-edit-special)
- when formatting a source code snippet for export with htmlize.
C-c ' org-edit-src-exit
C-c C-k org-edit-src-abort
C-x C-s org-edit-src-save
See also org-src-mode-hook.
This is a minor mode. If called interactively, toggle the
Org-Src mode mode. If the prefix argument is positive, enable
the mode, and if it is zero or negative, disable the mode.
If called from Lisp, toggle the mode if ARG is toggle. Enable
the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.
To check whether the minor mode is enabled in the current buffer,
evaluate org-src-mode(var)/org-src-mode(fun).
The mode's hook is called both when the mode is enabled and when it is disabled.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/org/org-src.el.gz
(define-minor-mode org-src-mode
"Minor mode for language major mode buffers generated by Org.
\\<org-mode-map>
This minor mode is turned on in two situations:
- when editing a source code snippet with `\\[org-edit-special]'
- when formatting a source code snippet for export with htmlize.
\\{org-src-mode-map}
See also `org-src-mode-hook'."
:lighter " OrgSrc"
(when org-edit-src-persistent-message
(setq header-line-format
(substitute-command-keys
(if org-src--allow-write-back
"Edit, then exit with `\\[org-edit-src-exit]' or abort with \
`\\[org-edit-src-abort]'"
"Exit with `\\[org-edit-src-exit]' or abort with \
`\\[org-edit-src-abort]'"))))
;; Possibly activate various auto-save features (for the edit buffer
;; or the source buffer).
(when org-edit-src-turn-on-auto-save
(setq buffer-auto-save-file-name
(concat (make-temp-name "org-src-")
(format-time-string "-%Y-%d-%m")
".txt")))
(unless (or org-src--auto-save-timer
(= 0 org-edit-src-auto-save-idle-delay))
(setq org-src--auto-save-timer
(run-with-idle-timer
org-edit-src-auto-save-idle-delay t
(lambda ()
(save-excursion
(let (edit-flag)
(dolist (b (buffer-list))
(with-current-buffer b
(when (org-src-edit-buffer-p)
(unless edit-flag (setq edit-flag t))
(when (buffer-modified-p) (org-edit-src-save)))))
(unless edit-flag
(cancel-timer org-src--auto-save-timer)
(setq org-src--auto-save-timer nil)))))))))