help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C-= ?


From: Emanuel Berg
Subject: Re: C-= ?
Date: Sun, 19 Jul 2015 10:10:50 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

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 via email to

[Prev in Thread] Current Thread [Next in Thread]