new commit
[org_files.git] / .emacs
blob5acea97f53ec518f05dd7219d05d0d77e083709e
1 (add-to-list 'load-path (expand-file-name "~/.elisp/"))
2 (add-to-list 'load-path (expand-file-name "~/.elisp/remember"))
3 ;;set display size and position
4 (setq initial-frame-alist '((top . 1) (left . 1) (width . 140) (height . 35)))
6 ;; To get bitstream vera-sans as the default font
7 ;; (require 'carbon-font)
8 ;;  (create-fontset-from-fontset-spec
9 ;;     "-apple-bitstream vera sans mono-medium-r-normal--16-*-*-*-*-*-fontset-mac,
10 ;;      ascii:-apple-bitstream vera sans mono-medium-r-normal--16-*-*-*-m-*-mac-roman,
11 ;;      latin-iso8859-1:-apple-bitstream vera sans mono-medium-r-normal--16-*-*-*-m-*-mac-roman,
12 ;;      mule-unicode-0100-24ff:-apple-bitstream vera sans mono-medium-r-normal--16-*-*-*-m-*-mac-roman")
13 ;;  (set-frame-font "-apple-bitstream vera sans mono-medium-r-normal--16-*-*-*-*-*-fontset-mac" 'keep)
15 ;;personal niceties
16 (setq tramp-default-method "ssh")
17 (winner-mode t)
18 (global-font-lock-mode t)
19 (ediff-toggle-multiframe)
20 (menu-bar-enable-clipboard)
22 ;;twiki mode
23 (require 'erin)
25 ;;org-mode
26 (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
27 (global-set-key "\C-cl" 'org-store-link)
28 (global-set-key "\C-ca" 'org-agenda)
29 ;;custom TODO keywords
30 (setq org-todo-keywords '((type "SOMEDAY/MAY BE" "TODO" "NEXT ACTION" "WAITING FOR" "|" "DONE")))
31 ;;custom agenda commands
32 (setq org-agenda-custom-commands
33            '(("n" todo "NEXT ACTION")
34              ("w" todo "WAITING FOR")
35              ("s" todo "SOMEDAY/MAY BE")
36              ("p" tags-todo "+phone")
37              ("o" . "office+Name tags searches") ; description for "h" prefix
38              ("ol" tags-todo "+office+laptop")
39              ("oo" tags-todo "+office-laptop")))
40 ;;settings for remember-mode
41 (require 'remember)
42 (org-remember-insinuate)
43 (setq org-directory "~/organization")
44 (setq org-default-notes-file (concat org-directory "/collection.org"))
45 (define-key global-map "\C-cr" 'org-remember)
47 ;;for mac, to get the usual behavior for M-w which doesn't show on mac
48 (global-set-key "\M-w" 'copy-region-as-kill)
49 ;;full screen
50 (defun toggle-fullscreen ()
51   (interactive)
52   (set-frame-parameter 
53    nil 
54    'fullscreen 
55    (if (frame-parameter nil 'fullscreen)
56        nil
57      'fullboth)))
59 (global-set-key [(meta return)] 'toggle-fullscreen)
61 ;; Use cperl-mode instead of the default perl-mode
62 (add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode))
63 (add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
64 (add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
65 (add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
67 (autoload 'javascript-mode' "javascript" nil t)
68 (autoload 'php-mode' "php-mode" nil t)
69 (autoload 'css-mode' "css-mode" nil t)
70 (add-to-list 'auto-mode-alist '("\\.js\\'" . javascript-mode))
71 (add-to-list 'auto-mode-alist '("\\.php\\'" . php-mode))
72 (add-to-list 'auto-mode-alist '("\\.css\\'" . css-mode))
75 ;;Steve Yegge's suggestions
77 (global-set-key "\C-w" 'delete-backward-char)
78 (global-set-key "\C-x\C-k" 'kill-region)
79 (global-set-key "\C-c\C-k" 'kill-region)
80 ;lose the UI
81 (if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
82 (if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
83 (if (fboundp 'menu-bar-mode) (menu-bar-mode -1))
85 (global-set-key "\C-x\C-m" 'execute-extended-command)
86 (global-set-key "\C-c\C-m" 'execute-extended-command)
88 ;;RDman's scroll other window
89 ;;procedures for scrolling 1 line at a time for the other window
90 (defun scroll-other-window-n-lines-ahead (&optional n)
91   "Scroll ahead N lines (1 by default) in the other window"
92   (interactive "P")
93   (scroll-other-window (prefix-numeric-value n)))
95 (defun scroll-other-window-n-lines-behind (&optional n)
96   "Scroll behind N lines (1 by default) in the other window"
97   (interactive "P")
98   (scroll-other-window (- (prefix-numeric-value n))))
100 (global-set-key "\C-\M-a" 'scroll-other-window-n-lines-behind)
101 (global-set-key "\C-\M-z" 'scroll-other-window-n-lines-ahead)
103 ;;WGE refers to Writing GNU Emacs Extensions
104 ;traversing window functions (WGE Chapter 2)
105 (defun other-window-backward (&optional n)
106   "Move the focus to nth previous window."
107   (interactive "P")
108   (other-window (- (prefix-numeric-value n))))
110 (global-set-key "\C-xn" 'other-window)
111 (global-set-key "\C-xp" 'other-window-backward)
113 ;scrolling functions for scrolling one line at a time (WGE Chapter 2)
114 (defalias 'scroll-ahead 'scroll-up)
115 (defalias 'scroll-behind 'scroll-down)
117 (defun scroll-n-lines-ahead (&optional n)
118   "scroll ahead n lines"
119 (interactive "P")
120 (scroll-ahead (prefix-numeric-value n)))
122 (defun scroll-n-lines-behind (&optional n)
123   "scroll ahead n lines"
124 (interactive "P")
125 (scroll-behind (prefix-numeric-value n)))
127 (defun scroll-n-lines-left (&optional n)
128   "scroll left n lines"
129 (interactive "P")
130 (scroll-left (prefix-numeric-value n)))
132 (defun scroll-n-lines-right (&optional n)
133   "scroll left n lines"
134 (interactive "P")
135 (scroll-right (prefix-numeric-value n)))
137 (global-set-key "\C-z" 'scroll-n-lines-behind)
138 (global-set-key "\C-q" 'scroll-n-lines-ahead)
139 (global-set-key "\C-\M-a" 'scroll-n-lines-left)
140 (global-set-key "\C-\M-s" 'scroll-n-lines-right)
141 (global-set-key "\C-c\C-q" 'quoted-insert)
143 ;defining desired behaviour when opening a symlink file(WGE Chapter 2)
144 (add-hook 'find-file-hooks 
145             (lambda ()
146                   (if (file-symlink-p buffer-file-name)
147                       (progn 
148                           (setq buffer-read-only t)
149                             (message "File is a symlink")))))
151 (defun visit-target-instead ()
152   "Replace this buffer with a buffer visiting the link target"
153   (interactive)
154   (if buffer-file-name
155       (let ((target (file-symlink-p buffer-file-name)))
156         (if target
157                 (find-alternate-file target)
158             (error "Not visiting a symlink")))
159     (error "Not visiting a file")))
161 (defun clobber-symlink ()
162   "Replace symlink with a copy of the file"
163   (interactive)
164   (if buffer-file-name
165       (let ((target (file-symlink-p buffer-file-name)))
166         (if target 
167                 (if (yes-or-no-p (format "Replace %s with %s?" buffer-file-name target))
168                     (progn
169                         (delete-file buffer-file-name)
170                           (write-file buffer-file-name)))
171             (error "Not visiting a symlink")))
172     (error "Not visiting a file")))
174 ;undoing scrolling (WGE Chapter 3)
175 (defvar unscroll-point nil
176   "Cursor position for next call to 'unscroll'.")
177 (defvar unscroll-window-start nil
178   "Window start for next call to 'unscroll'.")
180 (defadvice scroll-up (before remember-for-unscroll
181                                   activate compile)
182   "Remember where we started from, for 'unscroll'."
183 (if (not (eq last-command 'scroll-up))
184     (progn 
185       (setq unscroll-point (point))
186       (setq unscroll-window-start (window-start)))))
187 (defun unscroll ()
188   "Jump to the position specified by 'unscroll-to'."
189   (interactive)
190   (if (and (not unscroll-point) (not unscroll-window-start))
191       (error "cannot unscroll yet"))
192   (progn
193     (goto-char unscroll-point)
194     (set-window-start nil unscroll-window-start)))
196 ;;For reading word documents
197 (when (locate-library "no-word")
198   (require 'no-word)
199   (add-to-list 'auto-mode-alist '("\\.doc\\'" . no-word)))
201 ;;nxml mode
202 (load "~/.elisp/nxml-mode/rng-auto.el")
203 (setq auto-mode-alist
204       (cons '("\\.\\(xml\\|xsl\\|rng\\|xhtml\\)\\'" . nxml-mode)
205             auto-mode-alist))
207 ;;RDman's workflow mode
208 (load "~/.elisp/pw-utils/pw-utils.el")
209 ;;artist mode
210 (autoload 'artist-mode "artist" "Enter artist-mode" t)
211 ;;replace tabs with spaces
212 (setq-default indent-tabs-mode nil)
215 (custom-set-variables
216   ;; custom-set-variables was added by Custom.
217   ;; If you edit it by hand, you could mess it up, so be careful.
218   ;; Your init file should contain only one such instance.
219   ;; If there is more than one, they won't work right.
220  '(fill-column 125)
221  '(org-agenda-files (quote ("~/org_files/office.org" "~/org_files/gtd.org" "~/organization/delhi_barista_meeting.org"))))
222 (custom-set-faces
223   ;; custom-set-faces was added by Custom.
224   ;; If you edit it by hand, you could mess it up, so be careful.
225   ;; Your init file should contain only one such instance.
226   ;; If there is more than one, they won't work right.
227  '(default ((t (:stipple nil :background "black" :foreground "white" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 200 :width normal :family "inconsolata")))))