Two problems:
org-indent-mode
is a minor mode and like all minor modes is enabled by calling with a positive argument and disabled by calling it with a negative argument - see its doc string withC-h f org-indent-mode
. So you have to call it like this:(org-indent-mode -1)
to disable it.org-to-tree-indirect-buffer
leaves the current buffer unchanged, i.e. that of the original Org mode file. However, you need to turn offorg-indent-mode
not in the original buffer but in the generated indirect buffer. Fortunately, it saves that indirect buffer in the global variableorg-last-indirect-buffer
, so you can usewith-current-buffer
to temporarily switch to the indirect buffer and disableorg-indent-mode
there.
The final form of the function would then look like this:
(defun my-org-to-indirect-buffer ()
"Run `some-command' and `some-other-command' in sequence."
(interactive)
(org-tree-to-indirect-buffer)
(with-current-buffer org-last-indirect-buffer (org-indent-mode -1))
)
One more problem might be the key binding: why do you bind it in the global map? Presumably you only need it in an Org mode buffer, so why not restrict it to the mode-specific keymap? Something like this:
(define-key org-mode-map (kbd "C-c f") #'my-org-to-indirect-buffer)