Minor updates.
authorLuke Hoersten <Luke@Hoersten.org>
Fri, 09 Jan 2009 10:39:57 -0600
changeset 1 ede059431d20
parent 0 c25fee3c92e9
child 2 0c29010a8c83
Minor updates.
emacs.el
hoersten-c-style.el
hoersten-pastebin-region.el
--- a/emacs.el	Thu Jan 01 10:51:38 2009 -0600
+++ b/emacs.el	Fri Jan 09 10:39:57 2009 -0600
@@ -41,20 +41,19 @@
 ;; haskell
 (setq haskell-font-lock-symbols 'unicode)
 
-;; indentation
-(setq-default tab-width 3)
-(setq-default c-basic-offset 3)
-(setq-default indent-tabs-mode t)
-
 ;; use only spaces for alignment
 (global-set-key (kbd "C-c a") 'align-with-spaces)  ; align
-(defun align-with-spaces (beg end)
+(defun align-with-spaces (beg end pattern)
   "Align selected using only spaces for whitespace."
-  (interactive "r")
+  (interactive "r\nsAlign by: ")
   (let ((indent-tabs-mode nil))
-	 (align beg end)))
+    (align-string beg end pattern 1)
+    (align-entire beg end)
+    (untabify beg end)
+    (indent-region beg end)
+    (whitespace-cleanup-region beg end)))
 
-;; shell
+;; Shell
 (global-set-key (kbd "C-c s") 'shell)              ; start shell
 (ansi-color-for-comint-mode-on)                    ; color in shell buffer
 (setq-default comint-scroll-to-bottom-on-input t)  ; only type on prompt
@@ -62,18 +61,18 @@
 
 ;; map file extensions to modes
 (setq-default auto-mode-alist
-				  (append
-					'(("\\.ipp$" . c++-mode)
-					  ("\\.inl$" . c++-mode)
-					  ("SCons"   . python-mode)
-					  ("\\.jj$"  . java-mode))
-					auto-mode-alist))
+	      (append
+	       '(("\\.ipp$" . c++-mode)
+		 ("\\.inl$" . c++-mode)
+		 ("SCons"   . python-mode)
+		 ("\\.jj$"  . java-mode))
+	       auto-mode-alist))
 
 ;; x stuff
 (if (not window-system)
-	 (menu-bar-mode nil)                      ; remove menu bar in no-x mode
-  (tool-bar-mode nil)                        ; remove tool bar
-  (scroll-bar-mode nil)                      ; remove scroll bar
+    (menu-bar-mode nil) ; remove menu bar in no-x mode
+  (tool-bar-mode nil)   ; remove tool bar
+  (scroll-bar-mode nil) ; remove scroll bar
   (custom-set-faces '(default ((t (:background "#000000" :foreground "#ffffff" :height 100 :family "DejaVu Sans Mono")))))
   (setq default-frame-alist '((width . 100) (height . 50) (menu-bar-lines . 1)))
 
--- a/hoersten-c-style.el	Thu Jan 01 10:51:38 2009 -0600
+++ b/hoersten-c-style.el	Fri Jan 09 10:39:57 2009 -0600
@@ -2,49 +2,54 @@
 
 ;; hoersten c++-style
 (c-add-style "hoersten"
-				 '(;; indentation
-					(indent-tabs-mode . t)
-					(tab-width        . 3)
-					(c-basic-offset   . 3)
+             '(;; indentation
+               (indent-tabs-mode . t)
+               (tab-width        . 3)
+               (c-basic-offset   . 3)
 
-					;; brace cleanups
-					(c-cleanup-list
-					 brace-else-brace
-					 brace-elseif-brace
-					 brace-catch-brace
-					 empty-defun-braces
-					 defun-close-semi
-					 list-close-comma
-					 scope-operator)
+               ;; brace cleanups
+               (c-cleanup-list
+                brace-else-brace
+                brace-elseif-brace
+                brace-catch-brace
+                empty-defun-braces
+                defun-close-semi
+                list-close-comma
+                scope-operator)
 
-					;; syntactic symbols
-					(c-offsets-alist
-					 (substatement-open . 0)
-					 (inline-open       . 0)
-					 (case-label        . +)
-					 (innamespace       . 0)
-					 (cpp-macro         . -))))
+               ;; syntactic symbols
+               (c-offsets-alist
+                (substatement-open . 0)
+                (inline-open       . 0)
+                (case-label        . +)
+                (innamespace       . 0)
+                (cpp-macro         . -))))
 
 ;; c-like language settings (c, c++, java, etc.)
 (setq-default c-hungry-delete-key t)                             ; enable hungry delete
 (setq-default c-default-style "hoersten")                        ; load c-style
 (add-hook 'c-mode-common-hook
-			 (lambda()
-				(c-toggle-auto-newline t)                            ; auto newline
-				(auto-fill-mode t)                                   ; word wrap
+          (lambda()
+            ;; indentation
+            (setq tab-width 3)
+            (setq c-basic-offset 3)
+            (setq indent-tabs-mode t)
 
-				;; custom keys
-				(local-set-key (kbd "C-c f")   'ff-find-other-file)  ; toggle header/source file
-				(local-set-key (kbd "C-c C-c") 'comment-or-uncomment-region)
+            (c-toggle-auto-newline t)                            ; auto newline
+            (auto-fill-mode t)                                   ; word wrap
 
-				;; code folding
-				(local-set-key (kbd "C-c v") 'hs-toggle-hiding)
-				(local-set-key (kbd "<f1>")  'hs-hide-all)
-				(local-set-key (kbd "<f2>")  'hs-show-all)
-				(hs-minor-mode t)                                    ; enable hide-show mode
-				(hs-hide-all)                                        ; hide all blocks by default
+            ;; custom keys
+            (local-set-key (kbd "C-c f")   'ff-find-other-file)  ; toggle header/source file
+            (local-set-key (kbd "C-c C-c") 'comment-or-uncomment-region)
 
-				;; highlight todos
-				(font-lock-add-keywords
-				 nil
-				 '(("\\([@]\\(TODO\\|todo\\|warning\\)\\)" 1 font-lock-warning-face t)))))
+            ;; code folding
+            (local-set-key (kbd "C-c v") 'hs-toggle-hiding)
+            (local-set-key (kbd "<f1>")  'hs-hide-all)
+            (local-set-key (kbd "<f2>")  'hs-show-all)
+            (hs-minor-mode t)                                    ; enable hide-show mode
+            (hs-hide-all)                                        ; hide all blocks by default
+
+            ;; highlight todos
+            (font-lock-add-keywords
+             nil
+             '(("\\([@]\\(TODO\\|todo\\|warning\\|note\\)\\)" 1 font-lock-warning-face t)))))
--- a/hoersten-pastebin-region.el	Thu Jan 01 10:51:38 2009 -0600
+++ b/hoersten-pastebin-region.el	Fri Jan 09 10:39:57 2009 -0600
@@ -6,30 +6,30 @@
 ;; Based on http://www.emacswiki.org/cgi-bin/wiki/download/pastebin.el
 (defvar pastebin-type-assoc
   '((emacs-lisp-mode . "common-lisp")
-	 (c-mode          . "c")
-	 (python-mode     . "python")
-	 (nxml-mode       . "xml")
-	 (c++-mode        . "cpp")))
+    (c-mode          . "c")
+    (python-mode     . "python")
+    (nxml-mode       . "xml")
+    (c++-mode        . "cpp")))
 
 (defun pastebin-region (start end)
   "Send selected text to dpaste pastebin."
   (interactive "r")
   (let* ((pastebin-url "http://build-ch-03/paste/")
-			(url-request-method "POST")
-			(url-request-extra-headers '(("Content-Type" . "application/x-www-form-urlencoded")))
-			(url-request-data
-			 (format "title=%s&content=%s&lexer=%s&author=%s"
-						(url-hexify-string (buffer-file-name)) ;; title
-						(url-hexify-string (buffer-substring-no-properties start end)) ;; content
-						(url-hexify-string (or (assoc-default major-mode pastebin-type-assoc) "text")) ;; lexer
-						(url-hexify-string (user-full-name))))) ;; author
-	 (url-retrieve pastebin-url (lambda (arg)
-											(cond
-											 ((equal :error (car arg))
-											  (signal (cdr arg)))
-											 ((equal :redirect (car arg))
-											  (let ((redirected (cadr arg)))
-												 (message redirected)
-												 (with-temp-buffer
-													(insert redirected)
-													(clipboard-kill-ring-save (point-min) (point-max))))))))))
+         (url-request-method "POST")
+         (url-request-extra-headers '(("Content-Type" . "application/x-www-form-urlencoded")))
+         (url-request-data
+          (format "title=%s&content=%s&lexer=%s&author=%s"
+                  (url-hexify-string (buffer-file-name))                                         ; title
+                  (url-hexify-string (buffer-substring-no-properties start end))                 ; content
+                  (url-hexify-string (or (assoc-default major-mode pastebin-type-assoc) "text")) ; lexer
+                  (url-hexify-string (user-full-name)))))                                        ; author
+    (url-retrieve pastebin-url (lambda (arg)
+                                 (cond
+                                  ((equal :error (car arg))
+                                   (signal (cdr arg)))
+                                  ((equal :redirect (car arg))
+                                   (let ((redirected (cadr arg)))
+                                     (message redirected)
+                                     (with-temp-buffer
+                                       (insert redirected)
+                                       (clipboard-kill-ring-save (point-min) (point-max))))))))))