UP | HOME

Create and open an empty buffer in org-mode

We can use get-buffer-create to create a new empty buffer, then use with-current-buffer to do some modification to that buffer, for example, setting the mode, or insert some content.

Finally, use switch-to-buffer to open it.

For example, the following code create and open a new empty org-mode buffer:

(interactive)
(let ((temp-buffer (get-buffer-create "*new note*")))
  (with-current-buffer temp-buffer
    (org-mode)
    (switch-to-buffer temp-buffer)))

If you want to set the default directory for the new buffer, use (cd DIR):

(cd my-default-dir)

Date: 2019-01-06 Sun 00:00

Author: Huy Tran

Created: 2019-04-22 Mon 14:41