dot emacs file mac 19June2009

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
(setq load-path (cons "/Users/clsnyder/emacs_org/org-6.27a/lisp" load-path))
(add-to-list 'load-path "/Users/clsnyder/emacs_org/remember")
 
(require 'org)
(require 'remember)
(require 'org-install)
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
 
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-ca" 'org-agenda)
(global-set-key "\C-cb" 'org-iswitchb)
 
(global-font-lock-mode 1)                     ; for all buffers
(add-hook 'org-mode-hook 'turn-on-font-lock)  ; Org buffers only
 
(setq org-log-done t)
(setq org-directory "~/Dropbox/emacs_org")
(setq org-default-notes-file "~/Dropbox/emacs_org/notes.org")
 
(setq remember-annotation-functions '(org-remember-annotation))
(setq remember-handler-functions '(org-remember-handler))
(add-hook 'remember-mode-hook 'org-remember-apply-template)
(define-key global-map "\C-cr" 'org-remember)
 
(setq org-remember-templates
    '(("Todo" ?t "* TODO %? %T %^g\n %i\n " "~/Dropbox/emacs_org/personal.org" )
     ("Journal" ?j "\n* %^{topic} %T \n%i%?\n" "~/Dropbox/emacs_org/journal.org")
     ("Reference" ?r "\n* %^{topic} %T \n%i%?\n" "~/Dropbox/emacs_org/reference.org")
     ("Notes" ?n "\n* %^{topic} %T \n%i%?\n" "~/Dropbox/emacs_org/notes.org")
     ("Contact" ?c "\n* %^{Name} :CONTACT:\n%[~/Dropbox/emacs_org/contacts.txt]\n" 
              "~/Dropbox/emacs_org/contacts.org")
     ))
 
(setq org-agenda-custom-commands
      '(("p" . "Priorities")
        ("pa" "A items" tags-todo "+PRIORITY=\"A\"")
        ("pb" "B items" tags-todo "+PRIORITY=\"B\"")
        ("pc" "C items" tags-todo "+PRIORITY=\"C\"")
        ;; ...other commands here
        ))
 
 
;;
;; To change the location of the annotation file:
;;
(setq org-annotate-file-storage-file "~/Dropbox/emacs_org/annotated.org")
(setq org-annotate-file-add-search t)
 
 
(custom-set-variables
  ;; custom-set-variables was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 '(cua-mode t nil (cua-base))
 '(org-agenda-files (quote ("~/Dropbox/emacs_org/personal.org")))
 '(show-paren-mode t)
 '(text-mode-hook (quote (turn-on-auto-fill text-mode-hook-identify)))
 '(transient-mark-mode t))
(custom-set-faces
  ;; custom-set-faces was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 )
 
(defun wc ()
  (interactive)
  (message "Word count: %s" (how-many "\\w+" (point-min) (point-max))))
 
 
(defun run-current-file ()
(interactive)
  (let (ext-map file-name file-ext prog-name cmd-str)
; get the file name
; get the program name
; run it
    (setq ext-map
          '(
            ("pl" . "perl")
            ("py" . "python")
            ("sh" . "bash")
            ("rb" . "ruby")
            )
          )
    (setq file-name (buffer-file-name))
    (setq file-ext (file-name-extension file-name))
    (setq prog-name (cdr (assoc file-ext ext-map)))
    (setq cmd-str (concat prog-name " " file-name))
    (shell-command cmd-str)))
 
(define-key global-map "\C-c9" 'run-current-file)
 
; return a backup file path of a give file path
; with full directory mirroring from a root dir
; non-existant dir will be created
(defun my-backup-file-name (fpath)
  "Return a new file path of a given file path.
If the new path's directories does not exist, create them."
  (let (backup-root bpath)
    (setq backup-root "~/Dropbox/emacs_org/emacs-backup")
    (setq bpath (concat backup-root fpath "~"))
    (make-directory (file-name-directory bpath) bpath)
    bpath
  )
)
(setq make-backup-file-name-function 'my-backup-file-name)