Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!ut-emx!mic From: mic@ut-emx.UUCP (Mic Kaczmarczik) Newsgroups: comp.sys.next Subject: Re: Alternate as a Meta key in emacs?? Summary: Beware M-Q in Terminal (hack solution included) Message-ID: <25152@ut-emx.UUCP> Date: 27 Feb 90 03:15:13 GMT References: <23460001@pnl-geo.UUCP> <1990Feb25.001112.17746@athena.mit.edu> <16228@orstcs.CS.ORST.EDU> <9523@portia.Stanford.EDU> <1702@mit-amt.MEDIA.MIT.EDU> Reply-To: mic@emx.UUCP (Mic Kaczmarczik) Organization: UT Austin Computation Center, Unix/VMS/Cyber Services Lines: 152 In article <1702@mit-amt.MEDIA.MIT.EDU> lacsap@media-lab.media.mit.edu (Pascal Chesnais) writes: >In article <9523@portia.Stanford.EDU> grd@portia.Stanford.EDU (Glen Diener) writes: >> >>(setq meta-flag t) in .emacs will make 'command' into 'meta' > > >but user beware! command-Q still quits out of terminal, rather than do >M-Q. Indeed it does. Unless you make a copy of Terminal, then compile and run the following little hack on it. I wrote it after having lost many a mail message because I tried to reformat a paragraph with M-Q. Like all patches, there's no guarantee it will work under the next release of the operating system. I think a better approach in the long run is to let users turn off key equivalents if they want. Anybody at NeXT listening out there? Finally, a disclaimer: this patch is not sanctioned, condoned, or otherwise recognized by NeXT. Don't run it on your release copy of Terminal; do it on a private copy. Have fun, Mic Kaczmarczik mic@emx.utexas.edu (Internet) Unix/VMS/Cyber Services mic@utaivc (BITNET) UT Austin Computation Center ...!cs.utexas.edu!ut-emx!mic (UUCP) ``Good tea. Nice house.'' -- Worf ----------------------------------CUT HERE------------------------------------- /* * Name: * patchterm 1.0 (for the 1.0 NeXT system software release) * * Description: * This program removes the key equivalents from the NeXT Terminal * application, so typing M-q while editing in Emacs will not cause * the Terminal app to quit unexpectedly! * * Usage: * cc -o patchterm patchterm.c * cp /NextApps/Terminal ~/Apps/Terminal * ./patchterm ~/Apps/Terminal * * Perpetrated by: * * Mic Kaczmarczik * Unix/VMS/Cyber Services * UT Austin Computation Center * mic@emx.utexas.edu * * Comments: * * Don't ask me how I found these offsets; suffice it to say that when adb * isn't available, sometimes GNU Emacs does more than edit source code :-) * The magic constants used below are actually the 68000-series instructions * lea @#0x68 * and * lea @#0x71 * * which have the effect of pushing the character constants 'h' and 'q' on * the stack, respectively, while invoking the methods that set up the * Terminal app's menu items. That's a pretty nifty thing for a compiler * to do... Patching the instructions to set the address to 0, e.g. * lea @#0x00 * * disables the menu button cells' key equivalent, and makes me much happier * with the cube I use. :-) :-) */ #include #define HIDE_OFFSET 5976 #define HIDE_BEFORE 0x48780068 #define HIDE_AFTER 0x48780000 #define QUIT_OFFSET 6012 #define QUIT_BEFORE 0x48780071 #define QUIT_AFTER 0x48780000 #define PRINT_OFFSET 5952 #define PRINT_BEFORE 0x48780070 #define PRINT_AFTER 0x48780000 char *progname; main(argc, argv) int argc; char *argv[]; { FILE *f; progname = argv[0]; if (argc != 2) { fprintf(stderr,"usage: %s 1.0-Terminal-binary\n", progname); exit(1); } if ((f = fopen(argv[1], "r+")) == NULL) { fprintf(stderr,"%s: can't open %s for writing\n", progname, argv[1]); exit(1); } patch(f, PRINT_OFFSET, PRINT_BEFORE, PRINT_AFTER); patch(f, HIDE_OFFSET, HIDE_BEFORE, HIDE_AFTER); patch(f, QUIT_OFFSET, QUIT_BEFORE, QUIT_AFTER); fclose(f); printf("%s patched successfully.\n", argv[1]); exit(0); } patch(f, offset, before, after) FILE *f; long offset, before, after; { long inst; if (fseek(f, offset, 0)) { fprintf(stderr,"%s: can't seek to position %x, aborting\n", progname, offset); exit(1); } fread(&inst, sizeof(inst), 1, f); if (inst == after) { /* patched already ? */ fprintf(stderr,"%s: position 0x%lx is patched already.\n", progname, offset); return; } if (inst != before) { /* better not do anything in this case */ fprintf(stderr,"%s: position 0x%lx should be %x, is %x.\n\ Make sure this is really a copy of the 1.0 release Terminal app.\n", progname, offset, inst, before); exit(1); } fseek(f, offset, 0); fwrite(&after, sizeof(after), 1, f); } -- Mic Kaczmarczik mic@emx.utexas.edu (Internet) Unix/VMS/Cyber Services mic@utaivc (BITNET) UT Austin Computation Center ...!cs.utexas.edu!ut-emx!mic (UUCP) ``Good tea. Nice house.'' -- Worf Please direct consulting questions to gripe@{emx,ix2,ccwf,iv1} as appropriate.