From:	CRDGW2::CRDGW2::MRGATE::"SMTP::PREP.AI.MIT.EDU::HELP-GNU-EMACS-REQUEST" 22-MAR-1992 17:37:37.65
To:	ARISIA::EVERHART
CC:	
Subj:	Re: keybindings for vt220

From:	help-gnu-emacs-request@prep.ai.mit.edu@SMTP@CRDGW2
To:	Everhart@Arisia@MRGATE

Received:  by crdgw1.ge.com (5.57/GE 1.123)
	 id AA06496; Sun, 22 Mar 92 17:15:48 EST
Received: by life.ai.mit.edu (4.1/AI-4.10) id AA17753; Sun, 22 Mar 92 16:06:07 EST
Return-Path: <help-gnu-emacs-request@prep.ai.mit.edu>
Received: from news.cis.ohio-state.edu by life.ai.mit.edu (4.1/AI-4.10) id AA17746; Sun, 22 Mar 92 16:05:46 EST
Received: by news.cis.ohio-state.edu (5.61-kk/5.911008)
	id AA21396; Sun, 22 Mar 92 15:50:15 -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: 22 Mar 92 20:18:21 GMT
Message-Id: <1992Mar22.201821.3888@digi.lonestar.org>
Organization: DSC Communications Corp, Plano, TX
From: kgallagh@digi.lonestar.org (Kevin Gallagher)
Sender: help-gnu-emacs-request@prep.ai.mit.edu
References: <1992Mar18.150423.15601@gdstech.grumman.com>
Subject: Re: keybindings for vt220

In article <1992Mar18.150423.15601@gdstech.grumman.com> raj@gdstech.grumman.com (Rajesh Chawla) writes:
>The problem comes in that I want to use vt220 emulation.  When I set
>the emulation and the TERM variable, I have to use C-[ as the ESC key.
>
>How do I change this or which manual do I look into to help me figure
>out how to do it myself?

Try using the attached Emacs Lisp Code.  Directions are in the file header.

Kevin

===============================================================================

;;; File:  vt-esc-sub.el, v 1.2
;;;
;;;               -----   -----   -----------------------
;;;               E S C   K e y   S u b s t i t u t i o n
;;;               -----   -----   -----------------------
;;;
;;;
;;; Copyright (C) 1991 Kevin Gallagher
;;;
;;; GNU Emacs is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY.  No author or distributor accepts
;;; RESPONSIBILITY TO anyone for the consequences of using it or for
;;; whether it serves any particular purpose or works at all, unless 
;;; he says so in writing.  Refer to the GNU Emacs General Public
;;; License for full details.
;;;
;;;  Send bug reports and suggestions for improvement to Kevin Gallagher
;;;  (kgallagh@digi.lonestar.org).
;;;
;;; Everyone is granted permission to copy, modify and redistribute
;;; GNU Emacs, but only under the conditions described in the GNU
;;; Emacs General Public License.  A copy of this license is supposed
;;; to have been given to you along with GNU Emacs so you can know
;;; your rights and responsibilities.  It should be in a file named
;;; COPYING.  Among other things, the Copyright notice and this notice
;;; must be preserved on all copies.
;;;

;;;; Some VT series terminals, such as the VT220, have no escape key.
;;;; To enter an ESC from this terminal, users must type C-[, which
;;;; some people find annoying.  The function vt-esc-sub below allows
;;;; F11 to be used as ESC, in most cases.
;;;;
;;;; The GNU Emacs VT200 series terminal support file found in the
;;;; Emacs distribution, lisp/term/vt200.el, defines a function called
;;;; enable-arrow-keys, which enables arrow and functions keys, and
;;;; sets up F11 as a substitute ESC key when the ESC key is the first
;;;; key of a key sequence.  It does this by binding the character
;;;; sequence generated by the F11 key to ESC-prefix, which is what
;;;; ESC is bound to.  BUT this ONLY provides support for the use of
;;;; F11 for ESC in the situations where ESC is the first key of a key
;;;; sequence.
;;;;
;;;; By the way, as VT200 series terminal users know,
;;;; enable-arrow-keys is NOT set up to be invoked automatically,
;;;; because doing so breaks the standard Emacs binding to ESC [,
;;;; backward-paragraph.  But losing this standard binding is not a
;;;; big loss to most people, so most VT200 users want
;;;; enable-arrow-keys to be invoked.  Therefore, we ensure, below,
;;;; that enable-arrow-keys is called.
;;;;
;;;; Unfortunately, this does not solve the problem when the ESC
;;;; key is a second or later key in a key sequence.  There are two
;;;; such standard Emacs bindings: 
;;;;
;;;;           C-x ESC    bound to  repeat-complex-command
;;;;           ESC ESC    bound to  eval-expression
;;;;
;;;; I also like to make the personal binding of
;;;; 
;;;;           C-c ESC    bound to  electric-command-history
;;;;
;;;; Here's how to tell Emacs to let you use F11 for ESC in the above
;;;; cases:
;;;; 
;;;; First, you need to invoke vt-esc-sub at the appropriate time,
;;;; which binds C-x F11 to invoke repeat-complex-command and F11 F11
;;;; to invoke eval-expression.  For this to work, the F11 key must be
;;;; enabled.  So the function invokes enable-arrow-keys in case the
;;;; user has not done so already.  
;;;; 
;;;; Second, you need to tell Emacs to allow F11 for ESC in your
;;;; custom binding with a function, called enable-my-F11-bindings,
;;;; defined in your .emacs files.  Here's an example:
;;;;
;;;; (defun enable-my-F11-bindings ()
;;;;   (define-key (current-global-map) "\C-c\e" nil)
;;;;   (define-key (current-global-map) "\C-c\e[23~" 'electric-command-history)
;;;;   (let ((save-key (lookup-key electric-history-map "\e")))
;;;;     (define-key electric-history-map "\e" nil)
;;;;     (define-key electric-history-map "\e[23~" save-key)))
;;;; 
;;;; NOTE:  The above modifications to electric-history-map only work if 
;;;;        echistory has been loaded first.
;;;;
;;;; To make this facility available for use to all users, place this
;;;; file, vt-esc-sub.el, into your site's public emacs/lisp directory
;;;; and add the following command to your site's default.el file: 
;;;; 
;;;;   (load "vt-esc-sub")
;;;;      
;;;; The appropriate time to execute the function vt-esc-sub is AFTER
;;;; Emacs loads the terminal specific file from the directory
;;;; lisp/term in the Emacs directories.  This is done AFTER the
;;;; .emacs file is loaded by Emacs, so we must use term-setup-hook to
;;;; accomplish this automatically.  The following code added to your
;;;; .emacs file solves the problem:
;;;; 
;;;;   (setq term-setup-hook 'vt-esc-sub)
;;;;
;;;; If you are already using term-setup-hook to invoke some other
;;;; initialization function (edt-emulation-on, for example), then the
;;;; following code in your .emacs file will work instead:
;;;; 
;;;;   (defun my-term-setup ()
;;;;     (vt-esc-sub)
;;;;     (edt-emulation-on))
;;;;   (setq term-setup-hook 'my-term-setup)
;;;; 
;;;; (Note that vt-esc-sub is called BEFORE edt-emulation-on in the
;;;; example.  This is so the EDT emulation picks up the new key
;;;; definitions.)
;;;;

(defun vt-esc-sub ()
  "Set up bindings so the VT series F11 key behaves like an ESC key.
If the terminal is not the appropriate type, then the function returns
without doing anything."
  (interactive)
  (if (and (fboundp 'enable-arrow-keys)
	   (not (equal (lookup-key CSI-map "34~") 1)))
      (progn
	(enable-arrow-keys)
        (define-key ctl-x-map "\e" nil)
        (define-key ctl-x-map "\e[23~" 'repeat-complex-command)
        (define-key esc-map "\e" nil)
        (define-key esc-map "\e[23~" 'eval-expression)
        (define-key repeat-complex-command-map "\e" nil)
	(define-key repeat-complex-command-map 
	    "\e[23~p" 'previous-complex-command)
	(define-key repeat-complex-command-map 
	    "\e[23~n" 'next-complex-command)
	(if (fboundp 'enable-my-F11-bindings)
	    (enable-my-F11-bindings)))))
Newsgroups: comp.emacs
Subject: Re: Easiest way to duplicate a line
Summary: 
Expires: 
References: <ksckkmINN7d2@news.bbn.com>
Sender: 
Followup-To: 
Distribution: 
Organization: DSC Communications Corp, Plano, TX
Keywords: 

In article <ksckkmINN7d2@news.bbn.com> COTRCSBK%SEA04VM.NAVSEA.NAVY.MIL@vm.tcs.tulane.edu (Stephen B. Kutzer) writes:
>I have been using Emacs for only a few days, so pardon me if this
>is a moronic question.
>
>What is the easiest way to duplicate a line?  The current way I do it
>is:
>
>- at the beginning of the line, C-@
>- C-e
>- C-x C-x
>- ESC-w
>- C-y
>
>that's a whole lot of keystrokes for what has to be one of the most
>common editing tasks!
>
>
>Stephen B. Kutzer  703-769-2900
>I-NET, Inc.        cotrcsbk@sea04vm.navsea.navy.mil


-- 
----------------------------------------------------------------------------
Kevin Gallagher        kgallagh@digi.lonestar.org OR ...!uunet!digi!kgallagh
DSC Communications Corporation   Addr: MS 152, 1000 Coit Rd, Plano, TX 75075
----------------------------------------------------------------------------
