annotate lisp/utils/delbackspace.el @ 50:ee648375d8d6 r19-16b91

Import from CVS: tag r19-16b91
author cvs
date Mon, 13 Aug 2007 08:56:41 +0200
parents 49a24b4fd526
children 131b0175ea99
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; delbackspace.el --- rebind backspace and delete to be correct
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1994, 1995 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Copyright (C) 1996 Ben Wing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Author: Tibor Polgar??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Maintainer: Ben Wing <wing@666.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; Keywords: terminals
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;;; Synched up with: Not in FSF.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;; #### should port FSF pc-bindings.el and nuke this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; this is a hack that will have to do until function-key-map is implemented
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 (defconst delbackspace-backspace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 (if (not (eq 'tty (device-type (selected-device))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 'backspace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 "\C-h"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 (global-unset-key delbackspace-backspace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 (local-unset-key delbackspace-backspace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 (global-unset-key [(control delete)])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 (global-unset-key [(meta delete)])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 (global-unset-key [(meta shift delete)])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 (global-unset-key [(control backspace)])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 (global-unset-key [(meta backspace)])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 (global-unset-key [(meta shift backspace)])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 (if (eq 'tty (device-type (selected-device)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 (setq help-char '(meta h))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (define-key global-map "\M-h" 'help-command)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 (define-key key-translation-map 'delete 'delbackspace-compute-delete-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (define-key global-map 'intercepted_delete 'delete-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (defun delbackspace-compute-delete-value (prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (let ((orig-binding (key-binding 'delete)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (if (memq orig-binding '(delete-backward-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 backward-delete-char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 backward-delete-char-untabify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 c-electric-delete
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 c++-electric-delete
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 cperl-electric-backspace))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 [intercepted_delete]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 [delete])))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (define-key key-translation-map delbackspace-backspace [delete])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;; (ctrl) backspace to beginning of line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (global-set-key [(control backspace)] 'backward-kill-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;; (meta) backspace word before cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (define-key key-translation-map [(meta backspace)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 [intercepted_meta_backspace])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (define-key global-map 'intercepted_meta_backspace 'backward-kill-word)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;; (alt) backspace sentence before cursor; backspace sexp before cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;; in language modes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (define-key key-translation-map [(alt backspace)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 [intercepted_alt_backspace])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (define-key global-map 'intercepted_alt_backspace 'backward-kill-sentence)
10
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 0
diff changeset
63 (if (boundp 'c-mode-map)
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 0
diff changeset
64 (mapcar (lambda (map)
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 0
diff changeset
65 (define-key map [(alt backspace)] 'backward-kill-sexp))
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 0
diff changeset
66 (list
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 0
diff changeset
67 c-mode-map c++-mode-map objc-mode-map java-mode-map
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 0
diff changeset
68 emacs-lisp-mode-map lisp-mode-map minibuffer-local-map))
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 0
diff changeset
69 (setq after-load-alist
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 0
diff changeset
70 (append '(("cc-mode"
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 0
diff changeset
71 (mapcar (lambda (map)
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 0
diff changeset
72 (define-key map
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 0
diff changeset
73 [(alt backspace)]
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 0
diff changeset
74 'backward-kill-sexp)
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 0
diff changeset
75 (define-key map [(alt delete)] 'kill-sexp))
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 0
diff changeset
76 (list
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 0
diff changeset
77 c-mode-map
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 0
diff changeset
78 c++-mode-map
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 0
diff changeset
79 objc-mode-map
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 0
diff changeset
80 java-mode-map))))
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 0
diff changeset
81 after-load-alist)))
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 0
diff changeset
82
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;; (meta shift) backspace paragraph before cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (global-set-key [(meta shift backspace)] 'backward-kill-paragraph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;; (alt) delete rest of line (erase EOF)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (global-set-key [(control delete)] 'kill-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;; (meta) delete word before cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (define-key key-translation-map [(meta delete)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 [intercepted_meta_delete])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (define-key global-map 'intercepted_meta_delete 'kill-word)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;; (alt) delete sentence forward; delete sexp forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;; in language modes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (define-key key-translation-map [(alt delete)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 [intercepted_alt_delete])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (define-key global-map 'intercepted_alt_delete 'kill-sentence)
10
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 0
diff changeset
100 (mapcar (lambda (map)
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 0
diff changeset
101 (define-key map [(alt delete)] 'kill-sexp))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 emacs-lisp-mode-map lisp-mode-map minibuffer-local-map))
10
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 0
diff changeset
104 (when (boundp 'c-mode-map)
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 0
diff changeset
105 (mapcar (lambda (map)
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 0
diff changeset
106 (define-key map [(alt delete)] 'kill-sexp))
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 0
diff changeset
107 (list
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 0
diff changeset
108 c-mode-map c++-mode-map objc-mode-map java-mode-map)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ;; (meta shift) delete next paragraph
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (global-set-key [(meta shift delete)] 'kill-paragraph)
10
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 0
diff changeset
112
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 0
diff changeset
113 (provide 'delbackspace)
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 0
diff changeset
114
49a24b4fd526 Import from CVS: tag r19-15b6
cvs
parents: 0
diff changeset
115 ;;; delbackspace.el ends here