[implementations-list] buggy behaviour with Transient Mark Mode disabled

Vegard Øye vegard_oye at hotmail.com
Tue Apr 13 15:13:44 CEST 2010


> Date: Mon, 12 Apr 2010 23:24:02 +0200
> From: stepnem at gmail.com
>
> With TMM off, first `dd' in a buffer deletes the whole portion of the
> buffer up to that line. After this failure, it works correctly again
> ...until you set the mark, obviously. In short, the command seems to act
> upon the region instead of line when TMM is disabled.

Thank you for the bug report. This should be fixed in revision 203.

Vimpulse /should/ work just fine with Transient Mark mode disabled. It
may need to temporarily enable it now and then (e.g., Visual mode),
but it should restore everything to their original settings
afterwards. More details below.

> Last time I proposed that you said multiple files were advantageous
> for debugging -- what did you mean? I can't think of any such
> advantage myself.

Let me give you an example. :)

Transient Mark mode has a global variable, `mark-active', which
governs whether the region is "active" or not. When it is t, Transient
Mark mode highlights the region. When Transient Mark mode is disabled,
the value is ignored. You can set the variable directly, but the
common way to activate the region is with

    (push-mark nil nil t) ; ACTIVATE argument is t

which sets mark at point and, provided Transient Mark mode is enabled,
activates it. If you do

    (push-mark) ; ACTIVATE argument is nil

then mark is set at point, but /not/ activated (i.e., `mark-active'
is unchanged).

Now, let's disable Transient Mark mode and call `push-mark' again:

    (push-mark) ; ACTIVATE argument is nil

What happens to `mark-active' now? Well, its value is ignored, so why
should it change? But that's precisely what happens: when Transient
Mark mode is disabled, `push-mark' will set `mark-active' to t
/even if the ACTIVATE argument is nil/. That is, `push-mark' will set
`mark-active' to t if the ACTIVATE argument is t /or/ if Transient
Mark mode is disabled, even though it's ignored in the latter case.

Makes sense? Well, not to me either, but there it is.

Then, of course, Vimpulse comes along, enables Transient Mark mode,
and boom! -- the region is immediately activated. Big mess.

How does one discover these things? Multiple files to the rescue!
Unload them one by one until the problem disappears; that narrows it
down. Then search the remaining code for mark-related code, and the
strange, unintuitive behavior of `push-mark' becomes apparent. Not the
way I usually go about these things, but when you have to deal with
certain global variables ...

Now, Vimpulse is always released as one big file at EmacsWiki, and you
can run `make all' to produce that file yourself. Unfortunately, this
will lose you all revision history. I'm sorry about this
inconvenience.

FWIW, this is how I load Vimpulse in my .emacs:

    (require 'vimpulse-dependencies)
    (require 'vimpulse-viper-function-redefinitions)
    (require 'vimpulse-utils)
    (require 'vimpulse-misc-keybindings)
    (require 'vimpulse-modal)
    (require 'vimpulse-ex)
    (require 'vimpulse-paren-matching)
    (require 'vimpulse-operator)
    (require 'vimpulse-text-object-system)
    (require 'vimpulse-visual-mode)
    (require 'vimpulse-compatibility)

My site-lisp directory contains Vimpulse as multiple files, of course.
Maybe it would be easier if you did the same?

Vegard 		 	   		  
_________________________________________________________________
Nye Windows 7: PCen som passer for deg. Finn ut mer.
http://windows.microsoft.com/shop


More information about the implementations-list mailing list