From: CRDGW2::CRDGW2::MRGATE::"SMTP::PREP.AI.MIT.EDU::HELP-GNU-EMACS-REQUEST" 6-FEB-1992 14:57:07.69 To: ARISIA::EVERHART CC: Subj: Re: *SUMMARY* Running EMACS on a Sun using X/Motif in No Window Mode From: help-gnu-emacs-request@prep.ai.mit.edu@SMTP@CRDGW2 To: Everhart@Arisia@MRGATE Received: by crdgw1.ge.com (5.57/GE 1.122) id AA11035; Thu, 6 Feb 92 14:29:21 EST Received: by life.ai.mit.edu (4.1/AI-4.10) id AA29942; Wed, 5 Feb 92 04:37:17 EST Return-Path: Received: from news.cis.ohio-state.edu by life.ai.mit.edu (4.1/AI-4.10) id AA29929; Wed, 5 Feb 92 04:34:28 EST Received: by news.cis.ohio-state.edu (5.61-kk/5.911008) id AA26674; Wed, 5 Feb 92 04:28:16 -0500 Received: from USENET by news.cis.ohio-state.edu with netnews for help-gnu-emacs@prep.ai.mit.edu (help-gnu-emacs@prep.ai.mit.edu); contact usenet@news.cis.ohio-state.edu if you have questions. To: help-gnu-emacs@prep.ai.mit.edu Date: Wed, 5 Feb 92 09:11:06 GMT Message-Id: Organization: Institut fuer Informatik der Universitaet Freiburg, Deutschland From: ruprecht@informatik.uni-freiburg.de (Nick Ruprecht) Sender: help-gnu-emacs-request@prep.ai.mit.edu References: <9202042023.AA01884@porter>ps.oh Subject: Re: *SUMMARY* Running EMACS on a Sun using X/Motif in No Window Mode I believe there is a better way to run emacs within an xterm. Read on if you want to know why and how ... robinson@PORTER.GEO.BROWN.EDU (Darrin Robinson) writes: >Here's how to get emacs to run on a Sun Sparc in no window mode inside an Xterm and >maintain the same functionality it has under Sunview : [...] >;;F10 >(define-key dg-raw-map "-1z" 'replace-string) This strange escape sequence is due to a bug in the function stringFuncVal() in emacs/src/x11term.c, where whoever did it forgot to define the escape sequence for F10 to ^[[233z. The effect is that F10 and Help both show up as ^[[-1z. I have complained about it to no avail. >;;F11 >(define-key dg-raw-map "192z" 'query-replace) >;;F12 >(define-key dg-raw-map "193z" 'abbrev-mode) These escape sequences are due to a bug in X11, where F11 = L1 and F12 = L2, so F11 and F12 send the same escape sequences as L1 and L2, respectively. You can bind the keys to other KeySyms (e.g. KP_F1, KP_F2) with the program xmodmap, but emacs does not know those keys :-( There is an alternative, however. Read on ... >(define-key dg-raw-map "A" 'previous-line) >(define-key dg-raw-map "B" 'next-line) >(define-key dg-raw-map "C" 'forward-char) >(define-key dg-raw-map "D" 'backward-char) >(define-key dg-raw-map "214z" 'beginning-of-buffer) >(define-key dg-raw-map "220z" 'end-of-buffer) >(define-key dg-raw-map "222z" 'scroll-up) >(define-key dg-raw-map "216z" 'scroll-down) >(define-key dg-raw-map "218z" 'recenter) The rest of the keypad keys can't be bound this way, but here is how you can do it, and much more: xterm allows to define translations of keys in a resource file. Keys can be mapped to arbitrary strings, and the mapping can be different for different modifier combinations. You can also switch between keymaps. So I have done the following: 1. Change xmodmap so more keys produce something useful. Here is my file .xmodmaprc which I activate when I start X by putting xmodmap .xmodmaprc in my file .xinitrc -----8<----- snip snip -----8<----- ! .xmodmaprc - map keys to unique keysyms ! ! In /usr/include/X11/keysymdef.h, F11=L1 and F12=L2, so these must be moved ! to other keysyms, e.g. F11->KP_F1, F12->KP_F2 keycode 16 = KP_F1 keycode 18 = KP_F2 ! Keycode 57 (Del/. on the right keypad) sends "Delete", as does the Delete ! key. To be able to distinguish them, I do keycode 57 = KP_Decimal ! I want to use the Compose and AltGraph keys, so they must be bound to keysyms keycode 20 = Alt_R keycode 74 = Super_R -----8<----- snip snip -----8<----- 2. Create a keymap for xterm. This is merged into the resource database with this in my .xinitrc xrdb -merge .keymap You might not want all of this. Cut away what you don't like. I have removed my email address from the ftp keymap. Insert yours. -----8<----- snip snip -----8<----- ! .keymap - An example for xterm keymaps. ! ! Default keymap: keypad is in NumLock state. ! ScrollLock switches to emacs-keymap, F10 to ftp-keymap. ! A few other keys also have special effects. ! *VT100.Translations: #override \ Mod1 ShiftA: string(0x43) \n\ Mod1 A: string(0x63) \n\ Mod1 Delete: string(0x17) \n\ Shift Delete: string(0x7f) \n\ Delete: string(0x08) \n\ L2: string("!!") string(0x0d) \n\ L4: string(0x03) \n\ Linefeed: string(" | more") string(0x0d) \n\ F10: keymap(ftp) \n\ R1: string("(") \n\ R2: string(")") \n\ R3: keymap(emacspad) \n\ Num_Lock: ignore() \n\ R4: string("=") \n\ R5: string("/") \n\ R6: string("*") \n\ KP_Subtract: string("-") \n\ R7: string("7") \n\ Up: string("8") \n\ R9: string("9") \n\ KP_Add: string("+") \n\ Left: string("4") \n\ R11: string("5") \n\ Right: string("6") \n\ R13: string("1") \n\ Down: string("2") \n\ R15: string("3") \n\ Insert: string("0") \n\ KP_Decimal: string(".") \n\ KP_Enter: string(0x0d) ! Emacs keymap: ! L* and F* keys are bound to the default escape sequences. Modify to suit ! your taste ... ! The right keypad sends different strings for different modifier states: ! Unmodified keys generally do what you'd expect. ! send modified movement commands (like forward-word ...) ! and generally send the characters printed on the keys. ! sends the associated number as numeric argument for a command. ! Numlock switches back to the default keymap. ! Some bindings refer to elisp functions I made up. I have listed these ! further below. See for yourself whether you find them useful. ! *VT100.emacspadKeymap.translations: \ Delete: string(0x7f) \n\ L1: keymap(None) string(0x1b) string("[192z") \n\ L2: string(0x1b) string("[193z") \n\ L3: string(0x1b) string("[194z") \n\ L4: string(0x1b) string("[195z") \n\ L5: string(0x1b) string("[196z") \n\ L6: string(0x1b) string("[197z") \n\ L7: string(0x1b) string("[198z") \n\ L8: string(0x1b) string("[199z") \n\ L9: string(0x1b) string("[200z") \n\ L10: string(0x1b) string("[201z") \n\ F1: string(0x1b) string("[224z") \n\ F2: string(0x1b) string("[225z") \n\ F3: string(0x1b) string("[226z") \n\ F4: string(0x1b) string("[227z") \n\ F5: string(0x1b) string("[228z") \n\ F6: string(0x1b) string("[229z") \n\ F7: string(0x1b) string("[230z") \n\ F8: string(0x1b) string("[231z") \n\ F9: string(0x1b) string("[232z") \n\ F10: string(0x1b) string("[233z") \n\ KP_F1: string(0x1b) string("[234z") \n\ KP_F2: string(0x1b) string("[235z") \n\ KP_F3: string(0x1b) string("[236z") \n\ KP_F4: string(0x1b) string("[237z") \n\ Break: string(0x1b) string("[223z") \n\ Help: string(0x08) \n\ R1: string(0x18) string(0x02) \n\ R2: string(0x1b) \ string("xelectric-command-history") \ string(0x0d) \n\ R3: string(0x07) \n\ Num_Lock: keymap(None) \n\ Ctrl R4: string(0x1b) string("xgoto-line") \ string(0x0d) \n\ Mod1 R4: string(0x1b) string("xwhat-cursor-position") \ string(0x0d) \n\ Shift R4: string("=") \n\ Lock R4: string("=") \n\ R4: string(0x1b) string("xwhat-line") \ string(0x0d) \n\ Ctrl R5: string(0x12) \n\ Mod1 R5: string(0x1b) string("xre-search-forward") \ string(0x0d) \n\ Shift R5: string("/") \n\ Lock R5: string("/") \n\ R5: string(0x13) \n\ Ctrl R6: string(0x1b) string("xtoggle-read-only") \ string(0x0d) \n\ Mod1 R6: string(0x1b) string("xrevert-buffer")\n\ Shift R6: string("*") \n\ Lock R6: string("*") \n\ R6: string(0x1b) string("xauto-fill-mode") \ string(0x0d) \n\ Ctrl KP_Subtract: string(0x1b) string("k") \n\ Mod1 KP_Subtract: string(0x1b) string("-") \n\ Shift KP_Subtract: string("-") \n\ Lock KP_Subtract: string("-") \n\ KP_Subtract: string(0x0b) \n\ Ctrl R7: string(0x1b) string("xbackward-beg-of-line") \ string(0x0d) \n\ Mod1 R7: string(0x1b) string("7") \n\ Shift R7: string("7") \n\ Lock R7: string("7") \n\ R7: string(0x1b) string("<") \n\ Ctrl Up: string(0x1b) string("xbackward-paragraph") \ string(0x0d) \n\ Mod1 Up: string(0x1b) string("8") \n\ Shift Up: string("8") \n\ Lock Up: string("8") \n\ Up: string(0x10) \n\ Ctrl R9: string(0x1b) string("xbackward-end-of-line") \ string(0x0d) \n\ Mod1 R9: string(0x1b) string("9") \n\ Shift R9: string("9") \n\ Lock R9: string("9") \n\ R9: string(0x1b) string("v") \n\ Ctrl KP_Add: string(0x18) string("1") \n\ Mod1 KP_Add: string(0x18) string("2") \n\ Shift KP_Add: string("+") \n\ Lock KP_Add: string("+") \n\ KP_Add: string(0x18) string("o") \n\ Ctrl Left: string(0x1b) string("b") \n\ Mod1 Left: string(0x1b) string("4") \n\ Shift Left: string("4") \n\ Lock Left: string("4") \n\ Left: string(0x02) \n\ Ctrl R11: string(0x1b) string("xback-to-indentation") \ string(0x0d) \n\ Mod1 R11: string(0x1b) string("5") \n\ Shift R11: string("5") \n\ Lock R11: string("5") \n\ R11: string(0x0c) \n\ Ctrl Right: string(0x1b) string("f") \n\ Mod1 Right: string(0x1b) string("6") \n\ Shift Right: string("6") \n\ Lock Right: string("6") \n\ Right: string(0x06) \n\ Ctrl R13: string(0x1b) string("xforward-beg-of-line") \ string(0x0d) \n\ Mod1 R13: string(0x1b) string("1") \n\ Shift R13: string("1") \n\ Lock R13: string("1") \n\ R13: string(0x1b) string(">") \n\ Ctrl Down: string(0x1b) string("xforward-paragraph") \ string(0x0d) \n\ Mod1 Down: string(0x1b) string("2") \n\ Shift Down: string("2") \n\ Lock Down: string("2") \n\ Down: string(0x0e) \n\ Ctrl R15: string(0x1b) string("xforward-end-of-line") \ string(0x0d) \n\ Mod1 R15: string(0x1b) string("3") \n\ Shift R15: string("3") \n\ Lock R15: string("3") \n\ R15: string(0x16) \n\ Ctrl Insert: string(0x1b) string("xforward-to-indentation")\ string(0x0d) \n\ Mod1 Insert: string(0x1b) string("0") \n\ Shift Insert: string("0") \n\ Lock Insert: string("0") \n\ Insert: string(0x1b) string("xset-mark-command") \ string(0x0d) \n\ Ctrl KP_Decimal: string(0x1b) string("d") \n\ Mod1 KP_Decimal: string(0x1b) string(".") \n\ Shift KP_Decimal: string(".") \n\ Lock KP_Decimal: string(".") \n\ KP_Decimal: string(0x04) \n\ Alt_L: string(0x18) \n\ Alt_R: string(0x18) string("4") \n\ Super_R: string(0x03) ! ftp keymap: avoid typos when I ftp ... *VT100.ftpKeymap.translations: \ R3: keymap(emacspad) \n\ Num_Lock: keymap(None) \n\ F10: string("ftp ") \n\ KP_F1: string("anonymous") string(0x0d) \n\ KP_F2: string("* put your email address here *") \ string(0x0d) -----8<----- snip snip -----8<----- These are a few functions that are referred to in the emacs keymap. Put them in your .emacs file if you want to use them. With the above emacs keymap and the below save-buffers-... function, "AltGraph Compose" will save modified buffers and exit. Very convenient. -----8<----- snip snip -----8<----- ;; advanced move commands (defun forward-beg-of-line (arg) "Move forward to the beginning of the next line. With ARG, move ARG lines." (interactive "p") (if (< arg 0) (backward-beg-of-line (- 0 arg)) (end-of-line arg) (forward-char))) (defun backward-beg-of-line (arg) "Move backward to previous beginning of line. With ARG, move ARG lines." (interactive "p") (if (< arg 0) (forward-beg-of-line (- 0 arg)) (backward-char) (beginning-of-line (- 2 arg)))) (defun forward-end-of-line (arg) "Move forward to the next end of line. With ARG, move ARG lines." (interactive "p") (forward-char) (end-of-line arg)) (defun backward-end-of-line (arg) "Move backward to the previous end of line. With ARG, move ARG lines." (interactive "p") (if (< arg 0) (forward-end-of-line (- 0 arg)) (beginning-of-line (- 2 arg)) (backward-char))) ;; save buffers silently, then kill emacs, put this on C-x 4 C-c (defun save-buffers-silently-kill-emacs () "Silently save all file-visiting buffers, then kill this Emacs fork." (interactive) (save-buffers-kill-emacs t)) (define-key ctl-x-4-map "\C-c" 'save-buffers-silently-kill-emacs) -----8<----- snip snip -----8<----- Ended up being a long posting ... Hope you can use it. Regards, -- Nick Ruprecht Institut fuer Informatik der Universitaet Freiburg, Germany (ruprecht@informatik.uni-freiburg.de)