summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2010-01-13 06:25:15 +0100
committerAlexander Sulfrian <alexander@sulfrian.net>2010-01-13 06:25:15 +0100
commitd573b7413e267aae0c32e083cec45d583ccf0562 (patch)
tree21210212934a70bdb84ebe2f6ca8fa7a0e6203d7
parentf19dd70ece015509d52d0e9a7c113ccccad96e0e (diff)
downloaddotfiles-d573b7413e267aae0c32e083cec45d583ccf0562.tar.gz
dotfiles-d573b7413e267aae0c32e083cec45d583ccf0562.tar.xz
dotfiles-d573b7413e267aae0c32e083cec45d583ccf0562.zip
heavy update of emacs configs
Diffstat (limited to '')
-rw-r--r--emacs155
-rw-r--r--emacs.d/lisp/auto-complete/auto-complete-etags.el60
-rw-r--r--emacs.d/lisp/auto-complete/auto-complete.el1138
-rw-r--r--emacs.d/lisp/cursor-chg.el348
-rw-r--r--emacs.d/lisp/delphi-mode-ench.el8
-rw-r--r--emacs.d/lisp/etags-table.el157
-rw-r--r--emacs.d/snippets/delphi-mode/constructor, destructor.yasnippet2
-rw-r--r--emacs.d/snippets/delphi-mode/dbg.yasnippet6
-rw-r--r--emacs.d/snippets/delphi-mode/func-prototype.yasnippet4
-rw-r--r--emacs.d/snippets/delphi-mode/func.yasnippet2
-rw-r--r--emacs.d/snippets/delphi-mode/procedure-prototype.yasnippet4
-rw-r--r--emacs.d/snippets/delphi-mode/procedure.yasnippet2
-rw-r--r--emacs.d/templates/TEMPLATE.hpp.tpl32
-rwxr-xr-xemacs.d/update-etags18
-rw-r--r--emacs.elcbin18211 -> 20080 bytes
15 files changed, 1877 insertions, 59 deletions
diff --git a/emacs b/emacs
index eb5d464..d1dc83b 100644
--- a/emacs
+++ b/emacs
@@ -5,6 +5,8 @@
;; If there is more than one, they won't work right.
'(Buffer-menu-use-frame-buffer-list nil)
'(abbrev-mode t)
+ '(ac-dwim t)
+ '(ac-modes (quote (emacs-lisp-mode lisp-interaction-mode c-mode cc-mode c++-mode java-mode perl-mode cperl-mode python-mode ruby-mode ecmascript-mode javascript-mode js2-mode php-mode css-mode makefile-mode sh-mode fortran-mode f90-mode ada-mode xml-mode sgml-mode delphi-mode)))
'(all-christian-calendar-holidays t)
'(auto-compression-mode t nil (jka-compr))
'(auto-insert-mode t)
@@ -24,6 +26,8 @@
'(column-number-mode t)
'(compilation-skip-threshold 2)
'(confirm-kill-emacs (quote y-or-n-p))
+ '(curchg-default-cursor-color "white")
+ '(curchg-overwrite/read-only-cursor-type (quote hollow))
'(current-language-environment "English")
'(delphi-case-label-indent 2)
'(delphi-indent-level 2)
@@ -51,11 +55,19 @@
'(ecb-tag-display-function (quote ((default . ecb--semantic-format-tag-uml-prototype))))
'(ecb-tip-of-the-day nil)
'(ecb-use-speedbar-instead-native-tree-buffer nil)
+ '(etags-table-search-up-depth 10)
'(fill-individual-varying-indent t)
+ '(flyspell-default-dictionary "english")
+ '(flyspell-delay 1)
+ '(flyspell-duplicate-distance -1)
+ '(flyspell-issue-message-flag nil)
+ '(flyspell-mark-duplications-flag nil)
+ '(flyspell-use-meta-tab t)
'(focus-follows-mouse t)
'(font-lock-support-mode (quote jit-lock-mode))
'(frame-background-mode nil)
'(fringe-mode nil nil (fringe))
+ '(global-auto-complete-mode t)
'(global-font-lock-mode t nil (font-lock))
'(global-hl-line-mode t nil (hl-line))
'(gnus-audio-au-player "/usr/bin/aplay")
@@ -69,6 +81,10 @@
'(inhibit-eol-conversion nil)
'(inhibit-startup-screen t)
'(inverse-video nil)
+ '(ispell-extra-args nil)
+ '(ispell-program-name "/usr/bin/ispell")
+ '(ispell-silently-savep t)
+ '(ispell-use-framepop-p t)
'(jde-run-option-application-args (quote ("10")))
'(jit-lock-chunk-size 1024)
'(jit-lock-context-time 0.1)
@@ -93,9 +109,16 @@
'(savehist-mode t nil (savehist))
'(scalable-fonts-allowed t)
'(scroll-bar-mode (quote right))
+ '(scroll-conservatively 0)
+ '(scroll-down-aggressively nil)
+ '(scroll-margin 0)
+ '(scroll-preserve-screen-position t)
+ '(scroll-step 0)
+ '(scroll-up-aggressively nil)
'(server-mode t)
'(show-trailing-whitespace t)
'(sieve-manage-default-user "alexander@sulfrian.net")
+ '(smooth-scroll-margin 2)
'(speedbar-directory-button-trim-method (quote trim))
'(speedbar-frame-parameters (quote ((minibuffer) (width . 30) (height . 60) (border-width . 0) (menu-bar-lines . 0) (tool-bar-lines . 0) (unsplittable . t) (left-fringe . 0))))
'(speedbar-frame-plist (quote (minibuffer nil width 30 height 60 border-width 0 internal-border-width 0 unsplittable t default-toolbar-visible-p nil has-modeline-p nil menubar-visible-p nil default-gutter-visible-p nil)))
@@ -205,9 +228,6 @@
(setq fill-column 72)
(setq semanticdb-default-save-directory "~/.emacs.d/semantic")
-(setq ispell-extra-args '("-Tlatin15"
- "-d" "/usr/lib/ispell/german"
- "-w" "äöüÄÖÜß"))
(setq locale-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
@@ -216,7 +236,6 @@
(prefer-coding-system 'utf-8)
; load-path anpassen
-(setq load-path (cons "/usr/share/maxima/5.9.0/emacs" load-path))
(let* ((my-lisp-dir "~/.emacs.d/lisp")
(default-directory my-lisp-dir)
(orig-load-path load-path))
@@ -224,21 +243,10 @@
(normal-top-level-add-subdirs-to-load-path)
(nconc load-path orig-load-path))
-
-(autoload 'maxima-mode "maxima" "Maxima mode" t)
-(autoload 'maxima "maxima" "Maxima interactive" t)
-(setq auto-mode-alist (cons '("\.max" . maxima-mode) auto-mode-alist))
-(autoload 'emaxima-mode "emaxima" "EMaxima" t)
-(add-hook 'emaxima-mode-hook 'emaxima-mark-file-as-emaxima)
-
(setq auto-mode-alist (cons '("README" . text-mode) auto-mode-alist))
-(setq auto-mode-alist (cons '("\\.pas" . delphi-mode) auto-mode-alist))
(setq compilation-scroll-output t)
-(require 'compile)
-(pushnew '("^\\([-a-zA-Z0-9\\.\\/_~]+\\)(\\([0-9]+\\),\\([0-9]+\\))\s\\([Ff]atal:\\|[Nn]ote:\\|[Ww]arning:\\|[Ee]rror:\\)\s\\(.*$\\)" 1 2 3)
- compilation-error-regexp-alist)
-
+; css-mode
(setq cssm-indent-level 4)
(setq cssm-newline-before-closing-bracket t)
(setq cssm-indent-function #'cssm-c-style-indenter)
@@ -277,37 +285,68 @@
(c-set-style "linux") ; set indentation style
))
-(global-set-key [C-return] 'dabbrev-expand)
-(define-key esc-map [C-return] 'dabbrev-completion)
+(global-set-key [C-return] 'dabbrev-expand)
+(define-key esc-map [C-return] 'dabbrev-completion)
(global-set-key [f12] 'indent-region)
-; Ctrl(+Shift)+Tab to (un)indent a line with a full tab
-(defun indent-region-with-tab ()
- (interactive)
- (save-excursion
- (if (< (point) (mark)) (exchange-point-and-mark))
- (let ((save-mark (mark)))
- (if (= (point) (line-beginning-position)) (previous-line 1))
- (goto-char (line-beginning-position))
- (while (>= (point) save-mark)
- (goto-char (line-beginning-position))
- (insert "\t")
- (previous-line 1)))))
-(global-set-key [M-tab] 'indent-region-with-tab)
-
-(defun unindent-region-with-tab ()
+;; Enable Doxygen syntax highlighting for C and C++
+(require 'doxymacs)
+(add-hook 'font-lock-mode-hook
+ '(lambda ()
+ (if (or (eq major-mode 'c-mode) (eq major-mode 'c++-mode))
+ (doxymacs-font-lock))))
+
+;; flyspell
+(add-hook 'c-mode-hook 'flyspell-prog-mode)
+(add-hook 'sh-mode-hook 'flyspell-prog-mode)
+(add-hook 'c++-mode-hook 'flyspell-prog-mode)
+(add-hook 'ruby-mode-hook 'flyspell-prog-mode)
+(add-hook 'cperl-mode-hook 'flyspell-prog-mode)
+(add-hook 'python-mode-hook 'flyspell-prog-mode)
+(add-hook 'autoconf-mode-hook 'flyspell-prog-mode)
+(add-hook 'autotest-mode-hook 'flyspell-prog-mode)
+(add-hook 'makefile-mode-hook 'flyspell-prog-mode)
+(add-hook 'emacs-lisp-mode-hook 'flyspell-prog-mode)
+
+(add-hook 'tex-mode-hook (function (lambda () (setq ispell-parser 'tex))))
+(add-hook 'texinfo-mode
+ '(lambda () (setq flyspell-generic-check-word-p
+ 'texinfo-mode-flyspell-verify)))
+
+(add-hook 'text-mode-hook (lambda () (flyspell-mode 1)))
+(add-hook 'change-log-mode-hook (lambda () (flyspell-mode 1)))
+
+(add-hook 'flyspell-mode-hook 'flyspell-buffer)
+
+; ignore all #include stings
+(add-hook 'flyspell-incorrect-hook
+ (lambda (left right undef)
+ (save-excursion
+ (goto-char left)
+ (beginning-of-line)
+ (if (looking-at "#include")
+ 't
+ 'nil)
+ )))
+
+; change dictionary
+(defun switch-dictionary()
(interactive)
- (save-excursion
- (if (< (point) (mark)) (exchange-point-and-mark))
- (let ((save-mark (mark)))
- (if (= (point) (line-beginning-position)) (previous-line 1))
- (goto-char (line-beginning-position))
- (while (>= (point) save-mark)
- (goto-char (line-beginning-position))
- (if (= (string-to-char "\t") (char-after (point))) (delete-char 1))
- (previous-line 1)))))
-(global-set-key [M-S-iso-lefttab] 'unindent-region-with-tab)
+ (let* ((dic ispell-current-dictionary)
+ (change (if (string= dic "german") "english" "german")))
+ (ispell-change-dictionary change)
+ (message "Dictionary switched from %s to %s" dic change)
+ (if flyspell-mode (save-excursion (flyspell-buffer)))))
+(global-set-key (kbd "<f8>") 'switch-dictionary)
+
+; update flyspell after changing dictionary
+(defadvice ispell (after advice)
+ (flyspell-buffer))
+(ad-activate 'ispell t)
+(defadvice ispell-word (after advice)
+ (flyspell-buffer))
+(ad-activate 'ispell-word t)
; byte-compile .emacs
(defun autocompile nil
@@ -328,7 +367,7 @@
(setq-default save-place t)
(require 'saveplace)
-; clever autocomplete mode
+; clever auto complete mode
(require 'ido)
(ido-mode t)
(setq
@@ -340,19 +379,19 @@
ido-max-prospects 6
ido-confirm-unique-completion t)
-; servermode (to edit files with emacsclient)
+; server mode (to edit files with emacsclient)
(server-start)
; emacs code browser
(ecb-activate)
-; smex
+;; smex
(setq smex-save-file "~/.emacs.d/smex.save")
(require 'smex)
(smex-initialize)
(global-set-key (kbd "M-X") 'smex)
-; snippets
+;; snippets
(require 'yasnippet)
(yas/initialize)
(yas/load-directory "~/.emacs.d/snippets")
@@ -402,21 +441,35 @@
(load "rudel-loaddefs.el")
-; magit
+;; magit
(require 'magit)
-; linum (generic & *scratch*)
+;; linum (generic & *scratch*)
(add-hook 'find-file-hook (lambda () (linum-mode 1)))
(add-hook 'lisp-interaction-mode-hook (lambda () (linum-mode 1)))
-; bookmarks
+;; bookmarks
(setq bookmark-default-file "~/.emacs.d/bookmarks")
(setq bookmark-save-flag 1)
-; winring
+;; winring
(require 'winring)
(ecb-winman-winring-enable-support)
(winring-initialize)
(global-set-key (kbd "C-x j") 'winring-jump-to-configuration)
(global-set-key (kbd "C-x n") 'winring-new-configuration)
(global-set-key (kbd "C-x K") 'winring-delete-configuration)
+
+;; etags
+(require 'etags-table)
+
+; autocompletion for etags
+(require 'auto-complete-etags)
+
+;; change cursor according to the mode (normal, read only, overwrite)
+(require 'cursor-chg)
+(toggle-cursor-type-when-idle 1)
+(change-cursor-mode 1)
+
+;; windmove (only if available)
+(when (fboundp 'windmove-default-keybindings) (windmove-default-keybindings))
diff --git a/emacs.d/lisp/auto-complete/auto-complete-etags.el b/emacs.d/lisp/auto-complete/auto-complete-etags.el
new file mode 100644
index 0000000..1f0f3cf
--- /dev/null
+++ b/emacs.d/lisp/auto-complete/auto-complete-etags.el
@@ -0,0 +1,60 @@
+;;; auto-complete-etags.el ---
+
+;; Copyright 2009 Yen-Chin,Lee
+;;
+;; Author: Yen-Chin,Lee
+;; Version: $Id: auto-complete-etags.el,v 0.2 2009/04/23 00:38:01 coldnew Exp $
+;; Keywords:
+;; X-URL: not distributed yet
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+;;
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program; if not, write to the Free Software
+;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+;;; Commentary:
+
+;;
+
+;; Put this file into your load-path and the following into your ~/.emacs:
+;; (require 'auto-complete-etags)
+
+;;; Code:
+
+(provide 'auto-complete-etags)
+(require 'auto-complete)
+(eval-when-compile
+ (require 'cl))
+
+
+;;;;##########################################################################
+;;;; User Options, Variables
+;;;;##########################################################################
+
+(defface ac-etags-candidate-face
+ '((t (:background "gainsboro" :foreground "deep sky blue")))
+ "Face for etags candidate")
+
+(defface ac-etags-selection-face
+ '((t (:background "deep sky blue" :foreground "white")))
+ "Face for the etags selected candidate.")
+
+(defvar ac-source-etags
+ '((candidates . (lambda ()
+ (all-completions ac-target (tags-completion-table))))
+ (candidate-face . ac-etags-candidate-face)
+ (selection-face . ac-etags-selection-face)
+ (requires . 3))
+ "Source for etags.")
+
+
+;;; auto-complete-etags.el ends here
diff --git a/emacs.d/lisp/auto-complete/auto-complete.el b/emacs.d/lisp/auto-complete/auto-complete.el
new file mode 100644
index 0000000..cdc4e86
--- /dev/null
+++ b/emacs.d/lisp/auto-complete/auto-complete.el
@@ -0,0 +1,1138 @@
+;;; auto-complete.el --- Inline auto completion
+
+;; Copyright (C) 2008, 2009 MATSUYAMA Tomohiro
+
+;; Author: MATSUYAMA Tomohiro <t.matsuyama.pub@gmail.com>
+;; Keywords: convenience
+;; Version: 0.2.0
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+;; This extension provides a way to complete with popup menu like:
+;;
+;; def-!-
+;; +-----------------+
+;; |defun::::::::::::|
+;; |defvar |
+;; |defmacro |
+;; | ... |
+;; +-----------------+
+;;
+;; You can complete by typing and selecting menu.
+;; Enjoy!
+
+;;; Qualification:
+;;
+;; This extension can work property on GNU Emacs 22 or higher.
+
+;;; Installation:
+;;
+;; To use this extension, locate all .el files of this package to your load-path directory.
+;;
+;; $ cp auto-complete-x.x.x/*.el ~/.emacs.d/
+;;
+;; And write following code into your .emacs.
+;;
+;; (require 'auto-complete)
+;; (global-auto-complete-mode t)
+
+;;; Tips:
+;;
+;; Use C-n/C-p to select candidates
+;; --------------------------------
+;;
+;; Add following code to your .emacs.
+;;
+;; (define-key ac-complete-mode-map "\C-n" 'ac-next)
+;; (define-key ac-complete-mode-map "\C-p" 'ac-previous)
+;;
+;;
+;; Don't start completion automatically
+;; ------------------------------------
+;;
+;; Add following code to your .emacs.
+;;
+;; (setq ac-auto-start nil)
+;; (global-set-key "\M-/" 'ac-start)
+;;
+;; or
+;;
+;; ;; start completion when entered 3 characters
+;; (setq ac-auto-start 3)
+;;
+;;
+;; Stop completion
+;; ---------------
+;;
+;; Add following code to your .emacs.
+;;
+;; (define-key ac-complete-mode-map "\M-/" 'ac-stop)
+;;
+;; Now you can stop completion by pressing M-/.
+;;
+;;
+;; Completion by TAB
+;; -----------------
+;;
+;; Add following code to your .emacs.
+;;
+;; (define-key ac-complete-mode-map "\t" 'ac-complete)
+;; (define-key ac-complete-mode-map "\r" nil)
+;;
+;;
+;; Do What I Mean mode
+;; -------------------
+;;
+;; If DWIM (Do What I Mean) mode is enabled,
+;; the following features is available:
+;;
+;; a. TAB (ac-expand) behave as completion (ac-complete)
+;; when only one candidate is left
+;; b. TAB (ac-expand) behave as completion (ac-complete)
+;; after you select candidate
+;; c. Disapear automatically when you
+;; complete a candidate.
+;;
+;; DWIM mode is enabled by default.
+;; You can enable this feature by
+;; setting `ac-dwim' to t.
+;;
+;; (setq ac-dwim t)
+;;
+;;
+;; Change default sources
+;; ----------------------
+;;
+;; (setq-default ac-sources '(ac-source-abbrev ac-source-words-in-buffer))
+;;
+;;
+;; Change sources for particular mode
+;; ----------------------------------
+;;
+;; (add-hook 'emacs-lisp-mode-hook
+;; (lambda ()
+;; (setq ac-sources '(ac-source-words-in-buffer ac-source-symbols))))
+
+;;; History:
+;;
+;; 2008-03-18
+;; * auto-complete.el 0.2.0 released
+;;
+;; 2008-03-04
+;; * fixed menu position bug
+;;
+;; 2008-03-02
+;; * made a source be able to be just a function which returns candidates
+;; * added ac-source-words-in-all-buffer
+;;
+;; 2008-03-01
+;; * added basic cache facility
+;;
+;; 2008-02-20
+;; * fixed menu position bug at long line (thanks rubikitch <rubikitch@ruby-lang.org>)
+;; * made dictionary source generator (ac-define-dictionary-source)
+;; * devided into some files (auto-complete-ruby.el, auto-complete-yasnippet.el, etc)
+;;
+;; 2008-02-19
+;; * added ac-trigger-commands switch
+;;
+;; 2008-02-10
+;; * added ac-stop function (suggestion from Andy Stewart)
+;; * added ac-override-local-map switch (suggestion from Andy Stewart)
+;;
+;; 2008-02-03
+;; * omni completion redesign
+;; * ac-sources is now buffer local for every buffer
+;; * fixed a menu position bug (thanks Andy Stewart)
+;; * fixed byte-compile warnings (thanks Andy Stewart)
+;;
+;; 2008-01-22
+;; * added face/selection-face property for sources
+;; * supported menu scroll
+;;
+;; 2008-01-20
+;; * omni completion
+;;
+;; 2008-12-24
+;; * suppress errors on command hook
+;;
+;; 2008-12-03
+;; * changed ac-dwim to nil by default
+;; * made menu to be able to adjust width
+;;
+;; 2008-12-03
+;; * renamed ac-find-function to ac-prefix-function
+;; * renamed ac-target to ac-prefix
+;;
+;; 2008-11-26
+;; * auto-complete.el 0.1.0 released
+;;
+;; 2008-11-19
+;; * thanks for Taiki SUGAWARA <buzz.taiki@gmail.com>
+;; * added source ac-source-abbrev
+;; * added source ac-source-symbols
+;; * added ac-expand-common to expand common part
+;;
+;; 2008-11-18
+;; * added ac-auto-start switch
+;; * added ac-dwim switch
+;; * changed menu popup behavior at end of window
+;; * thanks rubikitch <rubikitch@ruby-lang.org>, kazu-yamamoto.
+;; * fixed canceler bug
+;; * changed to use overriding-local-map instead of minor mode map
+;; * changed default key bindings
+;;
+;; 2008-11-16
+;; * supported candidates by using sources
+;; * added automatically start swtich
+;; * fixed some bug
+;; * added source ac-source-files-in-current-dir
+;; * added source ac-source-words-in-buffer
+;; * added source ac-source-yasnippet
+;; * renamed ac-enum-candidates-function to ac-candidate-function
+;; * renamed ac-find-target-function to ac-find-function
+;; * ac-find-function and ac-candidate-function is not buffer local variable now
+;; * made candidates visible when you are end of line
+;;
+;; 2008-11-11
+;; * by reporting from rubikitch <rubikitch@ruby-lang.org>
+;; * renamed hook name
+;; * registered backward-delete-char as special command
+;; * fixed code for creating candidates
+;; * made auto-complete disabled when isearch-mode enabled
+;; * added some major-mode into ac-modes
+;;
+;; 2008-11-09
+;; * auto-complete.el 0.0.1 released
+;; * fixed double-width character displaying problem
+;; * fixed menu position following tab character
+;; * made candidates visible when you are end of window
+
+;;; TODO:
+;;
+;; - test facility
+;; - support composed chars
+;; - fuzzy match
+;; - minibuffer completion
+;; - dictionary
+;; - documentation
+;; - performance issue (cache issue)
+;; - fix narrowing bug (reported by Yuto Hayamizu <y.hayamizu@gmail.com>)
+;; - care about undo (buffer-disable-undo)
+;; - scroll bar (visual)
+;; - show description
+;; - semantic
+;; - use cl
+;; - icon
+;; - refactoring (especially menu)
+;; - linum.el bug (reported by Andy Stewart)
+;; - flymake bug (reported by TiagoCamargo)
+
+;;; Code:
+
+
+
+(defgroup auto-complete nil
+ "Auto completion with popup menu"
+ :group 'convenience
+ :prefix "auto-complete-")
+
+(defcustom ac-candidate-menu-height 10
+ "Max height of candidate menu."
+ :type 'number
+ :group 'auto-complete)
+
+(defcustom ac-candidate-max 10
+ "Max of number of candidates."
+ :type 'number
+ :group 'auto-complete)
+
+(defcustom ac-modes
+ '(emacs-lisp-mode lisp-interaction-mode
+ c-mode cc-mode c++-mode java-mode
+ perl-mode cperl-mode python-mode ruby-mode
+ ecmascript-mode javascript-mode js2-mode php-mode css-mode
+ makefile-mode sh-mode fortran-mode f90-mode ada-mode
+ xml-mode sgml-mode)
+ "Major modes `auto-complete-mode' can run on."
+ :type '(list symbol)
+ :group 'auto-complete)
+
+(defcustom ac-trigger-commands
+ '(self-insert-command)
+ "Trigger commands that specify whether `auto-complete' should start or not."
+ :type '(list symbol)
+ :group 'auto-complete)
+
+(defcustom ac-auto-start t
+ "Non-nil means completion will be started automatically.
+Positive integer means if a length of a word you entered is larger than the value,
+completion will be started automatically.
+If you specify `nil', never be started automatically."
+ :group 'auto-complete)
+
+(defcustom ac-dwim nil
+ "Non-nil means `auto-complete' works based on Do What I Mean."
+ :type 'boolean
+ :group 'auto-complete)
+
+(defcustom ac-override-local-map nil
+ "Non-nil mean use `ac-complete-mode-map' override local map.
+Please set it to non-nil only if you faced to some problem about
+minor-mode keymap conflicts."
+ :type 'boolean
+ :group 'auto-complete)
+
+(defface ac-candidate-face
+ '((t (:background "lightgray" :foreground "black")))
+ "Face for candidate."
+ :group 'auto-complete)
+
+(defface ac-selection-face
+ '((t (:background "blue" :foreground "white")))
+ "Face for the selected candidate."
+ :group 'auto-complete)
+
+(defvar auto-complete-mode-hook nil
+ "Hook for `auto-complete-mode'.")
+
+(defvar ac-menu nil
+ "Menu instance.")
+
+(defvar ac-menu-direction 1
+ "Positive integer means `ac-menu' grows forward.
+Or, `ac-menu' grows backward.")
+
+(defvar ac-menu-offset 0
+ "Offset to contents.")
+
+(defvar ac-menu-scroll 0
+ "Scroll top of `ac-menu'.")
+
+(defvar ac-completing nil
+ "Non-nil means `auto-complete-mode' is now working on completion.")
+
+(defvar ac-saved-window-start nil
+ "Saved window start value for restore.")
+
+(defvar ac-saved-window-hscroll nil
+ "Saved window hscroll value for restore.")
+
+(defvar ac-buffer nil
+ "A buffer where auto-complete is started.")
+
+(defvar ac-point nil
+ "Start point of prefix.")
+
+(defvar ac-old-point nil
+ "Previous start point of prefix.")
+
+(defvar ac-prefix nil
+ "Prefix.")
+(defvaralias 'ac-target 'ac-prefix)
+
+(defvar ac-limit 0
+ "Limit of number of candidates.")
+
+(defvar ac-candidates nil
+ "Current candidates.")
+
+(defvar ac-selection nil
+ "Current candidate index.")
+
+(defvar ac-dwim-enable nil
+ "Non-nil means DWIM completion will be allowed.")
+
+(defvar ac-setup-function 'ac-sources-setup
+ "This function will be called when `auto-complete-mode' is enabled.")
+
+(defvar ac-prefix-function 'ac-sources-prefix
+ "When `auto-complete-mode' finds it can start completion
+or update candidates, it will call this function to find a
+start point of the prefix.
+
+If this function returns a point `auto-complete-mode'
+will set the substring between the point and current point to `ac-prefix'.
+And also it will start completion or update candidates by using
+the `ac-prefix'.
+
+If this function returns `nil', `auto-complete-mode'
+ignore starting completion or stop completing.")
+(defvaralias 'ac-find-function 'ac-prefix-function)
+
+(defvar ac-init-function 'ac-sources-init
+ "This function will be called when candidate menu is setupped.")
+
+(defvar ac-cleanup-function 'ac-sources-cleanup
+ "This function will be called when candidate menu is cleanupped")
+
+(defvar ac-candidate-function 'ac-sources-candidate
+ "This function can return candidates as list by
+using the `TARGET' that is given as a first argument.")
+
+(defvar ac-complete-mode-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map "\t" 'ac-expand)
+ (define-key map "\r" 'ac-complete)
+
+ (define-key map [down] 'ac-next)
+ (define-key map [up] 'ac-previous)
+
+ map)
+ "Keymap for completion.")
+
+(defvar ac-saved-local-map nil
+ "Old keymap before `auto-complete' activated.")
+
+
+
+;;;; Auto completion
+
+(defun ac-setup-menu (point width)
+ "Setup popup menu."
+ (when ac-menu
+ ;; reposition
+ (ac-menu-delete ac-menu)
+ (setq ac-menu nil))
+ (save-excursion
+ (goto-char point)
+ (let ((column (ac-current-physical-column))
+ (line (line-number-at-pos)))
+ (setq ac-saved-window-start (window-start))
+ (setq ac-saved-window-hscroll (window-hscroll))
+ (setq ac-menu-direction
+ (if (and (> line ac-candidate-menu-height)
+ (> ac-candidate-menu-height
+ (-
+ (max 1 (- (window-height)
+ (if mode-line-format 1 0)
+ (if header-line-format 1 0)))
+ (count-lines (window-start) (point)))))
+ -1
+ 1))
+ (let ((window-width (window-width))
+ (right (- (+ column width)
+ (window-hscroll))))
+ (if (and (> right window-width)
+ (>= right width)
+ (>= column width))
+ (setq column (- column width))))
+ (if (> ac-menu-direction 0)
+ (progn
+ (forward-line)
+ (if (eq line (line-number-at-pos))
+ (newline)
+ (forward-line -1))
+ (setq ac-menu (ac-menu-create (1+ line) column width ac-candidate-menu-height))
+ (setq ac-point point))
+ (setq ac-menu (ac-menu-create (- line ac-candidate-menu-height) column width ac-candidate-menu-height))
+ (setq ac-point point)))))
+
+(defun ac-cleanup ()
+ "Destroy popup menu."
+ (ac-deactivate-mode-map)
+ (when ac-menu
+ (ac-menu-delete ac-menu)
+ (set-window-start (selected-window) ac-saved-window-start)
+ (set-window-hscroll (selected-window) ac-saved-window-hscroll))
+ (setq ac-menu nil)
+ (setq ac-menu-scroll 0)
+ (setq ac-completing nil)
+ (setq ac-point nil)
+ (setq ac-candidates nil)
+ (setq ac-selection 0)
+ (setq ac-selection-scroll-top 0)
+ (funcall ac-cleanup-function))
+
+(defun ac-activate-mode-map ()
+ "Activate `ac-complete-mode-map'."
+ (if ac-override-local-map
+ (progn
+ (setq ac-saved-local-map overriding-terminal-local-map)
+ (if (eq ac-saved-local-map ac-complete-mode-map)
+ ;; maybe never reach here
+ (setq ac-saved-local-map nil))
+ (setq overriding-terminal-local-map ac-complete-mode-map))
+ ;; rearrange ac-mode-map pair first
+ (assq-delete-all 'ac-completing minor-mode-map-alist)
+ (push (cons 'ac-completing ac-complete-mode-map) minor-mode-map-alist)))
+
+(defun ac-deactivate-mode-map ()
+ "Deactivate `ac-complete-mode-map'."
+ (when (and ac-override-local-map
+ (eq overriding-terminal-local-map ac-complete-mode-map))
+ (setq overriding-terminal-local-map ac-saved-local-map)
+ (setq ac-saved-local-map nil)))
+
+(defun ac-next ()
+ "Select next candidate."
+ (interactive)
+ (if (interactive-p)
+ (setq ac-dwim-enable t))
+ (if ac-candidates
+ (ac-select-candidate
+ (let ((selection (1+ ac-selection)))
+ (if (= selection (+ ac-menu-offset (min ac-candidate-menu-height (length ac-candidates))))
+ (if (< (+ (- ac-selection ac-menu-offset) ac-menu-scroll) (1- (length ac-candidates)))
+ (prog1 ac-selection
+ (setq ac-menu-scroll (1+ ac-menu-scroll))
+ (ac-redraw-candidates))
+ (setq ac-menu-scroll 0)
+ (ac-redraw-candidates)
+ ac-menu-offset)
+ selection)))))
+
+(defun ac-previous ()
+ "Select previous candidate."
+ (interactive)
+ (if (interactive-p)
+ (setq ac-dwim-enable t))
+ (if ac-candidates
+ (ac-select-candidate
+ (let ((selection (1- ac-selection)))
+ (if (< selection ac-menu-offset)
+ (if (= ac-menu-scroll 0)
+ (prog1 (1- (+ ac-menu-offset (min ac-candidate-menu-height (length ac-candidates))))
+ (setq ac-menu-scroll (- (length ac-candidates) (min ac-candidate-menu-height (length ac-candidates))))
+ (ac-redraw-candidates))
+ (setq ac-menu-scroll (1- ac-menu-scroll))
+ (ac-redraw-candidates)
+ ac-selection)
+ selection)))))
+
+(defun ac-expand-1 ()
+ "Try expansion."
+ (let ((string (overlay-get (ac-menu-line-overlay ac-menu ac-selection) 'real-string)))
+ (delete-region ac-point (point))
+ (insert string)
+ (setq ac-prefix string)))
+
+(defun ac-expand ()
+ "Try expansion but select next if expanded twice."
+ (interactive)
+ (if (and ac-dwim ac-dwim-enable)
+ (ac-complete)
+ (let ((target ac-prefix)
+ (string (ac-expand-1)))
+ (when (equal target string)
+ (ac-next)
+ (ac-expand-1)))))
+
+(defun ac-expand-common ()
+ "Try expansion common part."
+ (interactive)
+ (let ((common (try-completion ac-prefix ac-candidates))
+ (buffer-undo-list t))
+ (when (stringp common)
+ (delete-region ac-point (point))
+ (insert common)
+ (setq ac-prefix common))))
+
+(defun ac-complete ()
+ "Try completion."
+ (interactive)
+ (let* ((candidate (ac-get-selected-candidate))
+ (action (ac-get-candidate-action candidate)))
+ (ac-expand-1)
+ (if action
+ (funcall action))
+ (ac-abort)))
+
+(defun ac-abort ()
+ "Abort completion."
+ (ac-cleanup))
+
+(defun ac-stop ()
+ "Stop completiong."
+ (interactive)
+ (ac-abort))
+
+(defun ac-redraw-candidates ()
+ "Redraw the menu contents."
+ (let ((i ac-menu-offset))
+ ;; show line and set string to the line
+ (mapc
+ (lambda (candidate)
+ (when (< i ac-candidate-menu-height)
+ (ac-menu-show-line ac-menu i)
+ (ac-menu-set-line-string ac-menu i candidate
+ (if (= i ac-selection)
+ (or (ac-get-candidate-property 'selection-face candidate) 'ac-selection-face)
+ (or (ac-get-candidate-property 'candidate-face candidate) 'ac-candidate-face)))
+ (setq i (1+ i))))
+ (nthcdr ac-menu-scroll ac-candidates))
+ ;; ensure lines visible
+ (if (and (> ac-menu-direction 0)
+ (> i (-
+ (max 1 (- (window-height)
+ (if mode-line-format 1 0)
+ (if header-line-format 1 0)))
+ (count-lines (window-start) (point)))))
+ (recenter (- (1+ i))))
+ (if (> i ac-menu-offset)
+ (let ((window-width (window-width))
+ (right (- (+ (ac-menu-column ac-menu) (ac-menu-width ac-menu))
+ (window-hscroll))))
+ (if (> right window-width)
+ (scroll-left (- right window-width)))))
+ ;; hide remaining lines
+ (if (> ac-menu-direction 0)
+ (while (< i ac-candidate-menu-height)
+ (ac-menu-hide-line ac-menu i)
+ (setq i (1+ i)))
+ (dotimes (i ac-menu-offset)
+ (ac-menu-hide-line ac-menu i)))))
+
+(defun ac-update-candidates (candidates)
+ "Update candidates of popup menu."
+ (setq ac-menu-offset (if (> ac-menu-direction 0)
+ 0
+ (- ac-candidate-menu-height
+ (min ac-candidate-menu-height
+ (length candidates)))))
+ (setq ac-selection ac-menu-offset)
+ (setq ac-candidates candidates)
+ (setq ac-dwim-enable (= (length candidates) 1))
+ (if candidates
+ (progn
+ (setq ac-completing t)
+ (ac-activate-mode-map))
+ (setq ac-completing nil)
+ (ac-deactivate-mode-map))
+ (ac-redraw-candidates))
+
+(defun ac-get-selected-candidate ()
+ (overlay-get (ac-menu-line-overlay ac-menu ac-selection) 'real-string))
+
+(defun ac-get-candidate-action (candidate)
+ (ac-get-candidate-property 'action candidate))
+
+(defun ac-propertize-candidate (candidate &rest properties)
+ (apply 'propertize candidate properties))
+
+(defun ac-get-candidate-property (prop candidate)
+ (get-text-property 0 prop candidate))
+
+(defun ac-select-candidate (selection)
+ "Select candidate pointed by `SELECTION'."
+ (when ac-candidates
+ (let ((c1 (nth (+ (- ac-selection ac-menu-offset) ac-menu-scroll) ac-candidates))
+ (c2 (nth (+ (- selection ac-menu-offset) ac-menu-scroll) ac-candidates)))
+ (ac-menu-set-line-string ac-menu ac-selection c1
+ (or (ac-get-candidate-property 'candidate-face c1)
+ 'ac-candidate-face))
+ (ac-menu-set-line-string ac-menu selection c2
+ (or (ac-get-candidate-property 'selection-face c2)
+ 'ac-selection-face))
+ (setq ac-selection selection))))
+
+(defun ac-start ()
+ "Start completion."
+ (interactive)
+ (let* ((point (save-excursion (funcall ac-prefix-function)))
+ (reposition (not (equal ac-point point))))
+ (if (null point)
+ (ac-abort)
+ (setq ac-buffer (current-buffer))
+ (setq ac-point point)
+ (when (not (equal ac-point ac-old-point))
+ (setq ac-old-point point))
+ (setq ac-prefix (buffer-substring-no-properties point (point)))
+ (setq ac-limit ac-candidate-max)
+ (if (or reposition (null ac-menu))
+ (save-excursion
+ (funcall ac-init-function)))
+ (let* ((candidates
+ (if (or ac-completing
+ (not (integerp ac-auto-start))
+ (>= (length ac-prefix) ac-auto-start))
+ (save-excursion
+ (funcall ac-candidate-function))))
+ (current-width (if ac-menu (ac-menu-width ac-menu) 0))
+ (width (let ((w '(0)) s)
+ (dotimes (i ac-candidate-menu-height)
+ (setq s (nth i candidates))
+ (if (stringp s) (push (string-width s) w)))
+ (apply 'max w))))
+ (if (or reposition
+ (null ac-menu)
+ (> width current-width)
+ (< width (- current-width 10)))
+ (ac-setup-menu point (* (ceiling (/ width 10.0)) 10)))
+ (if (and ac-dwim
+ (= (length candidates) 1)
+ (equal (car candidates) ac-prefix)
+ (null (ac-get-candidate-action (car candidates))))
+ (setq candidates nil))
+ (ac-update-candidates candidates)))))
+
+(defun ac-trigger-command-p ()
+ "Return non-nil if `this-command' is a trigger command."
+ (or (memq this-command ac-trigger-commands)
+ (and ac-completing
+ (memq this-command
+ '(delete-backward-char
+ backward-delete-char
+ backward-delete-char-untabify)))))
+
+(defun ac-current-physical-column ()
+ "Current physical column. (not logical column)"
+ (- (point) (save-excursion (vertical-motion 0) (point))))
+
+(defun ac-on-pre-command ()
+ (progn ; ignore-errors
+ (if (and (not (ac-trigger-command-p))
+ (or (not (symbolp this-command))
+ (not (string-match "^ac-" (symbol-name this-command)))))
+ (ac-abort))))
+
+(defun ac-on-post-command ()
+ (progn ; ignore-errors
+ (if (and (or ac-auto-start
+ ac-completing)
+ (not isearch-mode)
+ (ac-trigger-command-p))
+ (ac-start))))
+
+(defun auto-complete-mode-maybe ()
+ "What buffer `auto-complete-mode' prefers."
+ (if (and (not (minibufferp (current-buffer)))
+ (memq major-mode ac-modes))
+ (auto-complete-mode 1)))
+
+(require 'easy-mmode)
+
+(define-minor-mode auto-complete-mode
+ "AutoComplete mode"
+ :lighter " AC"
+ :group 'auto-complete
+ (if auto-complete-mode
+ (progn
+ (funcall ac-setup-function)
+ (add-hook 'post-command-hook 'ac-on-post-command nil t)
+ (add-hook 'pre-command-hook 'ac-on-pre-command nil t)
+ (run-hooks 'auto-complete-mode-hook))
+ (remove-hook 'post-command-hook 'ac-on-post-command t)
+ (remove-hook 'pre-command-hook 'ac-on-pre-command t)
+ (ac-abort)))
+
+(define-global-minor-mode global-auto-complete-mode
+ auto-complete-mode auto-complete-mode-maybe
+ :group 'auto-complete)
+
+
+
+;;;; Basic cache facility
+
+(defvar ac-clear-variables-after-save nil)
+
+(defun ac-clear-variable-after-save (variable)
+ (push variable ac-clear-variables-after-save))
+
+(defun ac-clear-variables-after-save ()
+ (dolist (variable ac-clear-variables-after-save)
+ (set variable nil)))
+
+
+
+;;;; Sources implementation
+
+(defvar ac-sources '(ac-source-words-in-buffer)
+ "Sources for completion.
+
+Source takes a form of just function which returns candidates or alist:
+
+init INIT-FUNC
+ INIT-FUNC will be called before creating candidate every time.
+
+candidates CANDIDATE-FUNC
+ CANDIDATE-FUNC will return a list of string as candidates.
+CANDIDATE-FUNC should care about `ac-limit' that is specified at limit for performance.
+
+action ACTION-FUNC
+ ACTION-FUNC will be called when `ac-complete' is called.
+
+limit LIMIT-NUM
+ A limit of candidates.
+
+requires REQUIRES-NUM
+ This source will be included when `ac-prefix' length is larger than REQUIRES-NUM.")
+(make-variable-buffer-local 'ac-sources)
+
+(defvar ac-sources-prefix-function 'ac-sources-prefix-default
+ "Default prefix function for sources.
+You should override this variable instead of ac-prefix-function.")
+
+(defvar ac-current-sources nil
+ "Current working sources.")
+
+(defvar ac-omni-completion-sources nil
+ "An alist of REGEXP and SOURCES.
+If matched regexp, switch to omni-completion mode and
+use SOURCES as `ac-sources'.")
+(make-variable-buffer-local 'ac-omni-completion-sources)
+
+(defvar ac-sources-omni-completion nil
+ "Non-nil means `auto-complete-mode' is now working on omni-completion.")
+
+(defun ac-sources-setup ()
+ "Implementation for `ac-setup-function' by sources."
+ (make-local-variable 'ac-clear-variables-after-save)
+ (add-hook 'after-save-hook 'ac-clear-variables-after-save nil t))
+
+(defun ac-sources-init ()
+ "Implementation for `ac-init-function' by sources."
+ (or ac-current-sources (setq ac-current-sources ac-sources))
+ (dolist (source ac-current-sources)
+ (let ((init-function (ac-get-source-property 'init source)))
+ (if init-function
+ (funcall init-function)))))
+
+(defun ac-sources-cleanup ()
+ "Implementation for `ac-cleanup-function' by sources."
+ (setq ac-current-sources nil)
+ (setq ac-sources-omni-completion nil))
+
+(defun ac-sources-prefix ()
+ "Implemention for `ac-prefix-function' by sources."
+ (let (point)
+ (dolist (pair ac-omni-completion-sources)
+ (when (looking-back (car pair))
+ (setq ac-current-sources (cdr pair))
+ (setq ac-sources-omni-completion t)
+ (setq ac-completing t)
+ (setq point (match-end 0))))
+ (or point
+ (if (and ac-completing ac-sources-omni-completion)
+ ac-point
+ (setq ac-current-sources ac-sources)
+ (setq ac-sources-omni-completion nil)
+ (funcall ac-sources-prefix-function)))))
+
+(defun ac-sources-prefix-default ()
+ "Default implementation for `ac-sources-prefix-function'."
+ (require 'thingatpt)
+ (car-safe (bounds-of-thing-at-point 'symbol)))
+
+(defun ac-sources-candidate ()
+ "Implementation for `ac-cadidates-function' by sources."
+ (let (candidates)
+ (dolist (source ac-current-sources)
+ (let* ((ac-limit (or (ac-get-source-property 'limit source) ac-limit))
+ (requires (ac-get-source-property 'requires source))
+ cand)
+ (when (or ac-sources-omni-completion
+ (>= (length ac-prefix)
+ (if (integerp requires)
+ requires
+ 1)))
+ (setq cand
+ (delq nil
+ (mapcar (lambda (candidate)
+ (ac-propertize-candidate candidate
+ 'action (ac-get-source-property 'action source)
+ 'face (ac-get-source-property 'candidate-face source)
+ 'candidate-face (ac-get-source-property 'candidate-face source)
+ 'selection-face (ac-get-source-property 'selection-face source)))
+ (funcall (ac-get-source-property 'candidates source))))))
+ (if (and (> ac-limit 1)
+ (> (length cand) ac-limit))
+ (setcdr (nthcdr (1- ac-limit) (copy-sequence cand)) nil))
+ (setq candidates (append candidates cand))))
+ (delete-dups candidates)))
+
+(defun ac-get-source-property (property source)
+ (if (symbolp source)
+ (setq source (symbol-value source)))
+ (if (and (functionp source)
+ (eq property 'candidates))
+ source
+ (if (consp source)
+ (assoc-default property source))))
+
+
+
+;;;; Standard sources
+
+(defun ac-candidate-words-in-buffer ()
+ "Default implemention for `ac-candidate-function'."
+ (if (> (length ac-prefix) 0)
+ (let ((i 0)
+ candidate
+ candidates
+ (regexp (concat "\\b" (regexp-quote ac-prefix) "\\(\\s_\\|\\sw\\)*\\b")))
+ (save-excursion
+ ;; search backward
+ (goto-char ac-point)
+ (while (and (< i ac-limit)
+ (re-search-backward regexp nil t))
+ (setq candidate (match-string-no-properties 0))
+ (unless (member candidate candidates)
+ (push candidate candidates)
+ (setq i (1+ i))))
+ ;; search backward
+ (goto-char (+ ac-point (length ac-prefix)))
+ (while (and (< i ac-limit)
+ (re-search-forward regexp nil t))
+ (setq candidate (match-string-no-properties 0))
+ (unless (member candidate candidates)
+ (push candidate candidates)
+ (setq i (1+ i))))
+ (nreverse candidates)))))
+
+(defvar ac-source-words-in-buffer
+ '((candidates . ac-candidate-words-in-buffer))
+ "Source for completing words in current buffer.")
+
+(defvar ac-word-index nil
+ "Word index for individual buffer.")
+
+(ac-clear-variable-after-save 'ac-word-index)
+
+(defvar ac-source-words-in-all-buffer
+ '((init
+ . (lambda ()
+ (dolist (buffer (buffer-list))
+ (with-current-buffer buffer
+ (if (not (local-variable-p 'ac-word-index))
+ (make-local-variable 'ac-word-index))
+ (if (eq buffer ac-buffer)
+ (setq ac-word-index (ac-candidate-words-in-buffer))
+ (if (and (null ac-word-index)
+ (< (buffer-size) 102400))
+ (save-excursion
+ (goto-char (point-min))
+ (while (re-search-forward "\\b\\(\\s_\\|\\sw\\)+\\b" nil t)
+ (let ((candidate (match-string-no-properties 0)))
+ (if (not (member candidate ac-word-index))
+ (push candidate ac-word-index))))
+ (setq ac-word-index (nreverse ac-word-index)))))))))
+ (candidates
+ . (lambda ()
+ (let ((candidates)
+ (buffers (buffer-list)))
+ (while (and (< (length candidates) ac-limit)
+ buffers)
+ (setq candidates (append candidates (all-completions ac-prefix (buffer-local-value 'ac-word-index (car buffers)))))
+ (setq buffers (cdr buffers)))
+ candidates))))
+ "Source for completing words in all buffer.")
+
+(defvar ac-source-symbols
+ '((candidates
+ . (lambda ()
+ (all-completions ac-prefix obarray))))
+ "Source for Emacs lisp symbols.")
+
+(defvar ac-source-abbrev
+ `((candidates
+ . (lambda ()
+ (all-completions ac-prefix local-abbrev-table)))
+ (action
+ . expand-abbrev))
+ "Source for abbrev.")
+
+(defvar ac-source-files-in-current-dir
+ '((candidates
+ . (lambda ()
+ (all-completions ac-prefix (directory-files default-directory)))))
+ "Source for listing files in current directory.")
+
+(defun ac-filename-candidate ()
+ (let ((dir (file-name-directory ac-prefix)))
+ (ignore-errors
+ (delq nil
+ (mapcar (lambda (file)
+ (if (not (member file '("./" "../")))
+ (concat dir file)))
+ (file-name-all-completions
+ (file-name-nondirectory ac-prefix) dir))))))
+
+(defvar ac-source-filename
+ '((candidates . ac-filename-candidate))
+ "Source for completing file name.")
+
+(defvar ac-imenu-index nil
+ "Imenu index.")
+
+(defun ac-imenu-candidate ()
+ (require 'imenu)
+ (let ((i 0)
+ (stack ac-imenu-index)
+ candidates
+ node)
+ (while (and stack
+ (< i ac-limit))
+ (setq node (pop stack))
+ (when (consp node)
+ (let ((car (car node))
+ (cdr (cdr node)))
+ (if (consp cdr)
+ (mapc (lambda (child)
+ (push child stack))
+ cdr)
+ (when (and (stringp car)
+ (string-match (concat "^" (regexp-quote ac-prefix)) car))
+ (push car candidates)
+ (setq i (1+ i)))))))
+ (nreverse candidates)))
+
+(defvar ac-source-imenu
+ '((init
+ . (lambda ()
+ (require 'imenu)
+ (setq ac-imenu-index
+ (ignore-errors (imenu--make-index-alist)))))
+ (candidates . ac-imenu-candidate))
+ "Source for imenu.")
+
+(defmacro ac-define-dictionary-source (name list)
+ "Define dictionary source named `NAME'.
+`LIST' is a list of string.
+This is useful if you just want to define a dictionary/keywords source."
+ `(defvar ,name
+ '((candidates . (lambda () (all-completions ac-prefix ,list))))))
+
+
+
+;;;; Popup menu
+
+(defun ac-menu-line (menu)
+ "Line number of `MENU'."
+ (nth 0 menu))
+
+(defun ac-menu-column (menu)
+ "Column of `MENU'."
+ (nth 1 menu))
+
+(defun ac-menu-width (menu)
+ "Popup menu width of `MENU'."
+ (nth 2 menu))
+
+(defun ac-menu-height (menu)
+ "Popup menu height of `MENU'."
+ (nth 3 menu))
+
+(defun ac-menu-overlays (menu)
+ "Overlays that `MENU' contains."
+ (nth 4 menu))
+
+(defun ac-menu-line-overlay (menu line)
+ "Return a overlay of `MENU' at `LINE'."
+ (aref (ac-menu-overlays menu) line))
+
+(defun ac-menu-hide-line (menu line)
+ "Hide `LINE' in `MENU'."
+ (let ((overlay (ac-menu-line-overlay menu line)))
+ (overlay-put overlay 'invisible nil)
+ (overlay-put overlay 'after-string nil)))
+
+(defun ac-menu-show-line (menu line)
+ "Show `LINE' in `MENU'."
+ (let ((overlay (ac-menu-line-overlay menu line)))
+ (overlay-put overlay 'invisible t)))
+
+(defun ac-menu-set-line-string (menu line string &optional face)
+ "Set contents of `LINE' in `MENU'."
+ (let ((overlay (ac-menu-line-overlay menu line)))
+ (overlay-put overlay 'real-string string)
+ (funcall (overlay-get overlay 'set-string-function) menu overlay string face)))
+
+(defun ac-menu-create-line-string (menu string)
+ "Adjust `STRING' into `MENU'."
+ (let ((length 0)
+ (width 0)
+ (menu-width (ac-menu-width menu))
+ (chars (append string nil)))
+ (while (and
+ chars
+ (<= (setq width (+ width (char-width (car chars)))) menu-width))
+ (setq length (1+ length))
+ (setq chars (cdr chars)))
+ (if (< length (length string))
+ (setq string (substring string 0 length)))
+ (let ((string-width (string-width string)))
+ (if (< string-width menu-width)
+ (setq string (concat string
+ (make-string (- menu-width string-width) ? )))))
+ string))
+
+(defun ac-menu-hide (menu)
+ "Hide `MENU'."
+ (dotimes (i (ac-menu-height menu))
+ (ac-menu-hide-line menu i)))
+
+(defun ac-menu-last-line-of-buffer ()
+ (save-excursion
+ (not (eq (forward-line) 0))))
+
+(defun ac-menu-create (line column width height)
+ "Create popup menu."
+ (save-excursion
+ (let ((overlays (make-vector height nil))
+ (window (selected-window)))
+ (goto-line line)
+ (dotimes (i height)
+ (move-to-column column)
+ (let (overlay begin w current-column (prefix "") (postfix ""))
+ (setq current-column (current-column))
+ (cond
+ ((> current-column column)
+ (backward-char)
+ (setq current-column (current-column))
+ (if (< current-column column)
+ (setq prefix (make-string (- column current-column) ? ))))
+ ((< current-column column)
+ (setq prefix (make-string (- column current-column) ? ))))
+
+ (setq begin (point))
+ (setq w (+ width (length prefix)))
+ (while (and (not (eolp))
+ (> w 0))
+ (setq w (- w (char-width (char-after))))
+ (forward-char))
+ (if (< w 0)
+ (setq postfix (make-string (- w) ? )))
+ (if (ac-menu-last-line-of-buffer)
+ (setq postfix (concat postfix "\n")))
+
+ (setq overlay (make-overlay begin (point)))
+ (overlay-put overlay 'window window)
+ (overlay-put overlay 'prefix prefix)
+ (overlay-put overlay 'postfix postfix)
+ (overlay-put overlay 'width width)
+ (overlay-put overlay 'set-string-function
+ (lambda (menu overlay string &optional face)
+ (overlay-put overlay
+ 'after-string
+ (concat (overlay-get overlay 'prefix)
+ (propertize (ac-menu-create-line-string menu string) 'face face)
+ (overlay-get overlay 'postfix)))))
+ (aset overlays i overlay))
+ (forward-line))
+ (let ((i 100))
+ (mapc (lambda (overlay)
+ (overlay-put overlay 'priority i)
+ (setq i (1+ i)))
+ (nreverse (append overlays nil))))
+ (list line column width height overlays))))
+
+(defun ac-menu-delete (menu)
+ "Delete `MENU'."
+ (mapcar 'delete-overlay (ac-menu-overlays menu)))
+
+(provide 'auto-complete)
+;;; auto-complete.el ends here
diff --git a/emacs.d/lisp/cursor-chg.el b/emacs.d/lisp/cursor-chg.el
new file mode 100644
index 0000000..159d4e1
--- /dev/null
+++ b/emacs.d/lisp/cursor-chg.el
@@ -0,0 +1,348 @@
+;;; cursor-chg.el --- Change cursor dynamically, depending on the context.
+;;
+;; Filename: cursor-chg.el
+;; Description: Change cursor dynamically, depending on the context.
+;; Author: Drew Adams
+;; Maintainer: Drew Adams
+;; Copyright (C) 2006-2009, Drew Adams, all rights reserved.
+;; Created: Tue Aug 29 11:23:06 2006
+;; Version: 20.1
+;; Last-Updated: Sat Aug 1 15:14:46 2009 (-0700)
+;; By: dradams
+;; Update #: 191
+;; URL: http://www.emacswiki.org/cgi-bin/wiki/cursor-chg.el
+;; Keywords: cursor, accessibility
+;; Compatibility: GNU Emacs: 20.x, 21.x, 22.x, 23.x
+;;
+;; Features that might be required by this library:
+;;
+;; None
+;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;;; Commentary:
+;;
+;; This library provides three kinds of changes to the text cursor:
+;;
+;; 1. When a buffer is read-only or is in overwrite mode, the cursor
+;; type changes to `curchg-overwrite/read-only-cursor-type'. This
+;; is controlled by command `change-cursor-mode' and user option
+;; `curchg-change-cursor-on-overwrite/read-only-flag'.
+;;
+;; 2. When an input method is in use, the cursor color changes to
+;; `curchg-input-method-cursor-color'. This is controlled by
+;; command `change-cursor-mode' and user option
+;; `curchg-change-cursor-on-input-method-flag'.
+;;
+;; 3. When Emacs is idle, the cursor type changes to
+;; `curchg-idle-cursor-type'. This is controlled by command
+;; `toggle-cursor-type-when-idle'.
+;;
+;; To turn on all three types of cursor change by default, put the
+;; following in your Emacs init file (~/.emacs):
+;;
+;; (require 'cursor-chg) ; Load this library
+;; (change-cursor-mode 1) ; On for overwrite/read-only/input mode
+;; (toggle-cursor-type-when-idle 1) ; On when idle
+;;
+;; Note: Library `oneonone.el' provides the same functionality as
+;; library `cursor-chg.el', and more. If you use library
+;; `oneonone.el', then do NOT also use library `cursor-chg.el'.
+;;
+;; Note for Emacs 20: There is a bug in Emacs 20 which can lead to a
+;; fatal error (Emacs crash) when using `query-replace' with
+;; idle-cursor change enabled. If you use Emacs 20, then consider
+;; using `toggle-cursor-type-when-idle' to disable idle-cursor change
+;; while you use `query-replace'.
+;;
+;; User options defined here:
+;;
+;; `curchg-change-cursor-on-input-method-flag',
+;; `curchg-change-cursor-on-overwrite/read-only-flag',
+;; `curchg-default-cursor-color', `curchg-default-cursor-type',
+;; `curchg-idle-cursor-type', `curchg-input-method-cursor-color',
+;; `curchg-overwrite/read-only-cursor-type'.
+;;
+;; Commands defined here:
+;;
+;; `change-cursor-mode', `curchg-change-cursor-when-idle-interval',
+;; `curchg-set-cursor-type', `curchg-toggle-cursor-type-when-idle',
+;; `set-cursor-type', `toggle-cursor-type-when-idle'.
+;;
+;; Internal variables defined here:
+;;
+;; `curchg-change-cursor-when-idle-p', `curchg-idle-interval',
+;; `curchg-idle-timer', `curchg-last-cursor-type'.
+;;
+;; Non-interactive functions defined here:
+;;
+;; `curchg-change-cursor-on-input-method',
+;; `curchg-change-cursor-on-overwrite/read-only',
+;; `curchg-change-cursor-to-idle-type',
+;; `curchg-change-cursor-to-idle-type-off'.
+;;
+;; Acknowledgements:
+;;
+;; The cursor-changing on input method and read-only was inspired by
+;; Juri Linkov <juri@jurta.org>. Joe Casadonte <joc@netaxs.com>
+;; wrote a similar hook (`joc-cursor-type-set-hook'), which he got
+;; from Steve Kemp...
+;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;;; Change log:
+;;
+;; 2006/10/28 dadams
+;; curchg-default-cursor-color, curchg-input-method-cursor-color:
+;; Changed :type to 'color for Emacs 21+.
+;; 2006/09/04 dadams
+;; curchg-idle-timer: Cancel beforehand, and cancel after defining.
+;; curchg-toggle-cursor-type-when-idle:
+;; Use curchg-change-cursor-to-idle-type-off on pre-command-hook.
+;; Don't read an event; just turn it on.
+;; Added: curchg-change-cursor-to-idle-type-off.
+;; 2006/09/03 dadams
+;; Created.
+;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;; This program is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation; either version 2, or
+;; (at your option) any later version.
+;;
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;; General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program; see the file COPYING. If not, write to
+;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
+;; Floor, Boston, MA 02110-1301, USA.
+;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;;; Code:
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+;;------- User Options -------------------------------------
+
+;; Emacs 20 only
+(unless (fboundp 'define-minor-mode)
+ (defcustom change-cursor-mode nil
+ "*Toggle changing cursor type and color.
+Setting this variable directly does not take effect;
+use either \\[customize] or command `change-cursor-mode'."
+ :set (lambda (symbol value) (change-cursor-mode (if value 1 -1)))
+ :initialize 'custom-initialize-default
+ :type 'boolean :group 'cursor :require 'cursor-chg))
+
+(defcustom curchg-change-cursor-on-input-method-flag t
+ "*Non-nil means to use a different cursor when using an input method."
+ :type 'boolean :group 'cursor)
+
+(defcustom curchg-change-cursor-on-overwrite/read-only-flag t
+ "*Non-nil means use a different cursor for overwrite mode or read-only."
+ :type 'boolean :group 'cursor)
+
+(defcustom curchg-default-cursor-color (or (cdr (assq 'cursor-color default-frame-alist))
+ "Red")
+ "*Default text cursor color for non-special frames."
+ :type (if (>= emacs-major-version 21) 'color 'string) :group 'cursor)
+
+(defcustom curchg-default-cursor-type 'bar "*Default text cursor type."
+ :type 'symbol :group 'cursor)
+
+(defcustom curchg-idle-cursor-type 'box
+ "*Text cursor type when Emacs is idle."
+ :type 'symbol :group 'cursor)
+
+(defcustom curchg-input-method-cursor-color "Orange"
+ "*Default cursor color if using an input method.
+This has no effect if `curchg-change-cursor-on-input-method-flag' is nil."
+ :type (if (>= emacs-major-version 21) 'color 'string) :group 'cursor)
+
+(defcustom curchg-overwrite/read-only-cursor-type 'box
+ "*Default text cursor type for overwrite mode or read-only buffer.
+This applies only to non-special frames. This has no effect if
+`curchg-change-cursor-on-overwrite/read-only-flag' is nil."
+ :type 'symbol :group 'cursor)
+
+
+;;------- Internal Variables -------------------------------
+
+(defvar curchg-last-cursor-type curchg-default-cursor-type "Saved last cursor type.")
+
+(defvar curchg-idle-interval 2
+ "Number of seconds to wait before changing to alternate cursor type.
+The alternate cursor type is `curchg-idle-cursor-type'.
+Do NOT change this yourself to change the wait period; instead, use
+`\\[curchg-change-cursor-when-idle-interval]'.")
+
+(defvar curchg-idle-timer
+ (progn ; Cancel to prevent duplication.
+ (when (boundp 'curchg-idle-timer) (cancel-timer curchg-idle-timer))
+ (run-with-idle-timer curchg-idle-interval t 'curchg-change-cursor-to-idle-type))
+ "Timer used to change the cursor to alternate type when Emacs is idle.")
+
+;; Turn it off, by default. You must use `toggle-cursor-type-when-idle' to turn it on.
+(cancel-timer curchg-idle-timer)
+
+(defvar curchg-change-cursor-when-idle-p nil
+ "Non-nil means to use an alternate cursor type whenever Emacs is idle.
+Do NOT change this yourself; instead, use `\\[toggle-cursor-type-when-idle]'.")
+
+
+;;------- Commands -----------------------------------------
+
+(unless (fboundp 'set-cursor-type) (defalias 'set-cursor-type 'curchg-set-cursor-type))
+;; This is essentially from Juri Linkov <juri@jurta.org>.
+(defun curchg-set-cursor-type (cursor-type)
+ "Set the cursor type of the selected frame to CURSOR-TYPE.
+When called interactively, prompt for the type to use.
+To get the frame's current cursor type, use `frame-parameters'."
+ (interactive
+ (list (intern (completing-read "Cursor type: "
+ (mapcar 'list '("box" "hollow" "bar" "hbar" nil))))))
+ (modify-frame-parameters (selected-frame) (list (cons 'cursor-type cursor-type))))
+
+(defalias 'toggle-cursor-type-when-idle 'curchg-toggle-cursor-type-when-idle)
+(defun curchg-toggle-cursor-type-when-idle (&optional arg)
+"Turn on or off automatically changing cursor type when Emacs is idle.
+When on, use `curchg-idle-cursor-type' whenever Emacs is idle.
+With prefix argument, turn on if ARG > 0; else turn off."
+ (interactive "P")
+ (setq curchg-change-cursor-when-idle-p
+ (if arg (> (prefix-numeric-value arg) 0) (not curchg-change-cursor-when-idle-p)))
+ (cond (curchg-change-cursor-when-idle-p
+ (timer-activate-when-idle curchg-idle-timer)
+ (add-hook 'pre-command-hook 'curchg-change-cursor-to-idle-type-off)
+ (message "Turned ON changing cursor when Emacs is idle."))
+ (t
+ (cancel-timer curchg-idle-timer)
+ (remove-hook 'pre-command-hook 'curchg-change-cursor-to-idle-type-off)
+ (message "Turned OFF changing cursor when Emacs is idle."))))
+
+(defun curchg-change-cursor-when-idle-interval (secs)
+ "Set wait until automatically change cursor type when Emacs is idle.
+Whenever Emacs is idle for this many seconds, the cursor type will
+change to `curchg-idle-cursor-type'.
+
+To turn on or off automatically changing the cursor type when idle,
+use `\\[toggle-cursor-type-when-idle]."
+ (interactive
+ "nSeconds to idle, before changing cursor type: ")
+ (timer-set-idle-time curchg-idle-timer
+ (setq curchg-idle-interval secs)
+ t))
+
+(if (fboundp 'define-minor-mode)
+ ;; Emacs 21 and later.
+ (define-minor-mode change-cursor-mode
+ "Toggle changing cursor type and color.
+With numeric ARG, turn cursor changing on if and only if ARG is positive.
+
+When this mode is on, `curchg-change-cursor-on-input-method' and
+`curchg-change-cursor-on-overwrite/read-only-flag' control cursor
+changing."
+ :init-value nil :global t :group 'frames
+ :link `(url-link :tag "Send Bug Report"
+ ,(concat "mailto:" "drew.adams" "@" "oracle" ".com?subject=\
+cursor-chg.el bug: \
+&body=Describe bug here, starting with `emacs -q'. \
+Don't forget to mention your Emacs and library versions."))
+ :link '(url-link :tag "Other Libraries by Drew"
+ "http://www.emacswiki.org/cgi-bin/wiki/DrewsElispLibraries")
+ :link '(url-link :tag "Download" "http://www.emacswiki.org/cgi-bin/wiki/cursor-chg.el")
+ :link '(url-link :tag "Description"
+ "http://www.emacswiki.org/cgi-bin/wiki/ChangingCursorDynamically")
+ :link '(emacs-commentary-link :tag "Commentary" "cursor-chg")
+ (cond (change-cursor-mode
+ (if curchg-change-cursor-on-overwrite/read-only-flag
+ (add-hook 'post-command-hook 'curchg-change-cursor-on-overwrite/read-only)
+ (curchg-set-cursor-type curchg-default-cursor-type)
+ (remove-hook 'post-command-hook 'curchg-change-cursor-on-overwrite/read-only))
+ (if curchg-change-cursor-on-input-method-flag
+ (add-hook 'post-command-hook 'curchg-change-cursor-on-input-method)
+ (setq current-input-method nil)
+ (curchg-change-cursor-on-input-method)
+ (remove-hook 'post-command-hook 'curchg-change-cursor-on-input-method)))
+ (t
+ (curchg-set-cursor-type curchg-default-cursor-type)
+ (setq current-input-method nil)
+ (curchg-change-cursor-on-input-method)
+ (remove-hook 'post-command-hook 'curchg-change-cursor-on-overwrite/read-only)
+ (remove-hook 'post-command-hook 'curchg-change-cursor-on-input-method))))
+
+ ;; Emacs 20
+ (defun change-cursor-mode (&optional arg)
+ "Toggle changing cursor type and color.
+With numeric ARG, turn cursor changing on if and only if ARG is positive.
+
+When this mode is on, `curchg-change-cursor-on-input-method' and
+`curchg-change-cursor-on-overwrite/read-only-flag' control cursor
+changing."
+ (interactive "P")
+ (setq change-cursor-mode
+ (if arg (> (prefix-numeric-value arg) 0) (not change-cursor-mode)))
+ (cond (change-cursor-mode
+ (if curchg-change-cursor-on-overwrite/read-only-flag
+ (add-hook 'post-command-hook 'curchg-change-cursor-on-overwrite/read-only)
+ (curchg-set-cursor-type curchg-default-cursor-type)
+ (remove-hook 'post-command-hook 'curchg-change-cursor-on-overwrite/read-only))
+ (if curchg-change-cursor-on-input-method-flag
+ (add-hook 'post-command-hook 'curchg-change-cursor-on-input-method)
+ (setq current-input-method nil)
+ (curchg-change-cursor-on-input-method)
+ (remove-hook 'post-command-hook 'curchg-change-cursor-on-input-method))
+ (message "Change cursor on overwrite/read-only: %s; on input method: %s"
+ (if curchg-change-cursor-on-overwrite/read-only-flag "ON" "OFF")
+ (if curchg-change-cursor-on-input-method-flag "ON" "OFF")))
+ (t
+ (curchg-set-cursor-type curchg-default-cursor-type)
+ (setq current-input-method nil)
+ (curchg-change-cursor-on-input-method)
+ (remove-hook 'post-command-hook 'curchg-change-cursor-on-overwrite/read-only)
+ (remove-hook 'post-command-hook 'curchg-change-cursor-on-input-method)
+ (message "Turned OFF changing cursor on overwrite/read-only and input method")))))
+
+
+;;------- Non-Interactive Functions ------------------------
+
+;; This is inspired by code from Juri Linkov <juri@jurta.org>.
+(defun curchg-change-cursor-on-input-method ()
+ "Set cursor type depending on whether an input method is used or not."
+ (set-cursor-color (if current-input-method
+ curchg-input-method-cursor-color
+ curchg-default-cursor-color)))
+
+;; This is from Juri Linkov <juri@jurta.org>, with read-only added.
+(defun curchg-change-cursor-on-overwrite/read-only ()
+ "Set cursor type differently for overwrite mode and read-only buffer.
+That is, use one cursor type for overwrite mode and read-only buffers,
+and another cursor type otherwise."
+ (curchg-set-cursor-type (if (or buffer-read-only overwrite-mode)
+ curchg-overwrite/read-only-cursor-type
+ curchg-default-cursor-type)))
+
+(defun curchg-change-cursor-to-idle-type ()
+ "Change the cursor to `curchg-idle-cursor-type' when Emacs is idle."
+ (let ((type (cdr (assoc 'cursor-type (frame-parameters)))))
+ (unless (eq type curchg-idle-cursor-type)
+ (setq curchg-last-cursor-type type)
+ (curchg-set-cursor-type curchg-idle-cursor-type))))
+
+(defun curchg-change-cursor-to-idle-type-off ()
+ "Turn off changing the cursor to `curchg-idle-cursor-type' when idle."
+ (when curchg-last-cursor-type (curchg-set-cursor-type curchg-last-cursor-type)))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(provide 'cursor-chg)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; cursor-chg.el ends here
diff --git a/emacs.d/lisp/delphi-mode-ench.el b/emacs.d/lisp/delphi-mode-ench.el
index 04e017a..fcbb3ae 100644
--- a/emacs.d/lisp/delphi-mode-ench.el
+++ b/emacs.d/lisp/delphi-mode-ench.el
@@ -1,4 +1,10 @@
;;; delphi-mode-ench.el
+(require 'compile)
+(pushnew '("^\\([-a-zA-Z0-9\\.\\/_~]+\\)(\\([0-9]+\\),\\([0-9]+\\))\s\\([Ff]atal:\\|[Nn]ote:\\|[Ww]arning:\\|[Ee]rror:\\)\s\\(.*$\\)" 1 2 3)
+ compilation-error-regexp-alist)
+
+(setq auto-mode-alist (cons '("\\.pas" . delphi-mode) auto-mode-alist))
+
(setq delphi-unit-sections
'(implementation program library package))
@@ -55,7 +61,7 @@
(if pos (goto-char pos))
(re-search-forward "\\(begin\\|implementation\\)" nil t)
(let ((match (match-string-no-properties 1)))
- (if (or (equal match "implementation") (equal match "end")) 't 'nil)))))
+ (if (equal match "implementation") 't 'nil)))))
(defun delphi-in-class-definition (&optional pos)
(if pos (goto-char pos))
diff --git a/emacs.d/lisp/etags-table.el b/emacs.d/lisp/etags-table.el
new file mode 100644
index 0000000..5c33c8c
--- /dev/null
+++ b/emacs.d/lisp/etags-table.el
@@ -0,0 +1,157 @@
+;;; etags-table.el --- Set tags table(s) based on current file
+
+;; Copyright (C) 2008 Scott Frazer
+
+;; Author: Scott Frazer <frazer.scott@gmail.com>
+;; Maintainer: Scott Frazer <frazer.scott@gmail.com>
+;; Created: 28 Oct 2008
+;; Version: 1.1
+;; Keywords: etags tags tag
+
+;; This file is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; This file is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING. If not, write to
+;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
+
+;;; Commentary:
+
+;; This extension sets the tags table(s) based on the current file.
+;; `etags-table-alist' is a list of lists, where the car of each sublist is
+;; compared to the current filename. If it matches, all the rest of the list
+;; elements are put on `tags-table-list'. If `etags-table-search-up-depth' is
+;; an integer, the file path will be searched upwards for a tags file. If one
+;; is found, it will be added to the tags table list; this is actually done
+;; first so the local TAGS file is at the head of the list.
+;;
+;; When you switch files and do something tag-related, the tags table list is
+;; automatically recomputed.
+
+;;; Change log:
+;;
+;; 27 Mar 2009 -- v1.1
+;; Add ability to use backreferences in etags-table-alist
+;; Change files to true names when adding to table
+;; Fix the way parent directories are found
+;;
+;; 28 Oct 2008 -- v1.0
+;; Initial release
+
+;;; Code:
+
+(require 'custom)
+(require 'etags)
+
+;;;###autoload
+(defgroup etags-table nil
+ "*etags table"
+ :group 'etags)
+
+;;;###autoload
+(defcustom etags-table-alist nil
+ "*Map filename to tag file(s)
+
+Example:
+
+(setq etags-table-alist
+ (list
+ \'(\"/home/me/Projects/foo/.*\\\\.[ch]$\" \"/home/me/Projects/lib1/TAGS\" \"/home/me/Projects/lib2/TAGS\")
+ \'(\"/home/me/Projects/bar/.*\\\\.py$\" \"/home/me/Projects/python/common/TAGS\")
+ \'(\".*\\\\.[ch]$\" \"/usr/local/include/TAGS\")
+ ))
+
+A file named, for example, \"/home/me/Projects/foo/main.c\" would set the
+`tags-table-list' to a list of:
+
+\"/home/me/Projects/lib1/TAGS\"
+\"/home/me/Projects/lib2/TAGS\"
+\"/usr/local/include/TAGS\"
+
+and possibly a local tags file at the head of the list if `etags-table-search-up-depth'
+is non-nil. You can use \\&, \\1, etc. in the tag file names to substitute pieces
+captured with \\(\\) in the key.
+"
+ :group 'etags-table
+ :type 'alist)
+
+;;;###autoload
+(defcustom etags-table-search-up-depth nil
+ "*Max depth to search up for a tags file. nil means don't search."
+ :group 'etags-table
+ :type 'integer)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defvar etags-table-last-table-list nil
+ "Save the last table list so it can be reused if a new one is not found")
+
+(defun etags-table-build-table-list (filename)
+ "Build tags table list based on a filename"
+ (let (tables)
+
+ ;; Search up
+ (when etags-table-search-up-depth
+ (let ((depth etags-table-search-up-depth)
+ (dir (file-name-directory filename)))
+ (while (and (>= depth 0) dir)
+ (when (file-exists-p (concat dir "TAGS"))
+ (setq tables (list (concat dir "TAGS")))
+ (setq depth 0))
+ (setq dir (file-name-directory (directory-file-name dir)))
+ (setq depth (1- depth)))))
+
+ ;; Go through mapping alist
+ (mapc (lambda (mapping)
+ (let ((key (car mapping))
+ (tag-files (cdr mapping)))
+ (when (string-match key filename)
+ (mapc (lambda (tag-file)
+ (add-to-list 'tables (file-truename (replace-match tag-file t nil filename)) t))
+ tag-files))))
+ etags-table-alist)
+
+ ;; Return result or the original list
+ (setq etags-table-last-table-list
+ (or tables tags-table-list etags-table-last-table-list))))
+
+(defun etags-table-recompute ()
+ (when (and (or etags-table-alist etags-table-search-up-depth) (buffer-file-name))
+ (setq tags-table-list (etags-table-build-table-list (buffer-file-name)))))
+
+(defadvice visit-tags-table-buffer (before etags-table-recompute activate)
+ "Recompute `tags-table-list'"
+ (etags-table-recompute))
+
+(defadvice tags-completion-table (before etags-table-clear-completion-table activate)
+ "Clear the completion table (maybe)"
+ (etags-table-recompute)
+ (unless (equal tags-table-computed-list-for (mapcar 'tags-expand-table-name tags-table-list))
+ (etags-table-clear-completion-table)))
+
+(defun etags-table-clear-completion-table ()
+ "Clear the tags completion table"
+ (interactive)
+ (setq tags-completion-table nil))
+
+(eval-after-load "etags-select"
+ '(progn
+ (defadvice etags-select-get-tag-files (before etags-table-recompute activate)
+ "Recompute `tags-table-list'"
+ (etags-table-recompute))
+ (defadvice etags-select-find-tag (before etags-table-clear-completion-table activate)
+ "Clear the completion table (maybe)"
+ (etags-table-recompute)
+ (unless (equal tags-table-computed-list-for (mapcar 'tags-expand-table-name tags-table-list))
+ (setq tags-completion-table nil)))))
+
+(provide 'etags-table)
+;;; etags-table.el ends here
diff --git a/emacs.d/snippets/delphi-mode/constructor, destructor.yasnippet b/emacs.d/snippets/delphi-mode/constructor, destructor.yasnippet
index 33a52ed..114f30e 100644
--- a/emacs.d/snippets/delphi-mode/constructor, destructor.yasnippet
+++ b/emacs.d/snippets/delphi-mode/constructor, destructor.yasnippet
@@ -6,4 +6,4 @@
# --
constructor Create(${1:});
destructor Destroy; override;
-$0 \ No newline at end of file
+ $0$> \ No newline at end of file
diff --git a/emacs.d/snippets/delphi-mode/dbg.yasnippet b/emacs.d/snippets/delphi-mode/dbg.yasnippet
new file mode 100644
index 0000000..66fc15f
--- /dev/null
+++ b/emacs.d/snippets/delphi-mode/dbg.yasnippet
@@ -0,0 +1,6 @@
+# -*- mode: snippet -*-
+# contributor : Alexander Sulfrian <alexander@sulfrian.net>
+# name: dbg
+# --
+DebugWriteln($1);
+ $0$> \ No newline at end of file
diff --git a/emacs.d/snippets/delphi-mode/func-prototype.yasnippet b/emacs.d/snippets/delphi-mode/func-prototype.yasnippet
index cae55d7..2344f07 100644
--- a/emacs.d/snippets/delphi-mode/func-prototype.yasnippet
+++ b/emacs.d/snippets/delphi-mode/func-prototype.yasnippet
@@ -4,5 +4,5 @@
# key: func
# condition: (delphi-in-class-definition)
# --
-function ${1:Name$(capitalize text)}($2): $3;
-$0 \ No newline at end of file
+function ${1:Name$(upcase-initials text)}($2): $3;
+ $0$> \ No newline at end of file
diff --git a/emacs.d/snippets/delphi-mode/func.yasnippet b/emacs.d/snippets/delphi-mode/func.yasnippet
index a42a598..31fe413 100644
--- a/emacs.d/snippets/delphi-mode/func.yasnippet
+++ b/emacs.d/snippets/delphi-mode/func.yasnippet
@@ -4,7 +4,7 @@
# key: func
# condition: (not (delphi-in-class-definition))
# --
-function ${1:$$(yas/choose-value (let (value) (dolist (element (delphi-get-classes) value) (setq value (cons (concat element ".") value)))))}${2:Name$(capitalize text)}($3): $4;
+function ${1:$$(yas/choose-value (let (value) (dolist (element (delphi-get-classes) value) (setq value (cons (concat element ".") value)))))}${2:Name$(upcase-initials text)}($3): $4;
begin
$0
end; \ No newline at end of file
diff --git a/emacs.d/snippets/delphi-mode/procedure-prototype.yasnippet b/emacs.d/snippets/delphi-mode/procedure-prototype.yasnippet
index 09927ac..3c1d8cb 100644
--- a/emacs.d/snippets/delphi-mode/procedure-prototype.yasnippet
+++ b/emacs.d/snippets/delphi-mode/procedure-prototype.yasnippet
@@ -4,5 +4,5 @@
# key: proc
# condition: (delphi-in-class-definition)
# --
-procedure ${1:Name$(capitalize text)}($2);
-$0 \ No newline at end of file
+procedure ${1:Name$(upcase-initials text)}($2);
+ $0$> \ No newline at end of file
diff --git a/emacs.d/snippets/delphi-mode/procedure.yasnippet b/emacs.d/snippets/delphi-mode/procedure.yasnippet
index 9e3a08e..6039ad8 100644
--- a/emacs.d/snippets/delphi-mode/procedure.yasnippet
+++ b/emacs.d/snippets/delphi-mode/procedure.yasnippet
@@ -4,7 +4,7 @@
# key: proc
# condition: (not (delphi-in-class-definition))
# --
-procedure ${1:$$(yas/choose-value (let (value) (dolist (element (delphi-get-classes) value) (setq value (cons (concat element ".") value)))))}${2:Name$(capitalize text)}($3);
+procedure ${1:$$(yas/choose-value (let (value) (dolist (element (delphi-get-classes) value) (setq value (cons (concat element ".") value)))))}${2:Name$(upcase-initials text)}($3);
begin
$0
end; \ No newline at end of file
diff --git a/emacs.d/templates/TEMPLATE.hpp.tpl b/emacs.d/templates/TEMPLATE.hpp.tpl
new file mode 100644
index 0000000..02fc06f
--- /dev/null
+++ b/emacs.d/templates/TEMPLATE.hpp.tpl
@@ -0,0 +1,32 @@
+/*
+ * UltraStar Deluxe - Karaoke Game
+ *
+ * UltraStar Deluxe is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ */
+
+#ifndef (>>>FILE_UPCASE<<<)_HPP
+#define (>>>FILE_UPCASE<<<)_HPP
+
+(>>>POINT<<<)
+
+#endif
diff --git a/emacs.d/update-etags b/emacs.d/update-etags
new file mode 100755
index 0000000..88cc4f4
--- /dev/null
+++ b/emacs.d/update-etags
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+LANGUAGE=$1
+ACCEPTED_EXTENSION="$(echo $2|sed 's/|/ /g')"
+BASE_DIR=$3
+FILE_EXT=${4##*.}
+
+echo "test1" | logger
+
+[[ -z ${FILE_EXT} ]] && exit
+
+processing=
+for extension in $ACCEPTED_EXTENSION;do
+ [[ $extension == $FILE_EXT ]] && processing=true
+done
+
+echo "test" | logger
+find ${BASE_DIR} ! -wholename './.git/*' -a ! -wholename './.svn/*' -a ! -name '*.pyc' -a ! -name '*~' -a ! -name '*#' -a ! -name '*.o' -a ! -name '*.ppu' -print0 | xargs -0 etags -o ${BASE_DIR}/TAGS 2>/dev/null >/dev/null
diff --git a/emacs.elc b/emacs.elc
index 5dfd8e4..85f6629 100644
--- a/emacs.elc
+++ b/emacs.elc
Binary files differ