unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Per Bothner <per@bothner.com>
To: 16746@debbugs.gnu.org
Cc: Jakub Jankiewicz <jcubic@onet.pl>
Subject: bug#16746: support ctrl-left, ctrl-right etc for term-mode
Date: Thu, 13 Feb 2014 13:09:50 -0800	[thread overview]
Message-ID: <52FD349E.1030405@bothner.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 307 bytes --]

The attached patch translates ctrl-left, ctrl-right, ctrl-up, and ctrl-down
to the same escape sequences as xterm sends.  This means among other things
that ctrl-left and ctrl-right get interpreted as backward-word and 
forward-word
in readline.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

[-- Attachment #2: term-ctrl-arrow.patch --]
[-- Type: text/x-patch, Size: 1563 bytes --]

2014-02-13  Per Bothner  <per@bothner.com>

	* term.el: Translate C-left, C-right, C-up, C-down to
	appropriate (xterm-compatible) escape sequences.

=== modified file 'lisp/term.el'
--- lisp/term.el	2014-01-22 10:29:23 +0000
+++ lisp/term.el	2014-02-13 20:17:22 +0000
@@ -887,6 +887,10 @@
     (define-key map [down] 'term-send-down)
     (define-key map [right] 'term-send-right)
     (define-key map [left] 'term-send-left)
+    (define-key map [C-up] 'term-send-ctrl-up)
+    (define-key map [C-down] 'term-send-ctrl-down)
+    (define-key map [C-right] 'term-send-ctrl-right)
+    (define-key map [C-left] 'term-send-ctrl-left)
     (define-key map [delete] 'term-send-del)
     (define-key map [deletechar] 'term-send-del)
     (define-key map [backspace] 'term-send-backspace)
@@ -1275,6 +1279,10 @@
 (defun term-send-down  () (interactive) (term-send-raw-string "\eOB"))
 (defun term-send-right () (interactive) (term-send-raw-string "\eOC"))
 (defun term-send-left  () (interactive) (term-send-raw-string "\eOD"))
+(defun term-send-ctrl-up    () (interactive) (term-send-raw-string "\e[1;5A"))
+(defun term-send-ctrl-down  () (interactive) (term-send-raw-string "\e[1;5B"))
+(defun term-send-ctrl-right () (interactive) (term-send-raw-string "\e[1;5C"))
+(defun term-send-ctrl-left  () (interactive) (term-send-raw-string "\e[1;5D"))
 (defun term-send-home  () (interactive) (term-send-raw-string "\e[1~"))
 (defun term-send-insert() (interactive) (term-send-raw-string "\e[2~"))
 (defun term-send-end   () (interactive) (term-send-raw-string "\e[4~"))


             reply	other threads:[~2014-02-13 21:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-13 21:09 Per Bothner [this message]
2016-02-24  3:19 ` bug#16746: support ctrl-left, ctrl-right etc for term-mode Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52FD349E.1030405@bothner.com \
    --to=per@bothner.com \
    --cc=16746@debbugs.gnu.org \
    --cc=jcubic@onet.pl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).