lang/org: fix newline-and-indent behavior in src blocks

This commit is contained in:
Henrik Lissner 2018-05-08 15:36:42 +02:00
parent f3d54af5dc
commit 9e141cd01b
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 15 additions and 0 deletions

View file

@ -348,3 +348,15 @@ with `org-cycle')."
;;;###autoload ;;;###autoload
(defalias #'+org/toggle-fold #'+org|toggle-only-current-fold) (defalias #'+org/toggle-fold #'+org|toggle-only-current-fold)
;;
;; Advice
;;
;;;###autoload
(defun +org*return-indent-in-src-blocks ()
"Try to mimic `newline-and-indent' with correct indentation in src blocks."
(when (org-in-src-block-p t)
(org-babel-do-in-edit-buffer
(call-interactively #'indent-for-tab-command))))

View file

@ -258,6 +258,9 @@ between the two."
(add-hook 'org-tab-first-hook #'+org|toggle-only-current-fold t) (add-hook 'org-tab-first-hook #'+org|toggle-only-current-fold t)
;; Fix newline-and-indent behavior in src blocks
(advice-add #'org-return-indent :after #'+org*return-indent-in-src-blocks)
(map! :map outline-mode-map (map! :map outline-mode-map
:n "^" nil :n "^" nil
:n [backtab] nil :n [backtab] nil