Skip to content

Instantly share code, notes, and snippets.

@textarcana
Created February 14, 2009 22:06
Show Gist options
  • Save textarcana/64503 to your computer and use it in GitHub Desktop.
Save textarcana/64503 to your computer and use it in GitHub Desktop.
.emacs file for Aquamacs Emacs and GNU Emacs on OS X.
;;Noah Sussman's .emacs file for Aquamacs Emacs and GNU Emacs on OS X.
;;Branched February 16 2008 from my config for GNU Emacs for Windows, created Oct 18 2001.
;;Time-stamp: </Users/noah/Documents/n_s/config/emacs/aquamacs/.emacs last changed by Noah Sussman on noah.local/Textarcana Saturday 14 February 2009 at EST 16:51:25>
(load-file "~/.emacs-cfg/secrets.el")
;;;; Spaces are always used for indendation
;;;;;; Haml and Sass modes require this setting
(setq indent-tabs-mode nil)
(setq fortune-file "~/Documents/n_s/about/fortune/programming-laws")
;;;; Aquamacs should never show the tool bar
(tool-bar-mode -1)
;;;; Load third-party modules from my Subversion repo
;;;;;; site-lisp-textarcana contains modules which I hand-edit sometimes
(add-to-list 'load-path "~/Documents/n_s/config/emacs/site-lisp-textarcana")
;;;;;; site-lisp-mac is the extracted site-lisp-mac.zip
(add-to-list 'load-path "~/Documents/n_s/config/emacs/site-lisp-mac")
(add-to-list 'load-path "~/Documents/n_s/config/emacs/site-lisp-mac/org")
(add-to-list 'load-path "~/Documents/n_s/config/emacs/site-lisp-mac/remember")
(add-to-list 'load-path "~/Documents/n_s/config/emacs/site-lisp-mac/haml")
;;;; make with the pretty colors in IRC
(require 'erc-nick-colors)
(load-file "~/Documents/n_s/config/emacs/site-lisp-textarcana/erc-doctor.el")
;;;; Load my bookmarks from the repo
(setq bookmark-default-file "~/Documents/n_s/config/emacs/aquamacs/.emacs.bmk")
;;Command to kill all the buffers except scratch, and any explicitly specified
;TODO: should close all frames as well
(defun restart ()
"Kill all buffers, asking permission on unmodified ones."
(interactive)
(let ((list (buffer-list)))
(while list
(let* ((buffer (car list))
(name (buffer-name buffer)))
(and (not (string-equal name "*shell*"))
(not (string-equal name "*weblogic*"))
(not (string-equal name "*Org Agenda*"))
(not (string-equal name "todo.org"))
(kill-buffer buffer)))
(setq list (cdr list))))
(cd "~/Documents/n_s/work/"))
;; Display the file name in the title bar
;; modified? buffername (path)
;;set the title displayed in the title-bar
(setq frame-title-format "%+ %b (%f)")
;;set the title displayed in the task bar when the window is minimized.
;;;On Mac this does nothing.
;(setq icon-title-format "%b")
;;Hit tab and go down one line
(fset 'textarcana/tab-then-down
[?\C-a tab down])
;;;KILL-BLANK-LINE function
(defun textarcana/undouble-newline ()
"Delete doubled newlines from the current buffer."
(interactive)
(save-excursion
(replace-regexp "\n\n" "\n")))
;;* ;Set Size of the Kill-Ring and other histories that we use constantly
(setq kill-ring-max 500)
(setq extended-command-history-max 50)
(setq query-replace-history-max 50)
(setq replace-string-history-max 50)
(setq file-name-history-max 50)
(setq replace-regex-history-max 50)
(setq minibuffer-history-max 1000)
(setq shell-command-history-max 1000)
(setq find-file-history-max 1000)
;;* Bind frequently opened files to
;;* named commands
(defun dot-emacs ()
(interactive)
(find-file "~/Documents/n_s/config/emacs/aquamacs/.emacs"))
(defun abbrev-defs ()
(interactive)
(find-file "~/Documents/n_s/config/emacs/.abbrev_defs"))
;;Calendar and Diary
(setq diary-file "~/Documents/n_s/journal/emacs-diary")
(setq calendar-time-display-form '(24-hours ":" minutes
(if time-zone " (") time-zone (if time-zone ")")))
;;Set Location
(setq calendar-latitude 40.7)
(setq calendar-longitude -74.0)
(setq calendar-location-name "NYC")
(setq all-bahai-calendar-holidays nil)
(setq christian-holidays nil
hebrew-holidays nil
islamic-holidays nil
bahai-holidays nil
)
;SHOW TIME AT STARTUP
;(display-time)
;;SHOW DIARY AT STARTUP and use fancy display and sort entries by time and warn before diary dates that start with a time
(add-hook 'diary-display-hook 'fancy-diary-display)
(add-hook 'diary-hook 'appt-make-list)
;(add-hook 'list-diary-entries-hook 'sort-diary-entries t)
;;Mark Today
(add-hook 'today-visible-calendar-hook 'calendar-mark-today)
;;Mark Holidays and Diary Entries
(setq mark-holidays-in-calendar t)
(setq mark-diary-entries-in-calendar t)
;(setq mark-phases-of-moon-in-calendar t)
;Show X many entries on the Nth day of the [Su M Tu W Th F Sa]
(setq number-of-diary-entries [2 3 2 2 2 1 1])
;;WEEK STARTS WITH MONDAY - this doesn't work for me under Windows
;;(setq calendar-week-start-day 1)
;;SHOW AT STARTUP
;(calendar)
;(diary)
;;Recurring appointments in the calendar
;; (defun h-days (year);; Holidays that defer recycling and paychecks
;; "See http://groups.google.com/group/gnu.emacs.help/browse_thread/thread/ca060dfb9a5d8dca/12be92c98ba08b3d?lnk=st&q=emacs+diary+%22last+day%22#12be92c98ba08b3d"
;; (list (calendar-absolute-from-gregorian (list 1 1 year));; New Year
;; (calendar-dayname-on-or-before 1;; Monday
;; (calendar-absolute-from-gregorian (list 5 31 year)));; Memorial Day
;; (calendar-absolute-from-gregorian (list 7 4 year));; July 4
;; (calendar-nth-named-absday 1 1 9 year);; Labor Day
;; (calendar-nth-named-absday 4 4 11 year);; Thanksgiving
;; (calendar-absolute-from-gregorian (list 12 31 year));; Christmas
;; ))
;; (defun recycle-date (d)
;; ;; True if absolute date d should be a recycling date
;; (let* ((diff (- d (calendar-absolute-from-gregorian
;; (list 6 30 2003)))));; first recycyling pickup
;; (and (>= diff 0) (zerop (% diff 14)))))
;; (defun recycling ()
;; (let* ((month (extract-calendar-month date))
;; (day (extract-calendar-day date))
;; (year (extract-calendar-year date))
;; (a (calendar-absolute-from-gregorian date))
;; (h (h-days year)))
;; (or (and (recycle-date a) (not (memq a h)))
;; (and (recycle-date (1- a)) (memq (1- a) h)))))
;;Set color theme
;(color-theme-jsc-dark)
;(color-theme-calm-forest)
;(color-theme-lawrence)
;(color-theme-katester)
;;SLIME configuration
;; but doesn't work with LispWorks
; (add-to-list 'load-path "~/Documents/n_s/work/cb/frameworks/lisp/") ; your SLIME directory
; (setq inferior-lisp-program "/Applications/LispWorks\ Personal\ 5.0/LispWorks\ Personal.app") ; your Lisp system
; (require 'slime)
; (slime-setup)
;;Display or insert the current date and time *
;;(insert date) *
(defun date (&optional insert)
"Display the current date and time.
With a prefix arg, INSERT it into the buffer."
(interactive "P")
(funcall (if insert 'insert 'message)
(format-time-string "%l:%M:%S %p EST on %A, %B %d %Y" (current-time))))
(defun short-date (&optional insert)
"Display year.month.date,.
With a prefix arg, INSERT it into the buffer.
Eventually should be able to insert this directly into kill-ring with a key-command."
(interactive "P")
(funcall (if insert 'insert 'message)
(format-time-string "%Y.%m.%d" (current-time))))
(defun @-month-date (&optional insert)
"Display year.month.date,.
With a prefix arg, INSERT it into the buffer.
Eventually should be able to insert this directly into kill-ring with a key-command."
(interactive "P")
(funcall (if insert 'insert 'message)
(format-time-string "%Y.%m" (current-time))))
(defun created-by-noah (&optional insert)
"Insert a line stating that I created this at the current time."
(interactive "P")
(insert
(format-time-string "--N.S. at%l:%M:%S %p EST on %A, %B %d %Y" (current-time))))
;;~ UPDATE TIME STAMPS IN ALL FILES
;;Turn on time-stamp updating. Timestamp must be in first 8 lines of file and look like:
;; Time-stamp: <>
(add-hook 'write-file-hooks 'time-stamp)
(setq time-stamp-format ; format of the stamp
;;use M-x describe-variable RET time-stamp-format for info
"%F last changed by Noah Sussman on %s/Textarcana %:a %02d %:b %:y at %Z %02H:%02M:%02S"
time-stamp-active t ; update timestamps
time-stamp-warn-inactive t) ; warn if unable
;;* SET UP TADS MODE
;; Something is highly wrong with this.
;;;;Set up TADS (Text Adventure Development System)
;;;NOTE that the file in site-lisp should be renamed from tads2-mode to tads-mode
;;;and that the code to launch tads2-mode given in that file will not work.
(autoload 'tads-mode "tads-mode")
(setq auto-mode-alist
(cons '("\\.t\\'" . tads-mode) auto-mode-alist))
;;
;;;;Set up Abbreviation Mode
;;; C-x a i g to create a global abbreviation
;;; C-x a i l for local abbrev.
(setq-default abbrev-mode t)
(read-abbrev-file "~/Documents/n_s/config/emacs/.abbrev_defs")
(setq save-abbrevs t)
;**********************************************************
;*
;* Reload the .emacs file with a minimum of effort,
;* first saving histories with Persistent
;*
;**********************************************************
(defun reload () (interactive)
"Reload .emacs"
;; (persistent-session-save-alist-to-file) ;;persistent session not enabled here as yet
(if (file-exists-p "~/Documents/n_s/config/emacs/aquamacs/.emacs")
(load-file "~/Documents/n_s/config/emacs/aquamacs/.emacs")))
;;;; Org Mode
;;;; See http://www.newartisans.com/blog_files/org.mode.day.planner.php
;; C-M-r t create a new todo item
;; C-c C-c save newly created todo item
; Agenda view AND when editing org file ?
;; C-c C-t mark item DELEGATED?
;; C-c C-x C-s archive a todo item
;; C-c C-s assign a due date to an existing todo item
;; C-c a m tag search
;;; Time tracking
;;; See http://orgmode.org/manual/Clocking-work-time.html#Clocking-work-time
;; C-c C-x C-d display time tracking next to org headers
;; C-c C-x C-i start the clock on a task (stops current clock if running)
;; C-c C-x C-o stop the clock
;; C-c C-x C-x CANCEL the clock
;; C-c C-x C-j jump to the task the clock is currently running against
;;; Agenda view time-tracking
;; R toggle time tracking table
;; l toggle logbook, shows time logged, job status changes
;; I start tracking time against a task
; Agenda view only
;; C-u t change the status of a task
;; , prioritize a task
;; z add a NOTE about a task
;; SPACE show a task in its org file, including notes and time tracking history
;; C-c a L timeline view of agenda
;; C-c a a 7-day agenda view
;; r refresh agenda view
;; . jump to today
;; d day view
;; C-c a c list completed tasks
;; D toggle diary entries and events
; only when editing an org file
;; S-M-Ret add a new todo item below the current one
;; C-c C-c tag a todo item
(require 'org-install)
(setq org-log-done '(state))
(add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
(define-key mode-specific-map [?a] 'org-agenda)
;; Lets you select from any header in the first 5 levels of hierarchy when refiling notes with C-c C-w
(setq org-refile-targets '((org-agenda-files . (:maxlevel . 5))))
(eval-after-load "org"
'(progn
(define-prefix-command 'org-todo-state-map)
(define-key org-mode-map "\C-cx" 'org-todo-state-map)
(define-key org-todo-state-map "x"
#'(lambda nil (interactive) (org-todo "CANCELLED")))
(define-key org-todo-state-map "d"
#'(lambda nil (interactive) (org-todo "DONE")))
(define-key org-todo-state-map "f"
#'(lambda nil (interactive) (org-todo "DEFERRED")))
(define-key org-todo-state-map "l"
#'(lambda nil (interactive) (org-todo "DELEGATED")))
(define-key org-todo-state-map "s"
#'(lambda nil (interactive) (org-todo "STARTED")))
(define-key org-todo-state-map "w"
#'(lambda nil (interactive) (org-todo "WAITING")))
(setq truncate-lines nil)
(setq truncate-partial-width-windows nil)
))
(eval-after-load "org-agenda"
'(progn
(define-key org-agenda-mode-map "\C-n" 'next-line)
(define-key org-agenda-keymap "\C-n" 'next-line)
(define-key org-agenda-mode-map "\C-p" 'previous-line)
(define-key org-agenda-keymap "\C-p" 'previous-line)
))
;;;; Remember mode
(require 'remember)
(add-hook 'remember-mode-hook 'org-remember-apply-template)
(define-key global-map [(control meta ?r)] 'remember)
(custom-set-variables
'(org-agenda-files (quote ("/Users/noah/Dropbox/journal/todo.org")))
'(org-default-notes-file "/Users/noah/Dropbox/journal/notes.org")
'(org-agenda-ndays 7)
'(org-deadline-warning-days 14)
'(org-agenda-show-all-dates t)
'(org-agenda-skip-deadline-if-done t)
'(org-agenda-skip-scheduled-if-done t)
'(org-agenda-start-on-weekday nil)
'(org-agenda-todo-list-sublevels nil) ;Don't show subtasks in global todo list
'(org-reverse-note-order t)
'(org-fast-tag-selection-single-key (quote expert))
'(org-agenda-custom-commands
(quote (("d" todo "DELEGATED" nil)
("c" todo "DONE|DEFERRED|CANCELLED" nil)
("w" todo "WAITING" nil)
("W" agenda "21-day agenda" ((org-agenda-ndays 21)))
("A" agenda "today's high-priority tasks"
((org-agenda-skip-function
(lambda nil
(org-agenda-skip-entry-if (quote notregexp) "\\=.*\\[#A\\]")))
(org-agenda-ndays 1)
(org-agenda-overriding-header "Today's Priority #A tasks: ")))
("u" alltodo "unscheduled todo items"
((org-agenda-skip-function
(lambda nil
(org-agenda-skip-entry-if (quote scheduled) (quote deadline)
(quote regexp) "&lt;[^&gt;\n]+&gt;")))
(org-agenda-overriding-header "Unscheduled TODO entries: "))))))
'(org-remember-store-without-prompt t)
'(org-remember-templates
(quote (
(116 "* TODO %?\n %u" "/Users/noah/Dropbox/journal/todo.org" "Tasks")
(110 "* %u %?" "/Users/noah/Dropbox/journal/notes.org" "Notes")
; (113 "* %u %?" "~/Documents/n_s/journal/quotes.org" "Quotations")
; (99 "* %u %?" "~/Documents/n_s/journal/citations.org" "Citations")
; (108 "* TODO Look up %?, seen in \n %u" "~/Documents/n_s/journal/todo.org" "Lookup")
)))
'(remember-annotation-functions (quote (org-remember-annotation)))
'(remember-handler-functions (quote (org-remember-handler))))
;;;; Close the parent task when all subtasks are done.
(defun org-summary-todo (n-done n-not-done)
"Switch entry to DONE when all subentries are done, to TODO otherwise."
(let (org-log-done org-log-states) ; turn off logging
(org-todo (if (= n-not-done 0) "DONE" "TODO"))))
(add-hook 'org-after-todo-statistics-hook 'org-summary-todo)
;;;; Show at startup
;(org-agenda-goto-today)
;(org-agenda-goto-calendar)
;(org-agenda)
;(org-agenda-list)
;(calendar)
;;;; JS 2 Mode
;;;; NOT kept in the repo because it must be byte-compiled on the local machine. Just put it in c:/emacs/site-lisp after downloading from the project page:
;;;; http://code.google.com/p/js2-mode/wiki/InstallationInstructions
(autoload 'js2-mode "js2" nil t)
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
;;; HAML and SASS modes
(customize-set-variable 'indent-tabs-mode nil)
(require 'haml-mode nil 't)
(add-to-list 'auto-mode-alist '("\\.haml$" . sass-mode))
(require 'sass-mode nil 't)
(add-to-list 'auto-mode-alist '("\\.sass$" . sass-mode))
;; ZepInvest environment tools
;;;; should be broken into separate include eventually
(defun zep-terminals ()
"Start up the many shells I use on a daily basis."
(interactive)
(term "/bin/bash")
(rename-buffer "test runs")
(term "/bin/bash")
(rename-buffer "zepinvest")
(term "/bin/bash")
(rename-buffer "dev SSH")
(term "/bin/bash")
(rename-buffer "textarcana")
(term "/bin/bash")
(rename-buffer "Selenium RC process")
(term "/bin/bash")
(rename-buffer "WEBrick process")
(term "/bin/bash")
(rename-buffer "Autotest process")
(term "/bin/bash")
(rename-buffer "Synergy Client process")
)
;;; Aquamacs transparency
;;;;; see http://www.emacswiki.org/emacs/CustomizeAquamacs
(defun transparency-set-initial-value ()
"Set initial value of alpha parameter for the current frame"
(interactive)
(if (equal (frame-parameter nil 'alpha) nil)
(set-frame-parameter nil 'alpha 100)))
(defun transparency-set-value (numb)
"Set level of transparency for the current frame"
(interactive "nEnter transparency level in range 0-100: ")
(if (> numb 100)
(message "Error! The maximum value for transparency is 100!")
(if (< numb 0)
(message "Error! The minimum value for transparency is 0!")
(set-frame-parameter nil 'alpha numb))))
(defun transparency-increase ()
"Increase level of transparency for the current frame"
(interactive)
(transparency-set-initial-value)
(if (> (frame-parameter nil 'alpha) 0)
(set-frame-parameter nil 'alpha (+ (frame-parameter nil 'alpha) -1))
(message "This is a minimum value of transparency!")))
(defun transparency-decrease ()
"Decrease level of transparency for the current frame"
(interactive)
(transparency-set-initial-value)
(if (< (frame-parameter nil 'alpha) 100)
(set-frame-parameter nil 'alpha (+ (frame-parameter nil 'alpha) +1))
(message "This is a minimum value of transparency!")))
;;;;;; keybinding for transparency manipulation
(global-set-key (kbd "C-?") 'transparency-set-value)
;;;;;; the two below let for smooth transparency control
(global-set-key (kbd "C->") 'transparency-increase)
(global-set-key (kbd "C-<") 'transparency-decrease)
;;;;;; Set initial frame transparency
(setq transparency-level 85)
(transparency-set-value transparency-level)
(add-hook 'after-make-frame-functions (lambda (selected-frame) (set-frame-parameter selected-frame 'alpha transparency-level)))
;;;;;;;; Haven't yet gotten newly-created frames to work with transparency-set-value
;(add-hook 'after-make-frame-functions (lambda (selected-frame) (transparency-set-initial-value)) (lambda (selected-frame) (transparency-set-value 10)))
;; ERC IRC Client Config
;;;; Buttonize URLs http://www.emacswiki.org/emacs/ErcConfiguration
(setq erc-button-url-regexp
"\\([-a-zA-Z0-9_=!?#$@~`%&*+\\/:;,]+\\.\\)+[-a-zA-Z0-9_=!?#$@~`%&*+\\/:;,]*[-a-zA-Z0-9\\/]")
;;;; Highlight keywords
(setq erc-keywords '("\\bhaml\\b" "\\sass\\b"))
;;;; Enable erc-nicklist
(require 'erc-nicklist)
;;;; Growl support
;;;;; Requires growlnotify, source for which is included in the Growl disk image
;; (load-file "~/Documents/n_s/config/emacs/site-lisp-textarcana/todochiku.el")
;; Because todochiku uses the --image option, it is not reliable on OSX 10.5
;; see http://forums.cocoaforge.com/viewtopic.php?f=6&t=17526&p=114069
;;;;;; Wrapper for growlnotify
(defun growl-chat (title message &optional sticky)
(interactive "sTitle: \nsGrowl: ")
(shell-command
(format "/usr/local/bin/growlnotify %s -m '%s' --appIcon 'Aquamacs Emacs' %s" title message (if sticky "--sticky" ""))))
(defun growl-chat-sticky (title message)
(interactive "sTitle: \nsGrowl: ")
(growl-chat title message t))
;;;;;; Growl nicknames and highlight words
(add-hook 'erc-text-matched-hook
(lambda (match-type nickuserhost message)
(when (and
(boundp 'nick)
(not (string= nick "ChanServ"))
(not (string= nick "services."))
;(not (string= message "!"))
)
(cond
((eq match-type 'current-nick)
(growl-chat-sticky (format "%s said %s" nick (erc-current-nick)) message))
((eq match-type 'keyword)
(growl-chat (format "%s mentioned a Keyword" nick) message))))))
;;;; ERC Robot
(load-library "erc-robot")
(add-hook 'erc-server-PRIVMSG-functions 'erc-robot-remote t)
(add-hook 'erc-send-completed-hook 'erc-robot-local t)
(setq erc-robot-commands
'(
("help" t (lambda (args)
(concat "commands available: "
(mapconcat
(lambda (e)
(car e))
erc-robot-commands " "))))
;("hello" t (lambda (args) "hello to you too !"))
;("zippy" t (lambda (args) (erc-replace-regexp-in-string "\n" " " (yow))))
;("doctor" t erc-cmd-DOCTOR)
;("echo" t (lambda (args) args))
("version" t (lambda (args) (erc-version)))
("fortune" t (lambda (args)
(require 'fortune)
(fortune-in-buffer nil)
(let ((f (get-buffer fortune-buffer-name)))
(if f
(progn
(set-buffer f)
(erc-replace-regexp-in-string
"\n" " " (buffer-substring (point-min)
(point-max))))
"no fortunes!"))))
;; Subversion status
("info" t (lambda (args) (shell-command-to-string "svn info ~/Sites/zepinvest/branches/v1.3.0 | grep -iE \"(Revision|Path)\" | perl -pe \"chomp if eof\"")))
("st" t (lambda (args) (concat (shell-command-to-string "svn st ~/Sites/zepinvest/branches/v1.3.0 | wc -l | perl -pe \"s/\s+//; chomp\"") " files with local modifications.")))
))
;;;; ERC autojoin server and channels
;;;; Password, Nick, etc are stored in secrets.el
;;;;;; See
;;;;;; http://textarcanachua.com/notebook/emacs/erc-config.el
;;;;;; https://kanis.fr/svn/trunk/wk/lisp/emacs.d/ivan-erc.el
(setq erc-autojoin-channels-alist
'((".freenode.net$" . ("#zepinvest"))
(".perl.org$" . ("#perl"))))
(defun textarcana/erc ()
"Connect to Freenode."
(interactive)
(textarcana/erc-freenode))
(defun textarcana/erc-freenode () "Connect to Freenode."
(erc-select :server "irc.freenode.net" :port 6667 :nick freenode-nick :password freenode-password :full-name freenode-fullname))
(defun erc-autojoin-channels (server nick)
(dolist (l erc-autojoin-channels-alist)
(when (string-match (car l) server)
(dolist (chan (cdr l))
(erc-send-command (concat "join " chan))))
(add-hook 'erc-after-connect 'erc-autojoin-channels)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment