Monday, September 24, 2018

an elisp function for org mode of emacs

Just a memo of initial setting for org-mode of emacs;
M-x show-org-buffer to switch to the memo specified by user.

(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-ca" 'org-agenda)
(global-set-key "\C-cc" 'org-capture)
(global-set-key "\C-cb" 'org-switchb)
(setq org-capture-templates
      '(("n" "Note" entry (file+headline "c:/Users/xxx/Documents/memo/notes.org" "Notes")
         "* %?\nEntered on %U\n %i\n %a")
    ("j" "Journal" entry (file+datetree "c:/Users/xxx/Documents/memo/journal.org")
     "* %?\nEntered on %U\n %i\n %a")
        ))

(defun show-org-buffer(n-type)
  "Show an org-file FILE on the current buffer."
  (interactive "sNotes(n,j):")
  (let ((dir "c:/Users/dongsche1/Documents/memo/"))
    (let ((file (concat dir
            (progn
              (if (string= n-type "n")
                  "notes.org"
                "journal.org")))))
      (if (get-buffer file)
      (let ((buffer (get-buffer file)))                             
            (switch-to-buffer buffer)                                   
            (message "%s" file))
    (find-file file)))))

No comments:

Post a Comment