;; -*- emacs-lisp -*- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; $Id: files.el,v 1.14 2006/01/02 22:06:01 ole Exp $ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;_* Files Keys ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defvar files-keymap (make-sparse-keymap "Files") "Keymap used to globally access file related functions") (define-key mode-specific-map [?f] files-keymap) (define-key files-keymap [??] 'describe-prefix-bindings) (define-key files-keymap [?f] 'find-file-at-point) (define-key files-keymap [?d] 'find-dired) (define-key files-keymap [?D] 'find-grep-dired) (define-key files-keymap [?s] 'grep-find) (define-key files-keymap [?l] 'find-library) (define-key files-keymap [?g] 'igrep) (define-key files-keymap [?G] 'igrep-find) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;_* File handling functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (eval-after-load "dired" '(progn (require 'dired-x) (require 'dired-sort-map) (autoload 'wdired-change-to-wdired-mode "wdired") (add-hook 'dired-load-hook '(lambda () (define-key dired-mode-map "r" 'wdired-change-to-wdired-mode) (define-key dired-mode-map [menu-bar immediate wdired-change-to-wdired-mode] '("Edit File Names" . wdired-change-to-wdired-mode)))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Load crypt, which is a package for automatically decoding and reencoding ;;; files by various methods - for example, you can visit a .Z or .gz file, ;;; edit it, and have it automatically re-compressed when you save it again. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (require 'crypt++) (setq crypt-encryption-type 'gpg crypt-confirm-password t ; make sure new passwords are correct crypt-encryption-file-extension "\\(Secure\\)$\\|\\(\\.enc\\|\\.crypt\\|\\.pgp\\|\\.gpg\\)$") (crypt-rebuild-tables) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;_* Utility Functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Florian Weimer in <877lhs476b.fsf@deneb.cygnus.argh.org> (defun global-change-directory (from to) "Change directory of all buffers with default-directory FROM to TO." (interactive "DGlobally change directory from: \nDTo: ") (let ((bufs (buffer-list)) (from (expand-file-name from))) (while bufs (with-current-buffer (car bufs) (when (equal from (expand-file-name default-directory)) (setq default-directory to))) (setq bufs (cdr bufs))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;_* Diff ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (autoload 'diff-mode "diff-mode" "Diff major mode" t) (add-to-list 'auto-mode-alist '("\\.\\(diffs?\\|patch\\|rej\\)\\'" . diff-mode)) (eval-after-load "diff" '(progn (require 'diff+) (setq diff-switches "-u") (setq diff-command "diff") (add-hook 'diff-mode-hook (lambda () (font-lock-mode 1))) )) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;_* Shell-Command ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq-default start-command "") (setq dm-term-command "xterm") ;; ^M weglassen (add-hook 'comint-output-filter-functions 'comint-strip-ctrl-m) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;_* Grep ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (require 'grep) (require 'igrep) (setq grep-find-use-xargs 'gnu grep-command "grep -ne ") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Search & replace ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (require 'ireplace) (defun isearch-occur () "Invoke `occur' from within isearch." (interactive) (let ((case-fold-search isearch-case-fold-search)) (occur (if isearch-regexp isearch-string (regexp-quote isearch-string))))) (define-key isearch-mode-map (kbd "C-o") 'isearch-occur) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;_* List Lines In Buffer(s) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (require 'color-occur) (require 'color-moccur) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;_* Make dirs from minibuffer ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (add-hook 'minibuffer-setup-hook (lambda () (when minibuffer-completing-file-name (local-set-key [(control return)] 'minibuffer-make-directory)))) (defun minibuffer-make-directory () "*Create the directory named from the minibuffer contents. Also create any nonexistent parent directories." (interactive) (let* ((file (minibuffer-contents)) (directory (if (equal (file-name-as-directory file) file) file (file-name-directory file)))) (make-directory directory t))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;_* Buffer Show ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (require 'bs) (global-set-key (kbd "C-x C-b") 'bs-show) (add-to-list 'bs-configurations '("channels" nil nil "^[^#]" nil nil)) (add-to-list 'bs-configurations '("targets" nil nil nil (lambda (buf) (with-current-buffer buf (not (erc-default-target)))) nil)) (add-to-list 'bs-configurations '("dired" nil nil nil (lambda (buf) (with-current-buffer buf (not (eq major-mode 'dired-mode)))) nil)) (add-to-list 'bs-configurations '("java" nil nil nil (lambda (buf) (with-current-buffer buf (not (eq major-mode 'jde-mode)))) nil)) (add-to-list 'bs-configurations '("xml" nil nil nil (lambda (buf) (with-current-buffer buf (not (eq major-mode 'xml-mode)))) nil)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;:_* Killing Buffers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (if (fboundp 'switch-to-other-buffer) (global-set-key [f2] 'switch-to-other-buffer) (global-set-key [f2] "\C-xb\C-m") ) (global-set-key [f12] 'kill-this-buffer) (global-set-key [(control f12)] 'kill-buffer-and-window) ;; This nicely parallels M-*, which pops the tag stack. See below for ;; how to set up tags. (global-set-key [(control *)] 'find-tag-at-point) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;_* Conversions and auto insert at file open time ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (autoload 'no-word "no-word" "word to txt") (add-to-list 'auto-mode-alist '("\\.doc\\'" . no-word)) (setq auto-insert-query nil auto-insert-directory (expand-file-name "templates/" emacs-init-dir))