Skip to content

Instantly share code, notes, and snippets.

@textarcana
Created February 15, 2009 13:56
Show Gist options
  • Save textarcana/64706 to your computer and use it in GitHub Desktop.
Save textarcana/64706 to your computer and use it in GitHub Desktop.
.emacs for Windows port of GNU Emacs
;; Noah Sussman's .emacs file
;; Created Oct 18, 2001
;; Time-stamp: <c:/noah/n_s/config/emacs/.emacs last changed by Noah Sussman on PENTAGRAM/Textarcana Friday 27 February 2009 at Eastern Standard Time 12:37:21>
;; Introduction
;; emacs command reference:
;; SHELL MODE
;; Normally you can type M-x shell to open a new shell buffer, but if you already have one open that will just switch to the existing one. The solution is to use M-x rename-buffer to change the name of the first shell buffer before creating another one.
;; Use M-r regexp and M-s regexp to search in reverse and forward, respectively, through the command history. To search using the same regex as last time, leave the regex entery field blank and hit return.
;;
;; EDITING
;; M-$ check the spelling of the word at point
;; C-l center this line in display
;; C-o open-line (insert CR w/out moving mark)
;; M-m move mark to first non-whitespace character on line
;; M-shift-arrow select
;; C-x C-x exchange-point-and-mark
;;
;; or use set-mark-command:
;; C-SPACE or C-@ or M-x
;; M-h mark paragraph
;; C-x h mark-whole-buffer
;;
;; MOVING POINT TO PREVIOUS POSITIONS
;; C-x C-x Moves point to the last mark
;; C-u C-<SPC> Moves point to the previous mark in the mark-ring
;;
;; MACROS
;; M-x name-last-kbd-macro
;; M-x <macroname> to use a named macro
;; M-x insert-kbd-macro RET <macroname> RET to insert the macro into .emacs
;;
;; WINDOW CONTROL
;; M C-v scroll-other-window
;; C-x 2 spawn horizontal window
;; C-x 3 " vertical "
;; C-x 0 close current window
;; C-x 1 " other windows
;; C-x > shift window right
;; C-x < " left
;; C-x } widen window
;; C-x { narrow "
;; C-x ^ heighten "
;; M-x shrink-window
;; C-x + balance windows
;; M-x delete-windows-on RET buffername RET
;;
;; MANPAGES
;; The following works for any manpage.
;; To read the manpage for ls:
;; M-x man RET ls RET
;;
;; USEFUL
;; C-x ESC ESC repeat-complex-command
;; C-x 5 o other frame?
;; C-x 5 f find-file other frame
;; C-x C-q toggle read-only
;; C-t transpose letters
;; M-t transpose words
;;
;; LATEX-MODE
;; M-x latex-validate-buffer
;;
;; THE BUFFER LIST
;; C-x C-b buffer-list
;; d delete
;; s save
;; u unmark
;; x execute
;; ~ mark as unmodified
;; % toggle read-only
;; o show in other window
;; f show in this window
;; 1 show in entire window
;; m mark for display
;; v display marked
;; 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
;; Note that paths in this file use FORWARD slashes, that is:
;; "C:/foo/", not "C:\foo\"
;; End Introduction
(setq arcane-path "c:/noah/n_s/")
;; Spaces are always used for indendation
;; Haml and Sass modes require this setting
(setq indent-tabs-mode nil)
;; Load third-party modules from my Subversion repo
(add-to-list 'load-path (concat arcane-path "config/emacs/site-lisp-textarcana"))
(add-to-list 'load-path (concat arcane-path "config/emacs/site-lisp-mac"))
(add-to-list 'load-path (concat arcane-path "config/emacs/site-lisp-pc"))
;; Subdirectories MUST be explicitly called out:
(add-to-list 'load-path (concat arcane-path "config/emacs/site-lisp-mac/haml"))
(add-to-list 'load-path (concat arcane-path "config/emacs/site-lisp-mac/org"))
(add-to-list 'load-path (concat arcane-path "config/emacs/site-lisp-mac/remember"))
;; Passwords variables are defined here
(load-file "c:/noah/local/.emacs.cfg/secrets.el")
;; 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
;; ERC IRC Client Config
;; make with the pretty colors in IRC
(require 'erc-nick-colors)
;; 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"))
;; 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" "#emacs" "##javascript" "#css" "#nyc.rb"))))
(defun arcane/erc ()
"Connect to Freenode."
(interactive)
(arcane/erc-freenode))
(defun arcane/erc-freenode () "Connect to Freenode."
(erc-select :server "irc.freenode.net" :port 6667 :nick freenode-nick :password freenode-password :full-name "Noah Sussman"))
(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)))
;; Fictional ERC commands
(defun erc-cmd-TEST (&rest ignore)
"Display a string."
(erc-display-message nil 'notice (current-buffer) "something"))
;; Browse Kill Ring
(require 'browse-kill-ring)
(browse-kill-ring-default-keybindings)
;; ~ View-back-to-mark ~
;; ~ GO BACK TO LAST CURSUR POSITION ~
;; ~ CYCLE THROUGH PREVIOUS CURSOR POSITIONS ~
;; what-line
(global-set-key "\C-l" 'what-line)
;; View-back-to-mark
(global-set-key "\M-a" 'View-back-to-mark)
;; Reload the .emacs file with a minimum of effort,
;; first saving histories with Persistent
(defun reload () (interactive)
"Reload c:/.emacs"
(persistent-session-save-alist-to-file)
(if (file-exists-p "c:/.emacs")
(load-file "c:/.emacs")))
;; Bind frequently opened files and directories to
;; command sequences
(defun dot-emacs ()
(interactive)
(find-file (concat arcane-path "config/emacs/.emacs")))
(defun abbrev-defs ()
(interactive)
(find-file (concat arcane-path "config/emacs/.abbrev_defs")))
(defun snip (snippet)
(interactive "sSnippet Path: ")
(insert-file snippet))
;; set local search path (for web server)
(setq load-path (cons (expand-file-name "~/site-lisp/") load-path))
;; backup buffer and persistent.el history
;; This means I have a second UNDO command, one that doesn't get
;; fragged when the CPU goes down. The max. number of saved new files
;; is the only limit to the level of such an UNDO command!
;; main macro depends on this name:
(fset 'arcane/make-backup-macro
[?\C-u ?\C-u ?\C-x ?\C-s])
;; main macro depends on this name:
(fset 'arcane/save-persistent-list-macro
[?\M-x ?p ?e ?r ?s ?i ?s ?t tab ?s ?a tab return])
;; main macro:
(fset 'arcane/make-backup-of-current-buffer-and-save-persistent-list-macro
[?\M-x ?a ?r ?c ?a ?n ?e ?/?m ?a ?k ?e ?- ?b ?a ?c ?k ?u ?p ?- ?m ?a ?c ?r ?o return ?\M-x ?a ?r ?c ?a ?n ?e ?/?s ?a ?v ?e ?- ?p ?e ?r ?s ?i ?s ?t ?e ?n ?t ?- ?l ?i ?s ?t ?e backspace ?- ?m ?a ?c ?r ?o return])
(global-set-key "\M-e" 'arcane/make-backup-of-current-buffer-and-save-persistent-list-macro)
;; save buffer (shortcut key)
(global-set-key "\M-s" 'save-buffer) ;save
(global-set-key "\C-\M-s" 'write-file) ;save as
;; override latex-mode keybinding
;; Note that, after adding mode-hook, you must re-load the mode as well as your emacs file.
(add-hook 'latex-mode-hook 'n-latex-mode-hook)
(defun n-latex-mode-hook ()
(local-set-key "\M-s" 'save-buffer))
;; search and replace
(global-set-key "\C-s" 'isearch-forward-regexp)
(global-set-key "\M-%" 'query-replace-regexp) ;Remember to backslash your
;parentheses when backreferencing,
;and to refer to backreferences
;; Destroy whitespace at the beginning of a line, then move down one line
(fset 'arcane/destroy-whitespace-at-the-beginning-of-this-line-then-move-down-one-line
[?\C-a ?\C- ?\C-s ?\\ ?b right left ?\C-w down])
;; Search For Table Tags: find the next <table or </table tag
(fset 'arcane/search-for-table-tags
"\C-s<[/]?table\C-x\C-s")
(fset 'arcane/find-table-tags
"\C-s<[/]?table\C-x\C-s")
;; Insert a BASE HREF tag just after the head tag of an HTML document
;; Positions point just after the second forwardslash in "HTTP://"
;; The URL must be edited manually below:
;; isnt there a way to bind two names to the same macro???
(fset 'arcane/base-href-insert
[?\M-< ?\C-s ?< ?h ?e ?a ?d ?\C-e return return return up ?< ?b ?a ?s ?e ? ?h ?r ?e ?f ?= ?" ?h ?t ?t ?p ?: ?/ ?/ ?" ?> left left])
(fset 'arcane/insert-base-href
[?\M-< ?\C-s ?< ?h ?e ?a ?d ?\C-e return return return up ?< ?b ?a ?s ?e ? ?h ?r ?e ?f ?= ?" ?h ?t ?t ?p ?: ?/ ?/ ?" ?> left left])
;; Insert JSP Comment
(fset 'arcane/jsp-comment
[?< ?% tab return ?/ ?* tab ? ?\C-u ?\C-u ?~ return return ?* ?/ ? ?\C-u ?\C-u ?~ ?\C-_ backspace left left ?\C-u ?\C-u ?~ ? ?\C-e return ?% ?> tab tab up up tab])
;; Insert HTML comment (Works best in html-helper-mode)
(fset 'arcane/html-comment
[?< ?! ?- ?- ? ?\C-u ?\C-u ?~ ? ? ? ?\C-u ?\C-u ?~ ? ?- ?- ?> ?\C-u ?\C-u left ?\C-b ?\C-b ?\C-b ?\C-b ?\C-b ?\C-b tab])
;; Hit tab and go down one line
(fset 'arcane/tab-then-down
[?\C-a tab down])
;; latex-indexify-selection
;; Expects a block of text to be selected. Put an \index{the block} tag after the block.
(fset 'arcane/latex-indexify-selection
"\M-w\\index{\C-y}")
;; turn \item{foo} into <h1>foo</h1> save and go on to the next buffer
(fset 'arcane/fix-fragments
[?\M-d delete ?< ?h ?1 ?> ?\C-s ?] left delete ?< ?h ?1 backspace backspace ?/ ?h ?1 ?> return return ?\C-x ?\C-s ?\C-x ?k return down return])
;; break up a tex file containing \item blocks and drop each block into a folder called GLOSSARY, as a text file. Also creates a file called temp.txt in the main directory.
;; The original target file is \DEV\GAMEDEV\BOOK\Glossary_of_Miwasi.tex
(fset 'arcane/break-tex-items-into-files
[?\C-s ?\\ ?i ?t ?e ?m right ?\C- ?\C-s ?] left ?\M-w ?\C-a ?\C- ?\C-s ?\\ ?i ?t ?e ?m ?\C-s ?\C-a ?\M-w ?\C-x ?\C-f ?t ?e ?m ?p ?l backspace ?. ?t ?x ?t return ?\C-x ?h ?\C-y ?\C-x ?\C-s ?\C-x ?b return ?\C-x ?\C-f ?g ?l ?o ?s ?s ?a ?r ?y ?/ ?\C-y ?\M-y ?. ?p ?h ?p return ?\C-x ?i ?\M-b ?\C-k ?t ?e ?m ?p ?. ?t tab return ?\C-x ?\C-s ?\C-x ?b return])
;; The much sought-after "starbox" macro
(fset 'arcane/starbox
[?\C-a return ?* ?* ? up ?/ ?\C-u ?\C-u ?\C-u ?* down return ?\C-u ?\C-u ?\C-u ?* ?/])
(fset 'arcane/starbox-lvl-2
[?\C-a return ?= ?= ? up ?/ ?* ?\C-u ?\C-u ?\C-u ?= down return ?\C-u ?\C-u ?\C-u ?= ?* ?/])
(fset 'arcane/starbox-tilde
[?\C-a return ?~ ?~ ? up ?/ ?* ?\C-u ?\C-u ?\C-u ?~ down return ?\C-u ?\C-u ?\C-u ?~ ?* ?/])
(fset 'arcane/starbox-pipe
[?\C-a return ?| ?| ? up ?/ ?* ?\C-u ?\C-u ?\C-u ?| down return ?\C-u ?\C-u ?\C-u ?| ?* ?/])
;; Explode a bookmarklet
(defun arcane/explode-bookmarklet ()
"Explode a bookmarklet by inserting newlines after semicolons and curly braces."
(interactive)
(save-excursion
(replace-string "{" "{\n"))
(save-excursion
(replace-string "}" "\n}\n"))
(save-excursion
(replace-string ";" ";\n")))
(defun arcane/table-tagset-apocalypse ()
"Destroy all table markup!"
(interactive)
(save-excursion
(replace-regexp "<[/]?\\(table\\|td\\|tr\\|th\\|tbody\\)[^>]*>" "")))
(defun arcane/presentational-html-apocalypse ()
"Destroy all table markup!"
(interactive)
(save-excursion
(replace-regexp "<[/]?\\(p\\|font\\)[^>]*>" "")))
(defun arcane/tagset-apocalypse ()
"Destroy all table markup!"
(interactive)
(arcane/table-tagset-apocalypse)
(arcane/presentational-html-apocalypse))
(defun arcane/xhtml-img-tag-to-html4-img-tag ()
"For use with the Firefox IMGTag extension."
(interactive)
(save-excursion
(replace-regexp "style=\"\\(width\\): \\([0-9]*\\)px; \\(height\\): \\([0-9]*\\)px; border: 0\"\\( alt=\"\"\\) />" "\\1=\"\\2\" \\3=\"\\4\"\\5>")))
(defun arcane/palm-optimize ()
"For Palm eBook optimization. Make ready for conversion to ebook. Mostly cleans up crap left by various document converters."
(interactive)
(save-excursion
(replace-regexp "—" "---")
(replace-regexp "‘" "'")))
(defun arcane/only-allow-doubled-newlines ()
"For Palm eBook optimization. Delete any newline not immediately followed by another newline. Use to remove hard returns within paragraphs. Paragraphs should be separated by at least two hard returns."
(interactive)
(save-excursion
;(replace-regexp "^\\(.*?\\)\n" "\\1 ")))
(replace-regexp "\n\\([^\n]\\)" " \\1"))) ;;If after \n, next line does not also start with \n, delete \n and replace it with the first character of the next line.
(defun arcane/undouble-newline ()
"Delete doubled newlines from the current buffer."
(interactive)
(save-excursion
(replace-regexp "\n\n" "\n")))
(defun arcane/collapse-brackets ()
"Delete line breaks after \"{\" and before \"}\"."
(interactive)
(save-excursion
(replace-regexp "{\n" "{")
(replace-regexp "\n}" "}")))
(defun arcane/linkfix ()
"Fix links for the FW search side nav. Run it on string : href=\"chicken.html\" target=\"right\" to see what it does..."
(interactive)
(save-excursion
(replace-regexp "\\(href=\"\\)\\([^\\.]*\\)\\.html\\(\" target=\"\\)right\"" "\\1index_top_frame.php4?search=\\2\\3\\4top\"")))
(defun arcane/strip-markup ()
"Destroy all SGML markup tags."
(interactive)
(save-excursion
(replace-regexp "<[^>]*>" "")))
;; highlight jstl tags
(fset 'arcane/highlight-JSTL-tags
"\C-s<[/]?[^:> ]+:")
;; 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 "c:/.abbrev_defs")
(setq save-abbrevs t)
;; Set up printer -- this doesn't actually work.
;; (setq printer-name "EPUSB1:") ; non-standard port
;; EMACS-PERSISTENT MODE IS JUST THE BEST
;; Use persistent-session-save-alist-to-file to save your current history.
;; set up persistent.el
;; to remember histories across emacs sessions
;; from: http://www.geocrawler.com/archives/3/338/1995/8/0/1876983/
(setq persistent-session-list `(read-expression-history
extended-command-history
find-tag-history
query-replace-history
grep-history
file-name-history
compile-history
kill-ring
replace-string-history
replace-regex-history
query-replace-regex-history
minibuffer-history
shell-command-history
buffer-name-history
find-file-history
))
(require `persistent)
(persistent-session-load-from-alist)
(setq persistent-session-size 500) ;I forget why this is here...
;; 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)
;; SHELL MODE
;; Allow using arrow keys for cmd history, etc.
(add-hook 'shell-mode-hook 'n-shell-mode-hook)
(defun n-shell-mode-hook ()
;; "12Jan2002 - sailor, shell mode customizations."
(local-set-key '[up] 'comint-previous-input)
(local-set-key '[down] 'comint-next-input)
(local-set-key '[(shift tab)] 'comint-next-matching-input-from-input)
(setq comint-scroll-to-bottom-on-output all))
;; GENERAL EMACS SETTINGS
;; splash screen overlays my calendar
(setq inhibit-splash-screen t)
;; PHP-MODE
(require 'php-mode)
;; 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)
;; Turn on PC-Style selection deletion
;; (This also turns on transient-mark-mode)
(pc-selection-mode)
;; Turn On Javascript-Generic Mode
(require 'generic-x)
(add-to-list 'generic-extras-enable-list 'javascript-generic-mode)
;; Syntax Coloring
(global-font-lock-mode 1)
;; Make Numbered Backups of Files
(setq version-control t)
;; Don't ask when deleting old backups
(setq delete-old-versions t)
;; Number of Numbered Backups to Keep
;; Delete Oldest Version First
;; setq kept-old-versions 50)
(setq kept-new-versions 100)
;; Calendar****
;; Calendar and Diary
(setq diary-file "c:/dropbox/My Dropbox/journal/todo.org")
(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
;; (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
;;Xmas
(calendar-absolute-from-gregorian (list 12 31 year))))
(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)))))
;; cperl mode
;; Use cperl-mode instead of the default perl-mode
(add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode))
(add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
(add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
(add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
(add-hook 'cperl-mode-hook 'n-cperl-mode-hook t)
(defun n-cperl-mode-hook ()
(setq cperl-indent-level 4)
(setq cperl-continued-statement-offset 0)
(setq cperl-extra-newline-before-brace t)
(set-face-background 'cperl-array-face "wheat")
(set-face-background 'cperl-hash-face "wheat"))
;; css-mode settings
;; keyboard shortcuts in css mode**
;; css-insert-comment
;; This inserts a comment and is bound to "C-c C-c".
;; css-insert-url
;; This inserts an empty URL specification and is bound to "C-c C-u".
;; For editing Cascading Style Sheets
;; Load CSS Mode
(autoload 'css-mode "css-mode")
(setq auto-mode-alist
(cons '("\\.css\\'" . css-mode) auto-mode-alist))
;; set C-style indentation instead of CSS-style
(setq cssm-indent-function #'cssm-c-style-indenter)
(setq cssm-indent-level 4)
;; csound-mode settings
;; Csound Mode
;; This should cause csound modes to be automatically loaded whenever
;; we open an .orc or .sco file.
(setq auto-mode-alist (cons '("\\.orc$" . csound-orc-mode) auto-mode-alist))
(autoload 'csound-orc-mode "csound-orc" "Csound Orchestra major mode." t)
(setq auto-mode-alist (cons '("\\.sco$" . csound-sco-mode) auto-mode-alist))
(autoload 'csound-sco-mode "csound-sco" "Csound Score major mode." t)
;; Set up some things about orc mode
(setq csound-orc-mode-hook
'(lambda ()
(setq font-lock-maximum-decoration t)
(turn-on-font-lock)
(setq csound-orc-mode-do-write-file-hooks t)
(setq csound-orc-mode-build-new-buffer t)
(setq csound-orc-mode-address-string "copyright 2001 Noah Sussman ")
(setq csound-tab-stops '(10 18 28))
(setq csound-orc-comment-col 40)
(setq csound-orc-mode-sr 44100)
(setq csound-orc-mode-kr 2205)
(setq csound-orc-mode-ksmps 20)
(setq csound-orc-mode-nchnls 2)
;; customize some font colors for highlighting...
(custom-set-faces
'(font-lock-cs-decls-colour ((t (:bold t :foreground "White" :background "Blue"))) t)
'(font-lock-cs-arate-colour ((t (:foreground "Red" ))) t)
'(font-lock-cs-krate-colour ((t (:foreground "DarkGreen" ))) t)
'(font-lock-cs-irate-colour ((t (:foreground "BlueViolet" ))) t)
'(font-lock-cs-opcode-adi-colour ((t (:foreground "Aquamarine"))) t)
'(font-lock-reference-face ((((class color) (background light)) (:foreground "Yellow"))))
'(font-lock-string-face ((((class color) (background light)) (:foreground "Black" :background "Turquoise"))))
'(font-lock-cs-label-colour ((t (:underline t :foreground "Maroon"))) t)
'(font-lock-cs-equals-colour ((t (:bold t :foreground "magenta"))) t)
'(font-lock-cs-inst-colour ((t (:bold t :foreground "Black" :background "Gold"))) t)
'(font-lock-cs-comment-colour ((t (:foreground "Firebrick" :background "MediumAquamarine"))) t)
'(font-lock-variable-name-face ((((class color) (background light)) (:foreground "Goldenrod" :background "DarkSlateBlue"))))
'(font-lock-cs-funcs-colour ((t (:background "LightSteelBlue"))) t))
))
;; ...and sco mode
(setq csound-sco-mode-hook
'(lambda ()
(setq font-lock-maximum-decoration t)
(turn-on-font-lock)
(setq csound-sco-mode-do-write-file-hooks t)
(setq csound-sco-mode-build-new-buffer t)
(setq csound-sco-mode-address-string "[email protected]")
))
;; Csound MAKE-REGEXP command
(autoload 'make-regexp "make-regexp"
"Return a regexp to match a string item in STRINGS." t)
(autoload 'make-regexps "make-regexp"
"Return a regexp to REGEXPS." t)
;; enable upcase and downcase-region
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
;; html-helper-mode settings
(setq load-path (cons "c:/emacs/site-lisp" load-path))
(autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t)
(setq auto-mode-alist (cons '("\\.html$" . html-helper-mode) auto-mode-alist))
(autoload 'html-helper-load-hook "html-helper-plus.el" t)
;; timestamp
(setq html-helper-do-write-file-hooks nil)
;; prompting on
(setq tempo-interactive t)
;; indentation
(setq html-helper-never-indent nil)
;; always use expert menu
(setq html-helper-use-expert-menu t)
;; how to set the default dtd:
(setq html-helper-htmldtd-version "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n\t\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n")
;; set the default document skeleton
(setq html-helper-new-buffer-template
'(html-helper-htmldtd-version
"<html lang=\"en-US\" xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en-US\">\n<head>\n"
"<!--** Time-stamp: <> **-->\n"
"<title></title>\n"
"\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=us-ascii\" />"
"\n</head>\n"
"<body>\n<h1>"
p
"</h1>\n<div>\n<ul>\n<li>\n<a href=\"\" title=\"\"></a>\n</li>\n</ul>\n</div>\n</body>\n</html>\n"))
;; insert a document skeleton
(setq html-helper-build-new-buffer t)
;; set the format of the html timestamp
(setq html-helper-timestamp-start "<!-- hhmts start\n")
(setq html-helper-timestamp-end "hhmts end-->\n")
(custom-set-variables
;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
;; Your init file should contain only one such instance.
;; From an old installation of emacs. Not custom-set here.
'(indent-tabs-mode nil) ;use spaces instead of tabs when indenting
'(appt-display-mode-line t t)
'(auto-save-interval 300)
'(auto-save-timeout 30)
'(backward-delete-char-untabify-method nil)
'(case-fold-search t)
'(column-number-mode t)
'(current-language-environment "Latin-1")
'(default-input-method "latin-1-prefix")
'(delete-auto-save-files nil)
'(flyspell-mode-line-string " Fly" t)
'(global-font-lock-mode t nil (font-lock))
'(icomplete-mode t nil (icomplete))
'(indicate-empty-lines t)
'(minibuffer-prompt-properties (quote (read-only t point-entered minibuffer-avoid-prompt)))
'(mode-line-inverse-video t)
'(show-paren-mode t nil (paren))
'(transient-mark-mode t)
'(truncate-lines nil)
'(truncate-partial-width-windows nil)
'(undo-limit 200000)
'(undo-strong-limit 300000))
(custom-set-faces
;; custom-set-faces was added by Custom -- don't edit or cut/paste it!
;; Your init file should contain only one such instance.
'(mode-line ((((type x w32 mac) (class color)) (:background "black" :foreground "green" :box (:line-width -1 :color "blue" :style released-button))))))
;; Use Multi-Mode to
;; simulate a major mode for JSP
(require 'cl)
(autoload 'multi-mode
"multi-mode"
"Allowing multiple major modes in a buffer."
t)
(defun jsp-mode () (interactive)
(multi-mode 1
'html-helper-mode
'("<%--" indented-text-mode)
'("<%@" indented-text-mode)
'("<%=" html-helper-mode)
'("<%" java-mode)
'("%>" html-helper-mode)
;'("<script" javascript-generic-mode) ;sux0rz, using c-mode instead!
'("<script" c-mode)
'("</script" html-helper-mode)
'("<style" css-mode)
'("</style" html-helper-mode)))
(defun DHTML-helper-mode () (interactive)
(multi-mode 1
'html-helper-mode
;'("<script" javascript-generic-mode) ;sux0rz, using c-mode instead!
'("<script" c-mode)
'("</script" html-helper-mode)
'("<style" css-mode)
'("</style" html-helper-mode)))
(defun PHP-helper-mode () (interactive)
(multi-mode 1
'html-helper-mode
;; '("<?" c-mode)
'("<?" php-mode)
'("?>" html-helper-mode)
;'("<script" javascript-generic-mode) ;sux0rz, using c-mode instead!
'("<script" c-mode)
'("</script" html-helper-mode)
'("<style" css-mode)
'("</style" html-helper-mode)))
(setq auto-mode-alist
(cons '("\\.jsp\\'" . jsp-mode) auto-mode-alist))
(setq auto-mode-alist
(cons '("\\.jspf\\'" . jsp-mode) auto-mode-alist))
(setq auto-mode-alist
(cons '("\\.inc\\'" . jsp-mode) auto-mode-alist))
(setq auto-mode-alist
(cons '("\\.html\\'" . DHTML-helper-mode) auto-mode-alist))
(setq auto-mode-alist
(cons '("\\.htm\\'" . DHTML-helper-mode) auto-mode-alist))
(setq auto-mode-alist
(cons '("\\.php\\'" . PHP-helper-mode) auto-mode-alist))
(setq auto-mode-alist
(cons '("\\.phph\\'" . PHP-helper-mode) auto-mode-alist))
;; * 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:
(setq icon-title-format "%b")
;; Display or insert the current date and time
;; insert date)
;; Namespace: @
(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))))
;; Kill all the buffers except scratch
;; and those explicitly specified
;; Safe kill buffers
;; Ignore certain buffers
(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*"))
(kill-buffer buffer)))
(setq list (cdr list))))
(cd "~"))
;; Functions that change colors
;; Original code copied from
;; http://www.xanadb.com/archive/emacs/20021013
;; The cursor never blinked before, but when I set custom colors it does...
(blink-cursor-mode -1)
;;
(defun XPhantom()
"Sets the color scheme to something appropriate for a Windows NT/XP box."
(interactive "")
(setq default-frame-alist
'((foreground-color . "gray70")
(background-color . "black")))
(set-cursor-color "yellow")
(set-mouse-color "yellow")
(set-face-foreground 'modeline "magenta")
(set-face-background 'modeline "yellow")
(set-face-background 'region "yellow")
(set-face-background 'highlight "yellow")
(custom-set-faces
'(default ((t (:background "black" :foreground "chartreuse3" ))))
'(cursor ((t (:foreground "black" :background "yellow"))))
'(highlight ((t (:inverse-video t))))
'(region ((t (:inverse-video t))))
'(highlight ((t (:foreground "black" :background "yellow"))))
'(region ((t (:foreground "black" :background "yellow"))))
'(modeline ((t (:foreground "black" :background "dodgerblue1" :weight bold :box (:line-width -1 :color "firebrick" :style released-button)))))
'(font-lock-builtin-face ((t (:foreground "gray70"))))
'(font-lock-comment-face ((t (:italic t :foreground "forestgreen" ))))
'(font-lock-constant-face ((t (:bold t :foreground "steelblue"))))
'(font-lock-function-name-face ((t (:bold t ))))
'(font-lock-keyword-face ((t (:bold t :foreground "darkolivegreen"))))
'(margin-face ((t (:inverse-video t))))
'(font-lock-string-face ((t (:foreground "cadetblue1"))))
'(font-lock-type-face ((t (:bold t :foreground "cadetblue1"))))
'(font-lock-variable-name-face ((t (:foreground "dodgerblue1"))))
'(cperl-array-face ((t (:foreground "dodgerblue1" :background "gray18"))))
'(cperl-hash-face ((t (:foreground "dodgerblue1" :background "gray18"))))
'(html-tag-face ((t (:foreground "royalblue" :bold t))))
'(html-helper-bold-face ((t (:foreground "gray70" :bold t))))
'(show-paren-match-face ((t (:foreground "firebrick" :background "royalblue" :bold t))))
'(show-paren-mismatch-face ((t (:foreground "royalblue" :background "firebrick" :bold t))))))
;; Call the color-changing function
(XPhantom)
(put 'set-goal-column 'disabled nil)
(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 runcate-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 ("c:/dropbox/My Dropbox/journal/todo.org")))
'(org-default-notes-file "c:/dropbox/My 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" "c:/dropbox/My Dropbox/journal/todo.org" "Tasks")
(110 "* %u %?" "c:/dropbox/My Dropbox/journal/notes.org" "Notes")
(113 "* %u %?" "c:/dropbox/My Dropbox/journal/quotes.org" "Quotations")
(99 "* %u %?" "c:/dropbox/My Dropbox/journal/citations.org" "Citations")
(108 "* TODO Look up %?, seen in \n %u" "c:/dropbox/My Dropbox/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)
;; Ruby mode for GNU Emacs on XP and Vista
;; See http://sodonnell.wordpress.com/2007/06/21/emacs-ruby-foo/
;; loads ruby mode when a .rb file is opened.
(autoload 'ruby-mode "ruby-mode" "Major mode for editing ruby scripts." t)
(setq auto-mode-alist (cons '(".rb$" . ruby-mode) auto-mode-alist))
(setq auto-mode-alist (cons '(".rhtml$" . html-mode) auto-mode-alist))
(add-hook 'ruby-mode-hook
(lambda()
(add-hook 'local-write-file-hooks
'(lambda()
(save-excursion
(untabify (point-min) (point-max))
(delete-trailing-whitespace))))
(set (make-local-variable 'indent-tabs-mode) 'nil)
(set (make-local-variable 'tab-width) 2)
(imenu-add-to-menubar "IMENU")
(define-key ruby-mode-map "C-m" 'newline-and-indent) ;Not sure if this line is 100% right but it works!
(require 'ruby-electric)
(ruby-electric-mode t)))
;; 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
(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))
(setq indent-tabs-mode nil)
;; HAML conversion macros
;; "When the point is at the start of an attribute foo='bar' haml-ize it (or ruby-ize it, really) by changing that to :foo => 'bar'"
(fset 'arcane/haml-ize-html-attributes
[?: ?\C-s ?= left ? right ?> ? ?\C-s ?\" ?\C-s right left ?, right])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment