251 lines
15 KiB
HTML
251 lines
15 KiB
HTML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
|
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<title>emacs-init.el</title>
|
|
<meta name="generator" content="emacs 24.2.1; htmlfontify 0.21" />
|
|
<style type="text/css"><!--
|
|
body { font-family: Inconsolata; font-stretch: normal; font-weight: 500; font-style: normal; color: #eeeeec; background: #1d282b; font-size: 11pt; text-decoration: none; }
|
|
span.default { font-family: Inconsolata; font-stretch: normal; font-weight: 500; font-style: normal; color: #eeeeec; background: #1d282b; font-size: 11pt; text-decoration: none; }
|
|
span.default a { font-family: Inconsolata; font-stretch: normal; font-weight: 500; font-style: normal; color: #eeeeec; background: #1d282b; font-size: 11pt; text-decoration: underline; }
|
|
span.doc { color: #888a85; font-family: Inconsolata; font-stretch: normal; font-weight: 500; font-style: normal; background: #1d282b; font-size: 11pt; text-decoration: none; }
|
|
span.doc a { color: #888a85; font-family: Inconsolata; font-stretch: normal; font-weight: 500; font-style: normal; background: #1d282b; font-size: 11pt; text-decoration: underline; }
|
|
span.function-name { color: #edd400; font-style: italic; font-weight: 700; font-family: Inconsolata; font-stretch: normal; background: #1d282b; font-size: 11pt; text-decoration: none; }
|
|
span.function-name a { color: #edd400; font-style: italic; font-weight: 700; font-family: Inconsolata; font-stretch: normal; background: #1d282b; font-size: 11pt; text-decoration: underline; }
|
|
span.variable-name { color: #eeeeec; font-family: Inconsolata; font-stretch: normal; font-weight: 500; font-style: normal; background: #1d282b; font-size: 11pt; text-decoration: none; }
|
|
span.variable-name a { color: #eeeeec; font-family: Inconsolata; font-stretch: normal; font-weight: 500; font-style: normal; background: #1d282b; font-size: 11pt; text-decoration: underline; }
|
|
span.constant { color: #8ae234; font-family: Inconsolata; font-stretch: normal; font-weight: 500; font-style: normal; background: #1d282b; font-size: 11pt; text-decoration: none; }
|
|
span.constant a { color: #8ae234; font-family: Inconsolata; font-stretch: normal; font-weight: 500; font-style: normal; background: #1d282b; font-size: 11pt; text-decoration: underline; }
|
|
span.keyword { color: #729fcf; font-weight: 700; font-family: Inconsolata; font-stretch: normal; font-style: normal; background: #1d282b; font-size: 11pt; text-decoration: none; }
|
|
span.keyword a { color: #729fcf; font-weight: 700; font-family: Inconsolata; font-stretch: normal; font-style: normal; background: #1d282b; font-size: 11pt; text-decoration: underline; }
|
|
span.string { color: #ad7fa8; font-style: italic; font-family: Inconsolata; font-stretch: normal; font-weight: 500; background: #1d282b; font-size: 11pt; text-decoration: none; }
|
|
span.string a { color: #ad7fa8; font-style: italic; font-family: Inconsolata; font-stretch: normal; font-weight: 500; background: #1d282b; font-size: 11pt; text-decoration: underline; }
|
|
span.comment { color: #888a85; font-family: Inconsolata; font-stretch: normal; font-weight: 500; font-style: normal; background: #1d282b; font-size: 11pt; text-decoration: none; }
|
|
span.comment a { color: #888a85; font-family: Inconsolata; font-stretch: normal; font-weight: 500; font-style: normal; background: #1d282b; font-size: 11pt; text-decoration: underline; }
|
|
span.comment-delimiter { color: #888a85; font-family: Inconsolata; font-stretch: normal; font-weight: 500; font-style: normal; background: #1d282b; font-size: 11pt; text-decoration: none; }
|
|
span.comment-delimiter a { color: #888a85; font-family: Inconsolata; font-stretch: normal; font-weight: 500; font-style: normal; background: #1d282b; font-size: 11pt; text-decoration: underline; }
|
|
--></style>
|
|
|
|
<script type="text/javascript"><!--
|
|
// this function is needed to work around
|
|
// a bug in IE related to element attributes
|
|
function hasClass(obj)
|
|
{
|
|
var result = false;
|
|
if (obj.getAttributeNode("class") != null)
|
|
{
|
|
result = obj.getAttributeNode("class").value;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
function stripe(id)
|
|
{
|
|
// the flag we'll use to keep track of
|
|
// whether the current row is odd or even
|
|
var even = false;
|
|
|
|
// if arguments are provided to specify the colors
|
|
// of the even & odd rows, then use the them;
|
|
// otherwise use the following defaults:
|
|
var evenColor = arguments[1] ? arguments[1] : "#fff";
|
|
var oddColor = arguments[2] ? arguments[2] : "#ddd";
|
|
|
|
// obtain a reference to the desired table
|
|
// if no such table exists, abort
|
|
var table = document.getElementById(id);
|
|
if (! table) { return; }
|
|
|
|
// by definition, tables can have more than one tbody
|
|
// element, so we'll have to get the list of child
|
|
// <tbody>s
|
|
var tbodies = table.getElementsByTagName("tbody");
|
|
|
|
// and iterate through them...
|
|
for (var h = 0; h < tbodies.length; h++)
|
|
{
|
|
// find all the <tr> elements...
|
|
var trs = tbodies[h].getElementsByTagName("tr");
|
|
|
|
// ... and iterate through them
|
|
for (var i = 0; i < trs.length; i++)
|
|
{
|
|
// avoid rows that have a class attribute
|
|
// or backgroundColor style
|
|
if (! hasClass(trs[i]) &&
|
|
! trs[i].style.backgroundColor)
|
|
{
|
|
// get all the cells in this row...
|
|
var tds = trs[i].getElementsByTagName("td");
|
|
|
|
// and iterate through them...
|
|
for (var j = 0; j < tds.length; j++)
|
|
{
|
|
var mytd = tds[j];
|
|
|
|
// avoid cells that have a class attribute
|
|
// or backgroundColor style
|
|
if (! hasClass(mytd) &&
|
|
! mytd.style.backgroundColor)
|
|
{
|
|
mytd.style.backgroundColor =
|
|
even ? evenColor : oddColor;
|
|
}
|
|
}
|
|
}
|
|
// flip from odd to even, or vice-versa
|
|
even = ! even;
|
|
}
|
|
}
|
|
}
|
|
|
|
function toggle_invis( name )
|
|
{
|
|
var filter =
|
|
{ acceptNode:
|
|
function( node )
|
|
{ var classname = node.id;
|
|
if( classname )
|
|
{ var classbase = classname.substr( 0, name.length );
|
|
if( classbase == name ) { return NodeFilter.FILTER_ACCEPT; } }
|
|
return NodeFilter.FILTER_SKIP; } };
|
|
var walker = document.createTreeWalker( document.body ,
|
|
NodeFilter.SHOW_ELEMENT ,
|
|
filter ,
|
|
false );
|
|
while( walker.nextNode() )
|
|
{
|
|
var e = walker.currentNode;
|
|
if( e.style.display == "none" ) { e.style.display = "inline"; }
|
|
else { e.style.display = "none"; }
|
|
}
|
|
}
|
|
--> </script>
|
|
</head>
|
|
<body onload="stripe('index'); return true;">
|
|
|
|
<pre><span class="comment-delimiter">;; </span><span class="comment">no splash screen
|
|
</span>(setq inhibit-splash-screen t)
|
|
|
|
<span class="comment-delimiter">;; </span><span class="comment">show matching parenthesis
|
|
</span>(show-paren-mode t)
|
|
|
|
<span class="comment-delimiter">;; </span><span class="comment">answer with y/n
|
|
</span>(fset 'yes-or-no-p 'y-or-n-p)
|
|
|
|
<span class="comment-delimiter">;; </span><span class="comment">stop blinking cursor
|
|
</span>(blink-cursor-mode 0)
|
|
|
|
<span class="comment-delimiter">;; </span><span class="comment">overwrite marked text
|
|
</span>(delete-selection-mode t)
|
|
|
|
<span class="comment-delimiter">;; </span><span class="comment">show column number in mode-line
|
|
</span>(column-number-mode t)
|
|
|
|
<span class="comment-delimiter">;; </span><span class="comment">needed to use things downloaded with the package manager
|
|
</span>(package-initialize)
|
|
|
|
<span class="comment-delimiter">;; </span><span class="comment">add mirrors for list-packages
|
|
</span>(setq package-archives '((<span class="string">"gnu"</span> . <span class="string">"http://elpa.gnu.org/packages/"</span>)
|
|
(<span class="string">"marmalade"</span> . <span class="string">"http://marmalade-repo.org/packages/"</span>)
|
|
(<span class="string">"melpa"</span> . <span class="string">"http://melpa.milkbox.net/packages/"</span>)))
|
|
|
|
<span class="comment-delimiter">;; </span><span class="comment">choose a color-theme
|
|
</span>(load-theme 'wombat t)
|
|
|
|
<span class="comment-delimiter">;; </span><span class="comment">get the default config for auto-complete (downloaded with
|
|
</span><span class="comment-delimiter">;; </span><span class="comment">package-manager)
|
|
</span>(<span class="keyword">require</span> '<span class="constant">auto-complete-config</span>)
|
|
|
|
<span class="comment-delimiter">;; </span><span class="comment">load the default config of auto-complete
|
|
</span>(ac-config-default)
|
|
|
|
<span class="comment-delimiter">;; </span><span class="comment">enable ido-mode, this changes the way files are selected in the
|
|
</span><span class="comment-delimiter">;; </span><span class="comment">minibuffer
|
|
</span>(ido-mode t)
|
|
|
|
<span class="comment-delimiter">;; </span><span class="comment">no menubar
|
|
</span>(menu-bar-mode 0)
|
|
|
|
<span class="comment-delimiter">;; </span><span class="comment">no toolbar either
|
|
</span>(tool-bar-mode 0)
|
|
|
|
<span class="comment-delimiter">;; </span><span class="comment">scrollbar? no
|
|
</span>(scroll-bar-mode 0)
|
|
|
|
<span class="comment-delimiter">;; </span><span class="comment">global-linum-mode shows line numbers in all buffers, exchange 0
|
|
</span><span class="comment-delimiter">;; </span><span class="comment">with 1 to enable this feature
|
|
</span>(global-linum-mode 0)
|
|
|
|
<span class="comment-delimiter">;; </span><span class="comment">kills the active buffer, not asking what buffer to kill.
|
|
</span>(global-set-key (kbd <span class="string">"C-x k"</span>) 'kill-this-buffer)
|
|
|
|
<span class="comment-delimiter">;; </span><span class="comment">adds all autosave-files (i.e #test.txt#, test.txt~) in one
|
|
</span><span class="comment-delimiter">;; </span><span class="comment">directory, avoid clutter in filesystem.
|
|
</span>(<span class="keyword">defvar</span> <span class="variable-name">emacs-autosave-directory</span> <span class="string">"~/.emacs.d/autosaves/"</span>)
|
|
(setq backup-directory-alist
|
|
`((<span class="string">".*"</span> . ,emacs-autosave-directory))
|
|
auto-save-file-name-transforms
|
|
`((<span class="string">".*"</span> ,emacs-autosave-directory t)))
|
|
|
|
<span class="comment-delimiter">;; </span><span class="comment">defining a function that sets more accessible keyboard-bindings to
|
|
</span><span class="comment-delimiter">;; </span><span class="comment">hiding/showing code-blocs
|
|
</span>(<span class="keyword">defun</span> <span class="function-name">hideshow-on</span> ()
|
|
(local-set-key (kbd <span class="string">"C-c <right>"</span>) 'hs-show-block)
|
|
(local-set-key (kbd <span class="string">"C-c C-<right>"</span>) 'hs-show-block)
|
|
(local-set-key (kbd <span class="string">"C-c <left>"</span>) 'hs-hide-block)
|
|
(local-set-key (kbd <span class="string">"C-c C-<left>"</span>) 'hs-hide-block)
|
|
(local-set-key (kbd <span class="string">"C-c <up>"</span>) 'hs-hide-all)
|
|
(local-set-key (kbd <span class="string">"C-c C-<up>"</span>) 'hs-hide-all)
|
|
(local-set-key (kbd <span class="string">"C-c <down>"</span>) 'hs-show-all)
|
|
(local-set-key (kbd <span class="string">"C-c C-<down>"</span>) 'hs-show-all)
|
|
(hs-minor-mode t))
|
|
|
|
<span class="comment-delimiter">;; </span><span class="comment">now we have to tell emacs where to load these functions. Showing
|
|
</span><span class="comment-delimiter">;; </span><span class="comment">and hiding codeblocks could be useful for all c-like programming
|
|
</span><span class="comment-delimiter">;; </span><span class="comment">(java is c-like) languages, so we add it to the c-mode-common-hook.
|
|
</span>(add-hook 'c-mode-common-hook 'hideshow-on)
|
|
|
|
<span class="comment-delimiter">;; </span><span class="comment">adding shortcuts to java-mode, writing the shortcut folowed by a
|
|
</span><span class="comment-delimiter">;; </span><span class="comment">non-word character will cause an expansion.
|
|
</span>(<span class="keyword">defun</span> <span class="function-name">java-shortcuts</span> ()
|
|
(define-abbrev-table 'java-mode-abbrev-table
|
|
'((<span class="string">"psv"</span> <span class="string">"public static void main(String[] args) {"</span> nil 0)
|
|
(<span class="string">"sop"</span> <span class="string">"System.out.printf"</span> nil 0)
|
|
(<span class="string">"sopl"</span> <span class="string">"System.out.println"</span> nil 0)))
|
|
(abbrev-mode t))
|
|
|
|
<span class="comment-delimiter">;; </span><span class="comment">the shortcuts are only useful in java-mode so we'll load them to
|
|
</span><span class="comment-delimiter">;; </span><span class="comment">java-mode-hook.
|
|
</span>(add-hook 'java-mode-hook 'java-shortcuts)
|
|
|
|
<span class="comment-delimiter">;; </span><span class="comment">defining a function that guesses a compile command and bindes the
|
|
</span><span class="comment-delimiter">;; </span><span class="comment">compile-function to C-c C-c
|
|
</span>(<span class="keyword">defun</span> <span class="function-name">java-setup</span> ()
|
|
(set (make-variable-buffer-local 'compile-command)
|
|
(concat <span class="string">"javac "</span> (buffer-name)))
|
|
(local-set-key (kbd <span class="string">"C-c C-c"</span>) 'compile))
|
|
|
|
<span class="comment-delimiter">;; </span><span class="comment">this is a java-spesific function, so we only load it when entering
|
|
</span><span class="comment-delimiter">;; </span><span class="comment">java-mode
|
|
</span>(add-hook 'java-mode-hook 'java-setup)
|
|
|
|
<span class="comment-delimiter">;; </span><span class="comment">defining a function that sets the right indentation to the marked
|
|
</span><span class="comment-delimiter">;; </span><span class="comment">text, or the entire buffer if no text is selected.
|
|
</span>(<span class="keyword">defun</span> <span class="function-name">tidy</span> ()
|
|
<span class="doc">"Ident, untabify and unwhitespacify current buffer, or region if active."</span>
|
|
(interactive)
|
|
(<span class="keyword">let</span> ((beg (<span class="keyword">if</span> (region-active-p) (region-beginning) (point-min)))
|
|
(end (<span class="keyword">if</span> (region-active-p) (region-end) (point-max))))
|
|
(whitespace-cleanup)
|
|
(indent-region beg end nil)
|
|
(untabify beg end)))
|
|
|
|
<span class="comment-delimiter">;; </span><span class="comment">bindes the tidy-function to C-TAB
|
|
</span>(global-set-key (kbd <span class="string">"<C-tab>"</span>) 'tidy)
|
|
</pre>
|
|
|
|
</body>
|
|
</html>
|