[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Munging of del and backspace



Micce> Uh, I should have mentioned I run under X.

Miles> So you can think of `DEL' as the emacs abstraction for whatever
Miles> key happens to delete the previous character on your keyboard,
Miles> be it labelled BS, <--, or

Micce> For tty emacs, I would understand, but with X, it must be
Micce> possible to distinguish C-d and Delete, just as the <-- key
Micce> does not bring up the help, and tab is different from ^I etc.

Miles> Rubout.  Because emacs maintains this abstraction, your emacs
Miles> keybindings should work on any device.

Micce> I.e. you can never make any use of more than basic tty
Micce> capabilities?  And it's annoying that key bindings in emacs and
Micce> xemacs have different results.

But of course you _can_ tell them apart.  And you can remap them to
your liking, with function-key-map, which see.  This is usualy done in
the term subdirectory of one of the site-lisp directories, because it
is dependent on the terminal you're on.  For example, in my
site-lisp/term I have 3 files: x-win.el, rxvt.el, and linux.el.
Here's a piece of each:

;;;x-win.el:

;; Map certain keypad keys into ASCII characters
;; that people usually expect.
(define-key function-key-map [backspace] [127])
(define-key function-key-map [delete] [deletechar])
(define-key function-key-map [tab] [?\t])
(define-key function-key-map [linefeed] [?\n])
(define-key function-key-map [clear] [?\C-l])
(define-key function-key-map [return] [?\C-m])
(define-key function-key-map [escape] [?\e])
(define-key function-key-map [M-backspace] [?\M-\d])
(define-key function-key-map [M-delete] [?\M-\d])
(define-key function-key-map [M-tab] [?\M-\t])
(define-key function-key-map [M-linefeed] [?\M-\n])
(define-key function-key-map [M-clear] [?\M-\C-l])
(define-key function-key-map [M-return] [?\M-\C-m])
(define-key function-key-map [M-escape] [?\M-\e])
(define-key function-key-map [iso-lefttab] [backtab])

;; These tell read-char how to convert
;; these special chars to ASCII.
(put 'backspace 'ascii-character 127)
(put 'delete 'ascii-character 127)

;;;rxvt.el:

(define-key function-key-map "\e[A" [up])
(define-key function-key-map "\e[B" [down])
(define-key function-key-map "\e[C" [right])
(define-key function-key-map "\e[D" [left])
(define-key function-key-map "\e[2~" [insert])
(define-key function-key-map "\e[4~" [select])
(define-key function-key-map "\e[5~" [prior])
(define-key function-key-map "\e[6~" [next])
(define-key function-key-map "\e[11~" [f1])
(define-key function-key-map "\e[12~" [f2])
(define-key function-key-map "\e[13~" [f3])
(define-key function-key-map "\e[14~" [f4])
(define-key function-key-map "\e[15~" [f5])
(define-key function-key-map "\e[17~" [f6])
(define-key function-key-map "\e[18~" [f7])
(define-key function-key-map "\e[19~" [f8])
(define-key function-key-map "\e[20~" [f9])
(define-key function-key-map "\e[21~" [f10])
(define-key function-key-map "\e[23~" [f11])
(define-key function-key-map "\e[24~" [f12])
(define-key function-key-map "\e[29~" [print])

;;;linux.el:

(define-key function-key-map "\M-[1~" [home])
(define-key function-key-map "\M-[2~" [insert])
(define-key function-key-map "\M-[3~" [deletechar])
(define-key function-key-map "\M-[4~" [end])
(define-key function-key-map "\M-[5~" [prior])
(define-key function-key-map "\M-[6~" [next])

HTH, Ian

-- 
"This is the patent age of new inventions
For killing bodies, and for saving souls,
All propagated with the best intentions." 
George Gordon, lord Byron



Reply to: