2

mouse-wheel-mode is enabled in emacs, however the cursor does not scroll as it had in other terminal emulators, on other distros. I've done a lot of digging and cant seem to find the answer. Again I'm using urxvt, and scrolling up and down of the text in the window of say, the log output of a running application does occur when I move the mouse wheel. In emacs nothing happens with the mousewheel, and I believe there is a way that the scroll wheel can cause the same result as pressing the up arrow/down arrow.

3
  • You might take a look to see which escape sequence (if any...) emacs sends to initialize the mouse-mode. I would capture output from running emacs with script and make that in visible form with map to see the escape sequences, referring to XTerm Control Sequences. Commented Nov 25, 2015 at 18:49
  • Please be more specific. Your message is vague and confusing: for example, it makes no sense to talk about cursors that scroll; you say "...does not scroll.." and later "...scrolling does work"; finally "...not scroll as it had..." is begging for a description of the difference you're seeing (how did it scroll before, how does it scroll now).
    – Stefan
    Commented Nov 25, 2015 at 18:57
  • @Stefan, thanks, I see how what I was saying was confusing, i've clarified Commented Nov 30, 2015 at 6:39

1 Answer 1

1

I haven't tested this specifically for emacs yet, but this allows for mouse scrolling when using vim,less,man,etc. Paste this in $HOME/.urxvt/ext/vtwheel (create the file if it doesn't exist):

#! perl

# Implements a scrollwheel just like in good old vt100's mices

sub simulate_keypress {
    my ($self, $type) = @_; #type: 0:up, 1:down

    my $keycode_up = 111;
    my $keycode_down = 116;

    my $numlines = 3;

    my $keycode = 0;
    if ($type eq 0) {
        $keycode = $keycode_up;
    } elsif ($type eq 1) {
        $keycode = $keycode_down;
    } else {
        return;
    }

    for (my $i = 0 ; $i ne $numlines ; $i++) {
        $self->key_press(0,$keycode);
        $self->key_release(0,$keycode);
    }
}

sub on_button_release {
    my ($self, $event) = @_;

    #my $res_ss = $self->resource("secondaryScroll");
    #warn("ressource ss is <$res_ss>");

    !$self->current_screen and return ();

    #warn("foo, event: <$event->{button}>\n");
    if ($event->{button} eq "4") { # scroll up
        $self->simulate_keypress(0);
        return 1;
    } elsif ($event->{button} eq "5") { # scroll down
        $self->simulate_keypress(1);
        return 1;
    }

    return ();
}

Then add URxvt.perl-ext-common:vtewheel to your .Xresources (or .Xdefaults) and run xrdb .Xresources

Source: https://aur.archlinux.org/cgit/aur.git/tree/vtwheel?h=urxvt-vtwheel

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .