Package: bash
Version: 3.1dfsg-8
Severity: normal

I wanted to use set-mark as part of a readline key binding.  One
simple example I tried, which should have worked:

bind 'Control-v: "[EMAIL PROTECTED]&\C-x\C-x"'

This should make Control-v insert an & at the end of the line but
leave the cursor in the current position.  However, it does not work.
At first I thought that the set-mark command would not work in a key
binding.  However, I discovered that I could bind another key to
set-mark, and that key would work:

bind '"\C-x\C-m": set-mark'
bind 'Control-v: "\C-x\C-m\C-e&\C-x\C-x"'

I furthermore discovered that if I bound some other function or string
to C-@, it would not work in a macro either:

bind '"\C-@": "at"'
bind 'Control-v: "\C-@"'

Finally, I discovered that some key sequences only work if bound via
the longer Control-$char syntax, and others only work if bound via
"\C-$char".  For instance, Control-v only works if bound as Control-v;
if bound as "\C-v" it will continue to point to quoted-insert (both in
a key binding and interactively).  Control-@, on the other hand, only
works if bound as "\C-@"; if bound as Control-@, it will continue to
point to set-mark (interactively; it does not work either way in a key
binding).

The eventual goal, which I managed to achieve after these various
workarounds:

# Make Control-v paste, if in X and if xclip available
if [ -n "$DISPLAY" ] && [ -x /usr/bin/xclip ] ; then
        # Work around a bash bug: \C-@ does not work in a key binding
        bind '"\C-x\C-m": set-mark'
        # The '#' characters ensure that kill commands have text to work on; if
        # not, this binding would malfunction at the start or end of a line.
        bind 'Control-v: "#\C-b\C-k#\C-x\C-?\"$(xclip -o -selection 
c)\"\e\C-e\C-x\C-m\C-a\C-y\C-?\C-e\C-y\ey\C-x\C-x\C-d"'
fi

- Josh Triplett

-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.22-3-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages bash depends on:
ii  base-files                4.0.2          Debian base system miscellaneous f
ii  debianutils               2.28           Miscellaneous utilities specific t
ii  libc6                     2.7-1          GNU C Library: Shared libraries
ii  libncurses5               5.6+20071103-1 Shared libraries for terminal hand

bash recommends no packages.

-- no debconf information



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to