.Emacs for Windows 29 Jun 2009

(setq load-path (cons "C:/Documents and Settings/csnyder/Desktop/My Dropbox/emacs_org/org-6.27a/" load-path))
(add-to-list 'load-path "C:/Documents and Settings/csnyder/Desktop/My Dropbox/emacs_org/remember/")

(require 'org)
(require 'remember)
(require 'org-install)
(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

(defalias 'list-buffers 'ibuffer)
(defconst cls-tmp-dir    "~/.emacs.tmp")

(setq org-log-done t)
(setq org-directory "C:/Documents and Settings/csnyder/Desktop/My Dropbox/emacs_org")
(setq org-default-notes-file "C:/Documents and Settings/csnyder/Desktop/My 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 " "C:/Documents and Settings/csnyder/Desktop/My Dropbox/emacs_org/personal.org" )
     ("Journal" ?j "\n* %^{topic} %T \n%i%?\n" "C:/Documents and Settings/csnyder/Desktop/My Dropbox/emacs_org/journal.org")
     ("Reference" ?r "\n* %^{topic} %T \n%i%?\n" "C:/Documents and Settings/csnyder/Desktop/My Dropbox/emacs_org/reference.org")
     ("Notes" ?n "\n* %^{topic} %T \n%i%?\n" "C:/Documents and Settings/csnyder/Desktop/My Dropbox/emacs_org/notes.org")
     ("Contact" ?c "\n* %^{Name} :CONTACT:\n%[C:/Documents and Settings/csnyder/Desktop/My Dropbox/emacs_org/contacts.txt]\n"
              "C:/Documents and Settings/csnyder/Desktop/My Dropbox/emacs_org/")
     ))

(require 'org-publish)
(setq org-publish-project-alist
      '(
	      ("org-notes"
		 :base-directory "~/org/"
		 :base-extension "org"
		 :publishing-directory "~/public_html/"
		 :recursive t
		 :publishing-function org-publish-org-to-html
		 :headline-levels 4             ; Just the default for this project.
		 :auto-preamble t
	         :auto-index t                  ; Generate index.org automagically...
		 :index-filename "sitemap.org"  ; ... call it sitemap.org ...
		 :index-title "Sitemap"         ; ... with title 'Sitemap'.
		 )
		("org-static"
		 :base-directory "~/org/"
		 :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf"
		 :publishing-directory "~/public_html/"
		 :recursive t
		 :publishing-function org-publish-attachment
		 )
		("org" :components ("org-notes" "org-static"))
      ))

(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 "C:/Documents and Settings/csnyder/Desktop/My 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))
 '(inhibit-startup-screen t)
 '(org-agenda-files (quote ("C:/Documents and Settings/csnyder/Desktop/My 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)
(global-set-key (kbd "M-S-") ;; open my personal.org file
  (lambda()(interactive)(find-file "C:/Documents and Settings/csnyder/Desktop/My Dropbox/emacs_org/personal.org")))

;; backups
(setq cls-backup-dir (concat cls-tmp-dir "/backups"))
(setq make-backup-files t ;; do make backups
  backup-by-copying t     ;; and copy them here
  backup-directory-alist '(("." . "~/.emacs.tmp/backups")) ;; FIXME
  version-control t
  kept-new-versions 2
  kept-old-versions 5
  delete-old-versions t)

Running Map

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)

Repeating events in org-mode

This is from org mode forum:

I am reading the Org-mode Release 6.27a manual to learn new things.
and just discovered the C-c C-x c (clone subtree) command.

This makes copies of a tree and inserts them as siblings. The command
prompts you for the number of copies to make. The really useful
feature is to update dates according to a pattern.

Here is an example of creating headings for each of the next six months:

Start with this:

** First of the month
*** July
SCHEDULED: <2009-07-01 Wed>

Position the cursor to the beginning of the line *** July
then issue the C-c C-x c

Answer the question “Number of clones to produce:” with 6

Next question is
“Date shift per clone (e.g. +1w, empty to copy unchanged): ”

Answer it +1m and the tree looks like:

*** July
SCHEDULED: <2009-07-01 Wed>
*** July
SCHEDULED: <2009-08-01 Sat>
*** July
SCHEDULED: <2009-09-01 Tue>
*** July
SCHEDULED: <2009-10-01 Thu>
*** July
SCHEDULED: <2009-11-01 Sun>
*** July
SCHEDULED: <2009-12-01 Tue>
*** July
SCHEDULED: <2010-01-01 Fri>

Now you just have to change the occurrences of July to the real
month names!