annotate lisp/utils/delbackspace.el @ 76:c0c698873ce1 r20-0b33

Import from CVS: tag r20-0b33
author cvs
date Mon, 13 Aug 2007 09:05:10 +0200
parents 131b0175ea99
children
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)
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
63
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
64 (mapcar (lambda (map)
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
65 (define-key map [(alt backspace)] 'backward-kill-sexp))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 10
diff changeset
66 (list
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 10
diff changeset
67 emacs-lisp-mode-map lisp-mode-map minibuffer-local-map))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
69 (if (boundp 'c-mode-map)
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
70 (mapcar (lambda (map)
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
71 (define-key map [(alt backspace)] 'backward-kill-sexp))
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
72 (list
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
73 c-mode-map c++-mode-map objc-mode-map java-mode-map))
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
74 (setq after-load-alist
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
75 (append '(("cc-mode"
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
76 (mapcar (lambda (map)
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
77 (define-key map
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
78 [(alt backspace)]
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
79 'backward-kill-sexp)
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
80 (define-key map [(alt delete)] 'kill-sexp))
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
81 (list
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
82 c-mode-map
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
83 c++-mode-map
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
84 objc-mode-map
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
85 java-mode-map))))
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
86 after-load-alist)))
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
87
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;; (meta shift) backspace paragraph before cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (global-set-key [(meta shift backspace)] 'backward-kill-paragraph)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;; (alt) delete rest of line (erase EOF)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (global-set-key [(control delete)] 'kill-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;; (meta) delete word before cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (define-key key-translation-map [(meta delete)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 [intercepted_meta_delete])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (define-key global-map 'intercepted_meta_delete 'kill-word)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;; (alt) delete sentence forward; delete sexp forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;; in language modes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (define-key key-translation-map [(alt delete)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 [intercepted_alt_delete])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (define-key global-map 'intercepted_alt_delete 'kill-sentence)
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
104 (mapcar (lambda (map)
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
105 (define-key map [(alt delete)] 'kill-sexp))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 emacs-lisp-mode-map lisp-mode-map minibuffer-local-map))
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
108 (when (boundp 'c-mode-map)
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
109 (mapcar (lambda (map)
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
110 (define-key map [(alt delete)] 'kill-sexp))
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
111 (list
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
112 c-mode-map c++-mode-map objc-mode-map java-mode-map)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ;; (meta shift) delete next paragraph
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (global-set-key [(meta shift delete)] 'kill-paragraph)
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
116
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
117 (provide 'delbackspace)
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
118
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
119 ;;; delbackspace.el ends here