3029359a85790cd1b18ae2784c62a3f069fa538d
[syinit] / 02-keys-sy.el
1 ;; 02-keys-sy.el --- Keybindings   -*- Emacs-Lisp -*-
2
3 ;; Copyright (C) 2007 - 2012 Steve Youngs
4
5 ;;     Author: Steve Youngs <steve@sxemacs.org>
6 ;; Maintainer: Steve Youngs <steve@sxemacs.org>
7 ;;    Created: <2007-12-02>
8 ;; Time-stamp: <Sunday Jun 10, 2012 10:53:27 steve>
9 ;;   Download: <http://bastard.steveyoungs.com/~steve/SXEmacs/inits/>
10 ;;   HTMLised: <http://bastard.steveyoungs.com/~steve/SXEmacs/htmlinits/02-keys-sy.html>
11 ;;   Git Repo: git clone http://git.sxemacs.org/syinit
12 ;;   Keywords: init, compile
13
14 ;; This file is part of SYinit
15
16 ;; Redistribution and use in source and binary forms, with or without
17 ;; modification, are permitted provided that the following conditions
18 ;; are met:
19 ;;
20 ;; 1. Redistributions of source code must retain the above copyright
21 ;;    notice, this list of conditions and the following disclaimer.
22 ;;
23 ;; 2. Redistributions in binary form must reproduce the above copyright
24 ;;    notice, this list of conditions and the following disclaimer in the
25 ;;    documentation and/or other materials provided with the distribution.
26 ;;
27 ;; 3. Neither the name of the author nor the names of any contributors
28 ;;    may be used to endorse or promote products derived from this
29 ;;    software without specific prior written permission.
30 ;;
31 ;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
32 ;; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
33 ;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
34 ;; DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
35 ;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
36 ;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
37 ;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
38 ;; BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
39 ;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
40 ;; OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
41 ;; IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42
43 ;;; Commentary:
44 ;;
45 ;;   Sets up my keybindings
46 ;;
47 ;;   BTW, there are a number of different ways to actually set a
48 ;;   keybinding in emacs and I honestly could not tell you which way
49 ;;   is best.  I don't think any one way is really any better than
50 ;;   any other.  I've used most (all?) of them here in this file.
51 ;;   Whichever format you like is the right one to use. :-)
52
53 ;;; Credits:
54 ;;
55 ;;   The HTML version of this file was created with Hrvoje Niksic's
56 ;;   htmlize.el which is part of the XEmacs "text-modes" package.
57 ;;
58
59 ;;; Todo:
60 ;;
61 ;;     
62
63 ;;; Code:
64
65 ;:*=======================
66 ;:* Global key bindings
67 (global-set-key "\C-xw" 'what-line)
68 (global-set-key [f2] 'undo)
69 (global-set-key [f3] 'find-file)
70 (global-set-key [(super tab)] 'lisp-complete-symbol)
71 (global-set-key [(meta f3)] 'view-file)
72 (global-set-key [f5] "\M-w")
73 (global-set-key [f6] "\C-y")
74 (global-set-key [f7] 'save-buffer)
75 (global-set-key [f8] 'start-kbd-macro)
76 (global-set-key [f9] 'end-kbd-macro)
77 (global-set-key [(control f8)] 'call-last-kbd-macro)
78 (global-set-key [(control f5)] 'sy-extent-kill-save)
79 (global-set-key [XF86Copy] #'copy-primary-selection)
80 (global-set-key [XF86Cut] #'kill-primary-selection)
81 (global-set-key [XF86Paste] #'yank-clipboard-selection)
82
83 ;:*=======================
84 ;:* compose-key tô t¥pé fünky £ïttlê chãrs
85 (require 'x-compose)
86 (global-set-key "\C-cm" compose-map)
87
88 ;:*=======================
89 ;:* cursor into first line with C-pageup
90 (define-key global-map '(control prior) 'beginning-of-buffer)
91 (define-key global-map '(control next) 'end-of-buffer)
92
93 ;:*=======================
94 ;:* Enable menubar accelerators (double-wow!)
95 (setq menu-accelerator-enabled 'menu-fallback)
96 (setq menu-accelerator-modifiers '(super))
97 (setq menu-accelerator-prefix nil)
98 (define-key global-map [f10] 'accelerate-menu)
99
100 ;:*=======================
101 ;:* Popup window with buffer list ; from XEmacs FAQ (2.61)
102 (defun cw-build-buffers ()
103   "Popup buffer menu."
104   (interactive "@")
105   (run-hooks 'activate-menubar-hook)
106   (popup-menu (car (find-menu-item current-menubar '("Buffers")))))
107 (global-set-key '(control !) 'cw-build-buffers)
108
109 ;:*=======================
110 ;:* keymapping to resize frames
111 (define-key global-map [(control x) (up)] #'shrink-window)
112 (define-key global-map [(control x) (down)]  #'enlarge-window)
113 (define-key global-map [(control x) (left)] #'shrink-window-horizontally)
114 (define-key global-map [(control x) (right)]  #'enlarge-window-horizontally)
115
116 ;:*=======================
117 ;:* bind key to kill-whole-line
118 (global-set-key '(control ,) 'kill-entire-line)
119
120 ;:*=======================
121 ;:* Set C-x C-b to use ibuffer
122 (define-key global-map [(control x) (control b)] 'ibuffer)
123
124 ;:*=======================
125 ;:* OK, so just who the hell is sending those emails
126 (define-key global-map [f12] 'from)
127
128 ;:*=======================
129 ;:* Bind the Euro to a key
130 (define-key global-map "\C-ce"
131   (lambda () 
132     (interactive) 
133     (insert (make-char 'latin-iso8859-15 #x24))))
134
135 ;:*=======================
136 ;:* Toggle in/out of eshell
137 (global-set-key (kbd "C-c s") 'eshell-toggle)
138
139 ;:*=======================
140 ;:* Extra Mouse buttons (wheel etc)
141 ;;
142 ;;  A little bragging never hurts... SXEmacs allows you to bind up to
143 ;;  32 mouse buttons.  I'm not sure about GNU/Emacs, but XEmacs only
144 ;;  lets you bind 10 (or is it 12?).  OK, I've never seen a rat that
145 ;;  had 32 buttons, but you never know what these gamer kiddies will
146 ;;  want one day. :-)
147 (require 'mwheel)
148 (define-key global-map [(button4)] 'mwheel-scroll)
149 (define-key global-map [(button5)] 'mwheel-scroll)
150 (define-key global-map [(shift button4)] 'mwheel-scroll)
151 (define-key global-map [(shift button5)] 'mwheel-scroll)
152 (define-key global-map [(button9)] 'beginning-of-buffer)
153 (define-key global-map [(button8)] 'end-of-buffer)
154 (define-key global-map [(button10)] 'recenter)
155
156 ;:*=======================
157 ;:* Numeric keypad
158 (define-key key-translation-map [kp-divide]     [?/])
159 (define-key key-translation-map [kp-multiply]   [?*])
160 (define-key key-translation-map [kp-subtract]   [?-])
161 (define-key key-translation-map [kp-add]        [?+])
162 (define-key key-translation-map [kp-enter]     [?\r])
163 (define-key key-translation-map [kp-decimal]    [?.])
164 (define-key key-translation-map [kp-begin]   [begin])
165 (define-key key-translation-map [kp-home]     [home])
166 (define-key key-translation-map [kp-end]       [end])
167 (define-key key-translation-map [kp-next]     [next])
168 (define-key key-translation-map [kp-prior]   [prior])
169 (define-key key-translation-map [kp-left]     [left])
170 (define-key key-translation-map [kp-right]   [right])
171 (define-key key-translation-map [kp-up]         [up])
172 (define-key key-translation-map [kp-down]     [down])
173 (define-key key-translation-map [kp-insert] [insert])
174 (define-key key-translation-map [kp-delete] [delete])
175 (define-key key-translation-map [kp-0]          [?0])
176 (define-key key-translation-map [kp-1]          [?1])
177 (define-key key-translation-map [kp-2]          [?2])
178 (define-key key-translation-map [kp-3]          [?3])
179 (define-key key-translation-map [kp-4]          [?4])
180 (define-key key-translation-map [kp-5]          [?5])
181 (define-key key-translation-map [kp-6]          [?6])
182 (define-key key-translation-map [kp-7]          [?7])
183 (define-key key-translation-map [kp-8]          [?8])
184 (define-key key-translation-map [kp-9]          [?9])
185 ;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
186 (message "Key maps set successfully")