There are two ways I start a new org-mode file:

1) I open Emacs and then by Ctr-x Ctr-f I type in the address of the location of where I want my file to be in.

2) I right click the place I want my file to be in and create a new Text Document. I name the document and modify the end by replacing .txt with .org

I find the second way faster but still not as fast as opening Notepad which I do just by typing in Note in the search bar (I am using Windows 10). Is there a way to open a new org-mode file as fast as opening Notepad?

up vote 0 down vote accepted

I set my initial *scratch* to be org-mode.

(setq initial-major-mode 'org-mode)

Of course, *scratch* buffers start with that little message. You can remove that with this:

(setq initial-scratch-message "")

But what if you want a new *scratch* buffer?

(defun create-scratch-buffer nil
  "create a scratch buffer"
  (switch-to-buffer (get-buffer-create "*scratch*"))

If you want to change the default mode for all text files to org-mode, you could use the text-mode-hook.

   (add-hook 'text-mode-hook 'org-mode)

It looks like to set a default mode for a file using find-file you'll need to do something a little more involved. If you include org-mode on the find-file-hook, then all buffers are changed. That's not what you want. You want new files without extensions created using C-x C-f to be org-mode. It looks like that requires modifying the find-file-not-found-functions variable. I haven't used that before and my quick attempts aren't producing the desired results. Hopefully that gets you in the right direction!

Lots of useful functions to explore in norang website, I think that's were I found these bh/* set of functions for org-mode.

Add an interactive function that creates a temp org file where you choose:

(defun bh/make-org-scratch ()
  (find-file "/tmp/publish/")
  (gnus-make-directory "/tmp/publish"))

Then add a key binding such as:

(global-set-key (kbd "<f9> o") 'bh/make-org-scratch)

Now with F9 o you start a scratch org file that can be later saved using ctrl - xctrl -w

You may want to profile it M-x profiler-start before opening the new org file and M-x profiler-report after. If you're using anything like org-bullets that requires you to M-x all-the-icons-install-fonts then make sure you have set (setq inhibit-compacting-font-caches t) (see github issue).

For me it looks like the following for CPU samples:

Function                                                  CPU samples    %
- command-execute                                                  70  94%
 - call-interactively                                              70  94%
  - funcall-interactively                                          70  94%
   - counsel-find-file                                             69  93%
    - ivy-read                                                     69  93%
     - ivy-call                                                    63  85%
      - counsel-find-file-action                                   63  85%
       - find-file                                                 63  85%
        - find-file-noselect                                       63  85%
         - find-file-noselect-1                                    63  85%
          - after-find-file                                        62  83%
           - normal-mode                                           62  83%
            - set-auto-mode                                        62  83%
             - set-auto-mode-0                                     62  83%
              - org-mode                                           62  83%
               + org-load-modules-maybe                            62  83%
          + normal-backup-enable-predicate                          1   1%
       read-from-minibuffer                                         5   6%
   + profiler-report                                                1   1%
+ ...                                                               3   4%
+ timer-event-handler                                               1   1%

I'm getting a slight delay when initially loading a org file (even a new one) because it is loading org modules for the first time. Anytime I load an org file after that it's instant. If you run emacs as a daemon, you may consider preloading org-mode so that you don't have to wait on the first opening of a file.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.