;; -*- mode: Emacs-Lisp -*- ;;; ;;; (add-to-list 'load-path (expand-file-name "~/elisp")) (if (< emacs-major-version 22) (progn (add-to-list 'load-path (expand-file-name "~/elisp21/")) (add-to-list 'load-path (expand-file-name "~/elisp21/org") (require 'mycompat) (autoload 'rcirc "rcirc" "" t) (autoload 'org-mode "org" "" t) (autoload 'org-diary "org" "Diary entries from Org mode") (autoload 'org-agenda "org" "Multi-file agenda from Org mode" t) (autoload 'org-store-link "org" "Store a link to the current location" t) (global-font-lock-mode 1)) (setq inhibit-splash-screen t) (savehist-mode t) )) (when window-system (tool-bar-mode -1) (scroll-bar-mode -1) ) (menu-bar-mode -1) (column-number-mode 1) (setq truncate-partial-width-windows nil) (setq visible-bell t) (which-function-mode 1) (require 'ido) (ido-mode 1) (global-set-key (kbd "M-g") 'goto-line) (global-set-key (kbd "M-;") 'comment-or-uncomment-region) (global-set-key (kbd "") 'compile) (require 'recentf) (recentf-mode 1) (require 'cl) (defun recentf-interactive-complete () "find a file in the recently open file using ido for completion" (interactive) (let* ((all-files recentf-list) (file-assoc-list (mapcar (lambda (x) (cons (file-name-nondirectory x) x)) all-files)) (filename-list (remove-duplicates (mapcar 'car file-assoc-list) :test 'string=)) (ido-make-buffer-list-hook (lambda () (setq ido-temp-list filename-list))) (filename (ido-read-buffer "Find Recent File: ")) (result-list (delq nil (mapcar (lambda (x) (if (string= (car x) filename) (cdr x))) file-assoc-list))) (result-length (length result-list))) (find-file (cond ((= result-length 0) filename) ((= result-length 1) (car result-list)) ( t (let ( (ido-make-buffer-list-hook (lambda () (setq ido-temp-list result-list)))) (ido-read-buffer (format "%d matches:" result-length)))) )))) (global-set-key (kbd "C-x C-r") 'recentf-interactive-complete) ;;comint (ansi-color-for-comint-mode-on) ;;org-mode ;;;; *************** c-mode ********************** (add-to-list 'auto-mode-alist '("\\.h$" . c++-mode)) (eval-after-load 'cc-vars (progn (require 'dabbrev) (defun th-complete-or-indent (arg) "If preceding character is a word character and the following character is a whitespace character, then `dabbrev-expand', else indent according to mode." (interactive "*P") (cond ((and (= (char-syntax (preceding-char)) ?w) (looking-at (rx (or word-end (any ".,;:#=?()[]{}"))))) (require 'sort) (let ((case-fold-search t)) (dabbrev-expand arg))) (t (indent-according-to-mode)))) (defun switch-c-to-h () "Switch fromm *. to *. and vice versa" (interactive) (when (string-match "\\(.*\\)\\(\\..*\\)\\'" buffer-file-name) (let ((other-file (file-expand-wildcards (concat (match-string 1 buffer-file-name) (if (string-match "\\.c\\(c\\|pp\\|xx\\|\\+\\+\\)?\\|\\.CC?\\'" (match-string 2 buffer-file-name)) ".[hH]*" ".[cC]*")) t))) (if other-file (find-file (car other-file)))))) (add-hook 'c-mode-common-hook (lambda () (local-set-key (kbd "TAB") 'th-complete-or-indent) (local-set-key (kbd "") 'switch-c-to-h) )) )) ;; ***************** org-mode **************************** (add-to-list 'auto-mode-alist '("\\.org$" . org-mode)) (define-key global-map "\C-cl" 'org-store-link) (define-key global-map "\C-ca" 'org-agenda) ;; **************** rcirc ***************************** (eval-after-load 'rcirc-mode (setq rcirc-buffer-maximum-lines 500)) ;;erc (eval-after-load 'erc-mode (progn (require 'erc-truncate) (erc-truncate-mode 1) (defun erc-cmd-FLUSH (&rest ignore) "Erase the current buffer." (let ((inhibit-read-only t)) (erase-buffer) (message "Flushed contents of channel") t)) (require 'erc-track) (add-to-list 'erc-track-exclude-types "JOIN") (add-to-list 'erc-track-exclude-types "PART") (add-to-list 'erc-track-exclude-types "QUIT") (add-to-list 'erc-track-exclude-types "MODE") (require 'erc-join) (setq erc-autojoin-channels-alist (quote ((".*freenode.*" "#emacsfr" "#sed" "#bash" "#ksh" "#emacs")))))) (put 'erase-buffer 'disabled nil) (setq woman-use-own-frame nil) ;;***************** tag stuff **************************** (eval-after-load 'find-tag (progn (defun find-tags-file-recursive (&optional tag-file-name) "recursively searches each parent directory for a file named `TAGS' and returns the path to that file or nil if a tags file is not found. Returns nil if the buffer is not visiting a file" (let ((tag-file-name (or tag-file-name "TAGS")) (current-dir (file-name-directory (buffer-file-name))) found) (while (not (or (equal current-dir "/") (setq found (if (file-exists-p (concat current-dir tag-file-name)) (concat current-dir tag-file-name))))) (setq current-dir (file-name-directory (substring current-dir 0 -1)))) (if found found (message "no tags file found") nil))) (defun set-tags-file-name () (unless (and tags-file-name (let ((file-dir (file-name-directory (buffer-file-name))) (tag-file-dir (file-name-directory tags-file-name))) (and (> (length file-dir) (length tag-file-dir)) (equal (substring file-dir 0 (length tag-file-dir)) tag-file-dir)))) (setq tags-file-name (find-tags-file-recursive)))) (defadvice find-tag (before set-tags-file-name-before (tagname &optional next-p regexp-p)) "search for a tag file in the parent directories" (set-tags-file-name)) (ad-activate 'find-tag) (setq tags-add-tables nil))) (custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(ange-ftp-gateway-host "leon") '(ange-ftp-gateway-program "/usr/bin/rsh") '(ange-ftp-local-host-regexp ".*.intranet.gr") '(ange-ftp-smart-gateway t) '(column-number-mode t) '(menu-bar-mode t)) (put 'scroll-left 'disabled nil)