<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Fred's Blog &#187; customisations</title>
	<atom:link href="http://www.valton.com.au/archives/tag/customisations/feed" rel="self" type="application/rss+xml" />
	<link>http://www.valton.com.au</link>
	<description>techno-ramblings &#38; miscellanea</description>
	<lastBuildDate>Sat, 05 Dec 2009 00:22:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Customising Emacs</title>
		<link>http://www.valton.com.au/archives/3</link>
		<comments>http://www.valton.com.au/archives/3#comments</comments>
		<pubDate>Sat, 01 Dec 2007 12:15:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[customisations]]></category>
		<category><![CDATA[editors]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[ide]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://localhost/?p=3</guid>
		<description><![CDATA[Here&#8217;s a recent configuration geared towards Emacs in console mode (emacs -nw / emacs-nox): ;;;;;;;;;;;;;;;;; Load Paths ;;;;;;;;;;;;;;;;;;; (setq load-path (cons (expand-file-name &#8220;~/.emacs-clisp/&#8221;) load-path)) ;;;;;;;;;;;;;;;;; Require Modes ;;;;;;;;;;;;;;;;;;; ;;&#8211;automatically load packages installed through portage (require &#8216;site-gentoo nil t) ;;&#8211;mutt email editing mode for emacs (require &#8216;mutt) ;;&#8211;adds redo to emacs cf. undo &#8211; bound to [...]]]></description>
			<content:encoded><![CDATA[<p class="content">Here&#8217;s a recent configuration geared towards Emacs in console mode (emacs -nw / emacs-nox):</p>
<p><span id="more-3"></span></p>
<p>;;;;;;;;;;;;;;;;; Load Paths ;;;;;;;;;;;;;;;;;;;<br />
(setq load-path (cons (expand-file-name &#8220;~/.emacs-clisp/&#8221;) load-path))</p>
<p>;;;;;;;;;;;;;;;;; Require Modes ;;;;;;;;;;;;;;;;;;;<br />
;;&#8211;automatically load packages installed through portage<br />
(require &#8216;site-gentoo nil t)<br />
;;&#8211;mutt email editing mode for emacs<br />
(require &#8216;mutt)<br />
;;&#8211;adds redo to emacs cf. undo &#8211; bound to C-_<br />
(require &#8216;redo)<br />
;;&#8211;convert emacs faces to html<br />
(require &#8216;htmlize)<br />
;; required for saving session &#8211; cursor position in file<br />
(require &#8216;session)<br />
(add-hook &#8216;after-init-hook &#8216;session-initialize)</p>
<p>;;&#8211;load editing modes &#8211; acutally loaded by site-gentoo above<br />
;(require &#8216;ruby-mode)<br />
;(require &#8216;python-mode)<br />
;(require &#8216;php-mode)<br />
;(require &#8216;nxml-mode)<br />
;(require &#8216;css-mode)</p>
<p>;;&#8211;show contents of kill ring<br />
(require &#8216;browse-kill-ring)<br />
;;&#8211;text stats on current buffer &#8211; bound to C-ct<br />
(require &#8216;textstats)<br />
;;&#8211;highlight active line &#8211; use with highline-on<br />
;(require &#8216;highline)<br />
;;&#8211;highlight blank spaces &#8211; use with blank-mode-on<br />
;(require &#8216;blank-mode)</p>
<p>;;&#8211;muttrc<br />
(autoload &#8216;muttrc-mode &#8220;~/.emacs-clisp/muttrc-mode.elc&#8221; &#8220;muttrc-mode&#8221; t &#8216;nil)<br />
;;&#8211;html-helper-mode<br />
(autoload &#8216;html-helper-mode &#8220;html-helper-mode&#8221; &#8220;HTML major mode.&#8221; t &#8216;nil)</p>
<p>;;;;;;;;;;;;;;;;; Customisations  ;;;;;;;;;;;;;;;;;;;<br />
;;&#8211;turn on font highlighting<br />
(global-font-lock-mode t)<br />
;;&#8211;remove the startup message<br />
(setq  inhibit-startup-message t)<br />
;;&#8211;highlight selection<br />
(transient-mark-mode t)<br />
;;&#8211;highlight matching parenthesis<br />
(show-paren-mode t)<br />
;;&#8211;emulates PC delete, backspace, home, end &#8230;<br />
(pc-bindings-mode)<br />
;;&#8211;emulates PC cursor keys, next, prior, home and end keys<br />
;;(pc-selection-mode)<br />
;;&#8211;make searches case-INsensitive<br />
(setq-default case-fold-search t)<br />
;;&#8211;do not use tabs for indentation<br />
(setq-default indent-tabs-mode nil)<br />
;;&#8211;number of spaces for tab interval<br />
(setq tab-interval 2)<br />
;;&#8211;don&#8217;t automatically add new lines at end of a buffer<br />
(setq next-line-add-newlines nil)<br />
;;&#8211;make sure file ends with NEWLINE<br />
(setq require-final-newline t)<br />
;;&#8211;return to same line on a scroll back<br />
(setq scroll-preserve-screen-position t)<br />
;;&#8211;highlight search and replace matches<br />
(setq search-highlight t)<br />
;;&#8211;highlight words during query replacement<br />
(setq query-replace-highlight t)<br />
;;&#8211;turn on the column numbering in the minibuffer<br />
(setq column-number-mode t)<br />
;;&#8211;turn on the line numbering in the minibuffer<br />
(setq line-number-mode t)<br />
;;&#8211;non-nil means replace should preserve case<br />
(setq case-replace t)<br />
;;&#8211;visual bell<br />
(setq visible-bell t)<br />
;;&#8211;maximum number of entries in the mark ring<br />
(setq mark-ring-max 32)<br />
;;&#8211;turn on line wrapping in text mode<br />
(add-hook &#8216;text-mode-hook &#8216;turn-on-auto-fill)<br />
;;&#8211;turn on flyspell in text &amp; LaTeX modes<br />
(add-hook &#8216;text-mode-hook &#8216;flyspell-mode)<br />
(add-hook &#8216;LaTeX-mode-hook &#8216;flyspell-mode)<br />
;;&#8211;the column beyond which words wrap<br />
(setq default-fill-column 72)<br />
;;&#8211;scroll scroll max lines<br />
(setq scroll-step 1)<br />
;;&#8211;automatic scroll lines<br />
(setq scroll-conservatively 1)<br />
;;&#8211;show line numbers even in very big files<br />
(setq line-number-display-limit 10000000)<br />
;;&#8211;set high garbage collection threshold<br />
(setq gc-cons-threshold 5000000)<br />
;;&#8211;set maximum log size<br />
(setq message-log-max 3000)<br />
;;&#8211;history elements never deleted<br />
(setq history-length t)<br />
;;&#8211;maximum length to which the kill ring can grow &#8211; def. 30<br />
(setq kill-ring-max 200)<br />
;;&#8211;full name<br />
(setq user-full-name &#8220;Firstname Lastname&#8221;)<br />
;;&#8211;email address<br />
(setq user-mail-address &#8220;your@email.com&#8221;)<br />
;;&#8211;make all &#8220;yes or no&#8221; prompts show &#8220;y or n&#8221; instead<br />
(fset &#8216;yes-or-no-p &#8216;y-or-n-p)<br />
;;&#8211;set aspell as default spell-checker<br />
(setq-default ispell-program-name &#8220;aspell&#8221;)<br />
;;&#8211;ispell settings<br />
(autoload &#8216;ispell-word &#8220;ispell&#8221; &#8220;Check the spelling of word in buffer.&#8221; &#8216;t)<br />
(autoload &#8216;ispell-region &#8220;ispell&#8221; &#8220;Check the spelling of region.&#8221; &#8216;t)<br />
(autoload &#8216;ispell-buffer &#8220;ispell&#8221; &#8220;Check the spelling of buffer.&#8221; &#8216;t)<br />
(setq ispell-dictionary &#8220;british&#8221; ispell-skip-sgml t)<br />
;;&#8211;flyspell settings<br />
(autoload &#8216;flyspell-mode &#8220;flyspell&#8221; &#8220;On-the-fly spelling checking&#8221; t)<br />
(setq flyspell-default-dictionary &#8220;british&#8221;)<br />
;;&#8211;add flyspell to mail-mode<br />
(defun my-mail-mode-hook () (auto-fill-mode t))<br />
(add-hook &#8216;mail-mode-hook &#8216;my-mail-mode-hook)</p>
<p>;;;;;;;;;;;;;;;;; Mode Hooks ;;;;;;;;;;;;;;;;;;;<br />
(setq auto-mode-alist<br />
(append<br />
&#8216;(<br />
(&#8220;\\.txt$\\|\\.text$\\|\\.doc$&#8221;             . text-mode)<br />
(&#8220;\\.xml$\\|\\.xsl$\\|\\.rng$\\|\\.xhtml$&#8221;  . nxml-mode)<br />
(&#8220;\\.html$\\|\\.ohtml$\\|\\.phtml&#8221;          . html-helper-mode)<br />
(&#8220;\\.htm$\\|\\.asp$&#8221;                        . html-helper-mode)<br />
(&#8220;\\.php3$\\|\\.php4|\\.php$$&#8221;              . php-mode)<br />
(&#8220;\\.css\\&#8217;&#8221;                                . css-mode)<br />
(&#8220;\\.java$&#8221;                                 . java-mode)<br />
(&#8220;\\.perl$\\|\\.plx$\\|\\.pl$&#8221;              . cperl-mode)<br />
(&#8220;\\.py$&#8221;                                   . python-mode)<br />
(&#8220;\\.rb$&#8221;                                   . ruby-mode)<br />
(&#8220;^\/tmp\/mutt&#8221;                             . mail-mode)<br />
(&#8220;\\.muttrc&#8221;                                . muttrc-mode)<br />
(&#8220;\\.sh$|\\.zsh$|\\.bash$&#8221;                  . shell-script-mode)<br />
(&#8220;\\.xinitrc|\\.bashrc|\\.z?profile&#8221;        . sh-mode)<br />
) auto-mode-alist))</p>
<p>;;;;;;;;;;;;;;;;; Key Bindings ;;;;;;;;;;;;;;;;;;;<br />
;;&#8211;wrap text<br />
(global-set-key [f2]                &#8216;fill-paragraph)<br />
(global-set-key [(control f2)]      &#8216;fill-region)<br />
(global-set-key [f27]               &#8216;fill-region)<br />
;;&#8211;comment region<br />
(global-set-key [f4]                &#8216;ewd-comment-region)<br />
(global-set-key [(control f4)]      &#8216;ewd-uncomment-region)<br />
(global-set-key [f29]               &#8216;ewd-uncomment-region)<br />
;;&#8211;prepend text to region<br />
(global-set-key [f5]                &#8216;ewd-prepend)<br />
(global-set-key [(control f5)]      &#8216;ewd-unprepend)<br />
(global-set-key [f30]               &#8216;ewd-unprepend)<br />
;;&#8211;Ispell<br />
(global-set-key [f7]                &#8216;ispell-word)<br />
(global-set-key [(control f7)]      &#8216;ispell-buffer)<br />
(global-set-key [f32]               &#8216;ispell-buffer)</p>
<p>;;&#8211;browse kill ring<br />
(global-set-key &#8220;\C-xy&#8221;             &#8216;browse-kill-ring)<br />
;;&#8211;go to specific line in current buffer<br />
(global-set-key &#8220;\C-cg&#8221;             &#8216;goto-line)<br />
;;&#8211;go to specific line in current buffer<br />
(global-set-key &#8220;\C-ch&#8221;             &#8216;goto-column)<br />
;;&#8211;eat space at point up to non-space<br />
(global-set-key &#8220;\C-ce&#8221;             &#8216;fixup-whitespace)<br />
;;&#8211;display text stats for current buffer<br />
(global-set-key &#8220;\C-ct&#8221;             &#8216;textstats)</p>
<p>;;;;;;;;;;;;;;;;; Misc Functions ;;;;;;;;;;;;;;;;;;;<br />
;;&#8211;replace all ^M characters in buffer<br />
(defun fixm ()<br />
&#8220;Delete ^M from buffer.&#8221;<br />
(interactive)<br />
;;&#8211;Remember where we were<br />
(let ((old-point (point)))<br />
;;&#8211;Move to top<br />
(set-window-point (get-buffer-window (current-buffer)) 0)<br />
;;&#8211;Replace ^M&#8217;s<br />
(while (search-forward &#8220;\C-m&#8221; nil t)<br />
;; (replace-match &#8220;\n&#8221; nil t)) replace with new lines<br />
(replace-match &#8220;&#8221; nil t))<br />
;;&#8211;Move back to the old point<br />
(set-window-point (get-buffer-window (current-buffer)) old-point)))</p>
<p>;;&#8211;convert from DOS &gt; UNIX<br />
(defun dos-unix ()<br />
(interactive)<br />
(goto-char (point-min))<br />
(while (search-forward &#8220;\r&#8221; nil t) (replace-match &#8220;&#8221;)))</p>
<p>;;&#8211;convert from UNIX &gt; DOS<br />
(defun unix-dos ()<br />
(interactive)<br />
(goto-char (point-min))<br />
(while (search-forward &#8220;\n&#8221; nil t) (replace-match &#8220;\r\n&#8221;)))</p>
<p>;;&#8211;add a string in front of all lines in the region **<br />
(defun ewd-prepend (start end s)<br />
&#8220;Add a string in front of all lines in the region.&#8221;<br />
(interactive &#8220;*r\nMEnter a string: &#8220;)<br />
(save-excursion<br />
(save-restriction<br />
(narrow-to-region<br />
(progn (goto-char start) (beginning-of-line) (point))<br />
(progn (goto-char end) (end-of-line) (point)))<br />
(goto-char (point-min))<br />
(beginning-of-line)<br />
(while (not (eobp))<br />
(insert s)<br />
(forward-line 1)))))</p>
<p>;;&#8211;remove a string in front of all lines in the region **<br />
(defun ewd-unprepend (start end s)<br />
&#8220;Remove a string from the front of all lines in the region.&#8221;<br />
(interactive &#8220;*r\nMEnter a string: &#8220;)<br />
(save-excursion<br />
(save-restriction<br />
(narrow-to-region<br />
(progn (goto-char start) (beginning-of-line) (point))<br />
(progn (goto-char end) (end-of-line) (point)))<br />
(goto-char (point-min))<br />
(while (not (eobp))<br />
(if (looking-at (regexp-quote s))<br />
(delete-region (match-beginning 0) (match-end 0)))<br />
(forward-line 1)))))</p>
<p>;;&#8211;add a comment character in front of all lines in the region **<br />
(defun ewd-comment-region (start end)<br />
&#8220;Add one comment character in front of all lines in the region.&#8221;<br />
(interactive &#8220;*r&#8221;)<br />
(or comment-start (setq comment-start (read-input &#8220;Comment char?: &#8220;)))<br />
(ewd-prepend start end comment-start))</p>
<p>;;&#8211;remove a comment character from in front of all lines in the region **<br />
(defun ewd-uncomment-region (start end)<br />
&#8220;Remove one comment character from in front of all lines in the region.&#8221;<br />
(interactive &#8220;*r&#8221;)<br />
(or comment-start (setq comment-start (read-input &#8220;Comment char?: &#8220;)))<br />
(ewd-unprepend start end comment-start))</p>
<p>This configuration relies on the following modes:</p>
<p><em>muttrc-mode<br />
htmlize<br />
redo<br />
session<br />
highline<br />
browse-kill-ring<br />
textstats<br />
ruby-mode<br />
python-mode<br />
nxml-mode<br />
html-helper-mode<br />
css-mode<br />
php-mode<br />
java-mode<br />
cperl-mode<br />
python-mode<br />
ruby-mode</em></p>
<p>Most of these should be included with your favourite Linux distribution &#8211; in my case they are loaded using Gentoo&#8217;s site-gentoo mode</p>
<p>** Credit to  Elijah Daniel for the ewd-* functions.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.valton.com.au/archives/3/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
