mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-10-18 02:19:46 +00:00
org-indent-line: Fix indentation inside src blocks with `electric-indent-mode'
* lisp/org.el (org-indent-line): Use `indent-according-to-mode' to indent in src block's major mode. Using `indent-line-function' fails when `electric-indent-mode' wants to suppress <tab> indentation. * testing/lisp/test-org.el (test-org/with-electric-indent): Add test. Reported-by: the_wurfkreuz <the_wurfkreuz@proton.me> Link: https://orgmode.org/list/5O9VMGb6WRaqeHR5_NXTb832Z2Lek_5L40YPDA52-S3kPwGYJspI8kLWaGtuq3DXyhtHpj1J7jTIXb39RX9BtCa2ecrWHjijZqI8QAD742U=@proton.me
This commit is contained in:
parent
db46706bec
commit
022bb471c1
@ -19809,7 +19809,11 @@ Also align node properties according to `org-property-format'."
|
||||
(+ (org-current-text-indentation)
|
||||
org-edit-src-content-indentation)))))
|
||||
(ignore-errors ; do not err when there is no proper major mode
|
||||
(org-babel-do-in-edit-buffer (funcall indent-line-function)))
|
||||
;; It is important to call `indent-according-to-mode'
|
||||
;; rather than `indent-line-function' here or we may
|
||||
;; sometimes break `electric-indent-mode'
|
||||
;; https://orgmode.org/list/5O9VMGb6WRaqeHR5_NXTb832Z2Lek_5L40YPDA52-S3kPwGYJspI8kLWaGtuq3DXyhtHpj1J7jTIXb39RX9BtCa2ecrWHjijZqI8QAD742U=@proton.me
|
||||
(org-babel-do-in-edit-buffer (indent-according-to-mode)))
|
||||
(when (and block-content-ind (looking-at-p "^$"))
|
||||
(indent-line-to block-content-ind))))
|
||||
(t
|
||||
|
@ -1744,6 +1744,18 @@ CLOCK: [2022-09-17 sam. 11:00]--[2022-09-17 sam. 11:46] => 0:46"
|
||||
(electric-indent-local-mode 1)
|
||||
(call-interactively 'org-return)
|
||||
(buffer-string)))))
|
||||
;; Make sure that we do not mess things up when indenting remotely
|
||||
;; in src block buffer.
|
||||
(let ((org-edit-src-content-indentation 2))
|
||||
(should
|
||||
;; Add `org-edit-src-content-indentation' and no more.
|
||||
;; https://orgmode.org/list/5O9VMGb6WRaqeHR5_NXTb832Z2Lek_5L40YPDA52-S3kPwGYJspI8kLWaGtuq3DXyhtHpj1J7jTIXb39RX9BtCa2ecrWHjijZqI8QAD742U=@proton.me
|
||||
(equal "#+begin_src fundamental\n \n#+end_src" ; 2 spaces
|
||||
(org-test-with-temp-text "#+begin_src fundamental<point>\n#+end_src"
|
||||
(electric-indent-local-mode 1)
|
||||
(call-interactively 'org-return)
|
||||
(should (looking-at-p "\n\\#"))
|
||||
(buffer-string)))))
|
||||
;; C-j, like `electric-newline-and-maybe-indent', should not indent.
|
||||
(should
|
||||
(equal " Para\ngraph"
|
||||
|
Loading…
Reference in New Issue
Block a user