November 22, 2012

A Good Orgmode Configuration

At the behest of teammates at Minus who like my Emacs Orgmode setup, I share my configuration. The following eLisp optimizes Emacs for my use cases: engineering design, project planning and blogging. Pasting this into your Emacs init.el should be sufficient to incorporate these customizations into your Emacs experience.

;; My Emacs Orgmode Configuration.
;; Authored by Carl Hu 2012
;; Copyright 2012 Carl Hu
;; This program is distributed under the terms of the GNU General Public License.
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see
(require 'org)
(add-hook 'org-mode-hook (lambda () (modify-syntax-entry (string-to-char "\u25bc") "w"))) ; Down arrow for collapsed drawer.
(setq org-startup-indented t)
(setq org-hide-leading-stars t)
(setq org-odd-level-only nil) 
(setq org-insert-heading-respect-content nil)
(setq org-M-RET-may-split-line '((item) (default . t)))
(setq org-special-ctrl-a/e t)
(setq org-return-follows-link nil)
(setq org-use-speed-commands t)
(setq org-startup-align-all-tables nil)
(setq org-log-into-drawer nil)
(setq org-tags-column 1)
(setq org-ellipsis " \u25bc" )
(setq org-speed-commands-user nil)
(setq org-blank-before-new-entry '((heading . nil) (plain-list-item . nil)))
(setq org-completion-use-ido t)
(setq org-indent-mode t)
(setq org-startup-truncated nil)
(setq auto-fill-mode -1)
(setq-default fill-column 99999)
(setq fill-column 99999)
(global-auto-revert-mode t)
(prefer-coding-system 'utf-8)
(cua-mode t) ;; keep the cut and paste shortcut keys people are used to.
(setq cua-auto-tabify-rectangles nil) ;; Don't tabify after rectangle commands
(transient-mark-mode nil)               ;; No region when it is not highlighted
(setq cua-keep-region-after-copy t) 
;; python
(setq-default indent-tabs-mode nil)    ; use only spaces and no tabs
(setq default-tab-width 4)
;; a sample of how to call shell or python program from emacs.
(defun todo-export ()
  (save-some-buffers t)
  (call-process-shell-command "/bin/bash -c \"cd ~/Desktop/personal; git pull; git commit -am '-'; git push;\"" nil 0 ))
(global-set-key (kbd "") 'todo-export)
;; i like pressing f3 to switch to my todo list from wherever i am.
(defun switch-to-personal-todo ()
  (find-file "path-to-file"))
(global-set-key (kbd "") 'todo-export)
;; i like pageup page down for buffer changes.
(global-set-key [(control next)] 'next-buffer) 
(global-set-key [(control prior)] 'previous-buffer)
;; Add copy a whole line to clipboard to Emacs, bound to meta-c.
(defun quick-copy-line ()
  "Copy the whole line that point is on and move to the beginning of the next line.
    Consecutive calls to this command append each line to the
  (let ((beg (line-beginning-position 1))
        (end (line-beginning-position 2)))
    (if (eq last-command 'quick-copy-line)
        (kill-append (buffer-substring beg end) (< end beg))
      (kill-new (buffer-substring beg end))))
  (beginning-of-line 2)
  (message "Line appended to kill-ring."))
(define-key global-map (kbd "M-c") 'quick-copy-line)
;; Add inserting current date time.
(defun my-insert-date (prefix)
    "Insert the current date. With prefix-argument, use ISO format. With
   two prefix arguments, write out the day and month name."
    (interactive "P")
    (let ((format (cond
                   ((not prefix) "%Y-%m-%d %H:%M") 
                   ((equal prefix '(4)) "%Y-%m-%d")
                   ((equal prefix '(16)) "%A, %d. %B %Y")))
      (insert (format-time-string format))))
(define-key global-map (kbd "C-M-d") 'my-insert-date)
Filed under Hacking