unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Emanuel Berg <embe8573@student.uu.se>
To: help-gnu-emacs@gnu.org
Subject: Re: C-= ?
Date: Sun, 19 Jul 2015 10:10:50 +0200	[thread overview]
Message-ID: <87mvysva7p.fsf@nl106-137-147.student.uu.se> (raw)
In-Reply-To: 20150719011508.19549.09878E5B@ahiker.mooo.com

Ian Zimmerman <itz@buug.org> writes:

> I'll just add that there's a good reason emacs
> doesn't use this "key": there's no ASCII code
> Control-=, so such a binding will not work in emacs
> running on a text terminal, including an emulated
> terminal like xterm. It can only work in a true GUI
> emacs session where emacs knows about every physical
> key press and release.

It is possible to get C-= up and running in a couple
of minutes in the ttys, which are as far from "true
GUI" anyone will ever want to wander.

I have described this process a couple of times, so
I'll see if I can find a reference. If not, see if you
can deduct it from examining these to files - one
a config file for the tty, and one an Emacs init file.
As ever, that is all you need.

    http://user.it.uu.se/~embe8573/conf/remap.inc
    http://user.it.uu.se/~embe8573/conf/emacs-init/console-keys.el

... Yes, here it is, with some modification to clarify
the process. Originally written 2014-01-23. Seems like
ages ago ...

This file: http://user.it.uu.se/~embe8573/tty-emacs-keys.txt

The Linux console: special shortcuts in Emacs
---------------------------------------------

How to get special shortcuts (e.g., C-0) to work in
a tty Emacs instance. This is the Linux console/VT/tty
solution that works on Debian, and probably on many
other distros as well with minor or
none modifications.

In the file

    /etc/console-setup/remap.inc

put

    control keycode 11 = U+0110

11 is the keycode for the key '0', and you learn that
from showkey(1).

                         -*-

Note: If you use tmux on top of the VT, you might get
this error with showkey:

    Couldn't get a file descriptor referring to the console

If so, do either

    $ sudo showkey                # every time

or

    $ chmod u+s /usr/bin/showkey  # once

If showkey is somewhere else than /usr/bin/showkey, do

    $ type showkey

in bash or zsh to find out where.

                         -*-

Let's return to the line

    control keycode 11 = U+0110

This syntax reads: assign the shortcut C-0 (in Emacs
notation; remember showkey has told us '0 = 11') so
that when pressed, insert the char which has Unicode
U+0110. (That char turns out a diamond in the ttys, so
it must be something fancy that we will never need for
anything else.)

The Unicode (the particular code, i.e. U+0110) is
arbitrary in the sense it doesn't matter what it is as
long as the char isn't in use already. Make it exotic.
When you have found one exotic char, it is easy to
find more just by adding or subtracting one for each
shortcut you add. It is the hexadecimal system.

OK, now save the remap.inc file and use this zsh
function (or a bash equivalent, or just type the
command) to see that it works:

    lkeys () {
      loadkeys -q -c -s /etc/console-setup/remap.inc
    }

Again, do the '+s' thing if you don't want to do sudo
each time. After invoking lkeys, hit C-0 when in the
shell. Now the diamond should appear! (The options to
loadkeys(1) are not relevant to this tutorial, but
I use it for other purposes as well. The man page
tells more, as always.)

Next, in an Emacs init file (.emacs, or if you want to
put such things somewhere else, and then `load-file'
from the main init file), anyway in such a file, put:

    (define-key input-decode-map [?\u0110] [C-0])

Now, hit `C-0' and it should say:

    <C-0> is undefined

which means you can bind it to whatever:

    (global-set-key [C-0] 'switch-buffer)

One last hint: Because you want to load the modified
keymap each time when starting the system, but without
having to input the sudo password, one way to do that
(at least on Debian) is to put:

    loadkeys /etc/console-setup/remap.inc > /dev/null

in

    /etc/rc.local

Tutorial by: Emanuel Berg (embe8573@student.uu.se)
Last modified: July 19, 2015
More cool stuff: http://user.it.uu.se/~embe8573

-- 
underground experts united
http://user.it.uu.se/~embe8573




  reply	other threads:[~2015-07-19  8:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-18 18:32 C-= ? Sharon Kimble
2015-07-18 19:28 ` Emanuel Berg
2015-07-18 19:33 ` Dmitry Gutov
2015-07-19  1:26 ` Ian Zimmerman
2015-07-19  8:10   ` Emanuel Berg [this message]
2015-07-19  9:15     ` Yuri Khan
2015-07-19 23:14       ` Emanuel Berg
     [not found]       ` <mailman.7163.1437348015.904.help-gnu-emacs@gnu.org>
2015-07-20  2:47         ` Rusi
2015-07-19  3:37 ` Vaidheeswaran C

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=87mvysva7p.fsf@nl106-137-147.student.uu.se \
    --to=embe8573@student.uu.se \
    --cc=help-gnu-emacs@gnu.org \
    /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.
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).