How to Start a Software Company 2.0

by Richard Rodger

       
 
Emacs Autocomplete Bliss

You known that IntelliSense rots your brain, right?

Well if you use Emacs, now you too can rot your brain, only better (everything is always better with Emacs).

This is the most treasured snippet from my .emacs file. All it does is store every word in all open files and when you hit tab, it autocompletes based on the text before the cursor. Sure, it doesn't show you the list of possible candidates, but all you ever need is a few tabs and you'll find what you want.

; auto completion
;;;;;;;;;;;;;;;;;
(require 'dabbrev)
(setq dabbrev-always-check-other-buffers t)
(setq dabbrev-abbrev-char-regexp "\\sw\\|\\s_")

(global-set-key "\C-i" 'my-tab)

(defun my-tab (&optional pre-arg)
  "If preceeding character is part of a word then dabbrev-expand,
else if right of non whitespace on line then tab-to-tab-stop or
indent-relative, else if last command was a tab or return then dedent
one step, else indent 'correctly'"
  (interactive "*P")
  (cond ((= (char-syntax (preceding-char)) ?w)
         (let ((case-fold-search t)) (dabbrev-expand pre-arg)))
        ((> (current-column) (current-indentation))
         (indent-relative))
        (t (indent-according-to-mode)))
  (setq this-command 'my-tab))

(add-hook 'html-mode-hook
          '(lambda () 
             (local-set-key "\C-i"     'my-tab)))
(add-hook 'sgml-mode-hook
          '(lambda () 
             (local-set-key "\C-i"     'my-tab)))
(add-hook 'perl-mode-hook
          '(lambda () 
             (local-set-key "\C-i"     'my-tab)))
(add-hook 'text-mode-hook
          '(lambda () 
             (local-set-key "\C-i"     'my-tab)))

; add more hooks here

The code isn't mine and I can't remember where I found it, but it has saved me countless hours of typing.

@ 05:56 PM GMT+00:00 [ comments [0] ]   email this   links to this

If you liked this entry, please consider bookmarking it &mdash Thanks!
Bookmark Emacs Autocomplete Bliss at del.icio.us Digg Emacs Autocomplete Bliss at Digg.com Bookmark Emacs Autocomplete Bliss at reddit.com Bookmark Emacs Autocomplete Bliss at YahooMyWeb Bookmark Emacs Autocomplete Bliss at Spurl.net Bookmark Emacs Autocomplete Bliss at Simpy.com Bookmark Polyphasic Mutants at NewsVine Blink this Emacs Autocomplete Bliss at blinklist.com Bookmark Emacs Autocomplete Bliss at Furl.net Fark Emacs Autocomplete Bliss at Fark.com

 
 
Trackback URL: http://www.richardrodger.com/roller/trackback/richard/Weblog/emacs_auto_complete
Comments:

Comments for this have been disabled. Please send me a mail if you want to comment and I will activate comments again.
 
YahooBloglines
NewsgatorMSN
Google Readerdel.icio.us FurlSubscribe with myFeedster
« December 2005 »
SunMonTueWedThuFriSat
    
3
5
10
11
13
17
18
24
25
26
27
28
29
30
31
       
Today

All | General | Java | Business | Fun | Perl | Rant | Ireland | Web
[This is a Roller site]
[Valid Atom 1.0] [Valid RSS]
Technology Blog Top Sites
Blogarama - The Blogs Directory

Blog Directory & Search engine

Blog Flux Directory
Irish Blogs
 View My Public Stats on MyBlogLog.com

Performancing
Enter your Email


Powered by FeedBlitz
Theme adapted from Sotto.
 
Ricebridge XML Manager
  • Convert XML to a table of data
  • Convert XML to CSV, and CSV to XML
  • High-speed, single-pass XPath
  • Memory-stable and fault-tolerant
  • Loads of documentation
  • Cut-and-paste code examples
  • Find a bug, get a gift cert
Ricebridge Java XML Manager Component


Ricebridge CSV Manager
  • Convert CSV to a table of data
  • Handle any type of delimited file
  • Memory-stable and fault-tolerant
  • Loads of documentation
  • Cut-and-paste code examples
  • Find a bug, get a gift cert
Ricebridge Java CSV Manager Component


Popular Posts

 Sign up for MyBlogLog.com
Alertra Website Monitoring Service
Get Chitika eMiniMalls
Solo Tees
BlogJet