Quickly Save Org Docs

Watch the Video Here

Quickly Create a New Org Buffer

(defun xah-new-empty-buffer ()
  (interactive)
  (let ((xbuf (generate-new-buffer "untitled")))
    (switch-to-buffer xbuf)
    (org-mode) ;; Set the buffer's major mode to Org mode
    xbuf
    ))

(global-set-key (kbd "<f10>") 'xah-new-empty-buffer)

http://xahlee.info/emacs/emacs/emacs_new_empty_buffer.html

Quickly Add Title

# -*- mode: snippet -*-
# name: title
# key: tle
# --
#+TITLE: ${1:Document Title}
#+NAME: Raoul Comninos
#+OPTIONS: \n:t
#+STARTUP: showall
#+DATE: `(format-time-string "%-d %B %Y")`

$0

Save Document Title as File Name

(defun org-title-to-filename ()
  (let* ((title (save-excursion
                  (goto-char (point-min))
                  (if (re-search-forward "^#\\+TITLE:\\s-*\\(.*\\)" nil t)
                      (match-string 1)
                    nil))))
    (setq title (or title (read-string "Enter title for the new file: ")))
    (setq title (string-trim title)) ;; Trim spaces
    (setq title (replace-regexp-in-string "[^[:alnum:][:space:]-]" "" title)) ;; Remove special chars
    (setq title (replace-regexp-in-string "[[:space:]]+" "-" title)) ;; Replace spaces with dashes
    (setq title (replace-regexp-in-string "-+$" "" title)) ;; Remove trailing dashes
    (downcase title)))

(defun org-save-with-title ()
  (interactive)
  (let* ((filename (org-title-to-filename))
         (directory (expand-file-name "~/Documents/")) ;; Path to ~/Documents/
         (filepath (concat directory filename ".org")))
    (write-file filepath)))

(global-set-key (kbd "C-x C-a") 'org-save-with-title)

Return to Home