comparison lisp/erc/erc-viper.el @ 68451:fc745b05e928

Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22 Creator: Michael Olson <mwolson@gnu.org> Install ERC.
author Miles Bader <miles@gnu.org>
date Sun, 29 Jan 2006 13:08:58 +0000
parents
children
comparison
equal deleted inserted replaced
68450:a3ba4ef5d590 68451:fc745b05e928
1 ;;; erc-viper.el --- Viper compatibility hacks for ERC
2
3 ;; Copyright (C) 2005 Free Software Foundation, Inc.
4
5 ;; Author: Edward O'Connor <ted@oconnor.cx>
6 ;; Keywords: emulation
7
8 ;; This file is part of GNU Emacs.
9
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
14
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 ;; Boston, MA 02110-1301, USA.
24
25 ;;; Commentary:
26
27 ;; Viper is a VI emulation mode for Emacs. ERC and Viper don't quite get
28 ;; along by default; the code in this file fixes that. A simple
29 ;; (require 'erc-viper)
30 ;; in your ~/.ercrc.el should be all it takes for you to use ERC and
31 ;; Viper together happily.
32
33 ;;; Code:
34
35 (require 'viper)
36
37 ;; We need this for `erc-mode-hook' and `erc-buffer-list'. Perhaps it
38 ;; would be better to use an `eval-after-load', so that there could be
39 ;; some autodetection / loading of this file from within erc.el?
40 (require 'erc)
41
42 ;; Fix RET in ERC buffers, by telling Viper to pass RET through to the
43 ;; normal keymap.
44
45 (add-to-list 'viper-major-mode-modifier-list
46 '(erc-mode insert-state viper-comint-mode-modifier-map))
47 (add-to-list 'viper-major-mode-modifier-list
48 '(erc-mode vi-state viper-comint-mode-modifier-map))
49
50 (viper-apply-major-mode-modifiers)
51
52 ;; Ensure that ERC buffers come up in insert state.
53 (add-to-list 'viper-insert-state-mode-list 'erc-mode)
54
55 ;; Fix various local variables in Viper.
56 (add-hook 'erc-mode-hook 'viper-comint-mode-hook)
57
58 ;; Fix ERC buffers that already exist (buffers in which `erc-mode-hook'
59 ;; has already been run).
60 (mapc (lambda (buf)
61 (with-current-buffer buf
62 (viper-comint-mode-hook)
63 ;; If there *is* a final newline in this buffer, delete it, as
64 ;; it interferes with ERC /-commands.
65 (let ((last (1- (point-max))))
66 (when (eq (char-after last) ?\n)
67 (goto-char last)
68 (delete-char 1)))))
69 (erc-buffer-list))
70
71 (provide 'erc-viper)
72
73 ;; arch-tag: 659fa645-e9ad-428c-ad53-8304d9f900f6
74 ;;; erc-viper.el ends here