GNU bug report logs - #16438
24.3.50; `C-x TAB right right' fails with error (mark-inactive)

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> jurta.org>

Date: Tue, 14 Jan 2014 08:18:01 UTC

Severity: normal

Found in version 24.3.50

Done: Juri Linkov <juri <at> jurta.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 16438 in the body.
You can then email your comments to 16438 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#16438; Package emacs. (Tue, 14 Jan 2014 08:18:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juri Linkov <juri <at> jurta.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 14 Jan 2014 08:18:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.3.50; `C-x TAB right right' fails with error (mark-inactive)
Date: Tue, 14 Jan 2014 10:14:07 +0200
1. emacs -Q
2. Paste to *scratch*:

(custom-set-variables
 '(mark-even-if-inactive nil))

3. Eval it.
4. Put point at its opening paren and type:

C-M-SPC    - selects the whole expression
C-x TAB    - activates a transient indentation mode
right      - adjusts indentation 1 position to the right
right      - fails with the error "The mark is not active now"
             because the previous `right' key deactivated the region

One way to fix this is not to deactivate the mark in this transient mode:

=== modified file 'lisp/indent.el'
--- lisp/indent.el	2014-01-13 05:03:31 +0000
+++ lisp/indent.el	2014-01-14 08:07:55 +0000
@@ -214,7 +214,9 @@ (defun indent-rigidly (start end arg &op
               (indent-to (max 0 (+ indent (prefix-numeric-value arg))) 0))
           (delete-region (point) (progn (skip-chars-forward " \t") (point))))
         (forward-line 1))
-      (move-marker end nil))))
+      (move-marker end nil)
+      (when (eq overriding-terminal-local-map indent-rigidly-map)
+	(setq deactivate-mark nil)))))


But the condition of checking for the transient mode doesn't work
because overriding-terminal-local-map never equals to indent-rigidly-map.

 indent-rigidly-map:
  (keymap (S-right . indent-rigidly-right-to-tab-stop) (S-left . indent-rigidly-left-to-tab-stop) (right . indent-rigidly-right) (left . indent-rigidly-left))

 overriding-terminal-local-map:
  (keymap (keymap (S-right . indent-rigidly-right-to-tab-stop) (S-left . indent-rigidly-left-to-tab-stop) (right . indent-rigidly-right) (left . indent-rigidly-left))
          add-keymap-witness)

There is some `add-keymap-witness' at the end of `overriding-terminal-local-map'
when the transient indentation mode is active.  And I don't know another way
to check if `overriding-terminal-local-map' is active.




Reply sent to Juri Linkov <juri <at> jurta.org>:
You have taken responsibility. (Wed, 15 Jan 2014 08:29:02 GMT) Full text and rfc822 format available.

Notification sent to Juri Linkov <juri <at> jurta.org>:
bug acknowledged by developer. (Wed, 15 Jan 2014 08:29:04 GMT) Full text and rfc822 format available.

Message #10 received at 16438-done <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: 16438-done <at> debbugs.gnu.org
Subject: Re: bug#16438: 24.3.50;
 `C-x TAB right right' fails with error (mark-inactive)
Date: Wed, 15 Jan 2014 10:23:11 +0200
> But the condition of checking for the transient mode doesn't work
> because overriding-terminal-local-map never equals to indent-rigidly-map.
>
>  indent-rigidly-map:
>   (keymap (S-right . indent-rigidly-right-to-tab-stop) (S-left . indent-rigidly-left-to-tab-stop) (right . indent-rigidly-right) (left . indent-rigidly-left))
>
>  overriding-terminal-local-map:
>   (keymap (keymap (S-right . indent-rigidly-right-to-tab-stop) (S-left . indent-rigidly-left-to-tab-stop) (right . indent-rigidly-right) (left . indent-rigidly-left))
>           add-keymap-witness)

I fixed this by using (eq (cadr overriding-terminal-local-map) indent-rigidly-map)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16438; Package emacs. (Wed, 15 Jan 2014 15:32:01 GMT) Full text and rfc822 format available.

Message #13 received at 16438 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: 16438 <at> debbugs.gnu.org
Cc: juri <at> jurta.org
Subject: Re: bug#16438: 24.3.50;
 `C-x TAB right right' fails with error (mark-inactive)
Date: Wed, 15 Jan 2014 10:31:47 -0500
> I fixed this by using (eq (cadr overriding-terminal-local-map) indent-rigidly-map)

That's hideous, tho :-(


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16438; Package emacs. (Thu, 16 Jan 2014 08:10:03 GMT) Full text and rfc822 format available.

Message #16 received at 16438 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 16438 <at> debbugs.gnu.org
Subject: Re: bug#16438: 24.3.50;
 `C-x TAB right right' fails with error (mark-inactive)
Date: Thu, 16 Jan 2014 09:53:12 +0200
>> I fixed this by using (eq (cadr overriding-terminal-local-map) indent-rigidly-map)
>
> That's hideous, tho :-(

I borrowed this condition from

    (not (eq map (cadr overriding-terminal-local-map)))

in `set-transient-map' that checks if the transient map is in effect.

Maybe it should be refactored to a separate predicate function.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16438; Package emacs. (Thu, 16 Jan 2014 14:01:01 GMT) Full text and rfc822 format available.

Message #19 received at 16438 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Juri Linkov <juri <at> jurta.org>
Cc: 16438 <at> debbugs.gnu.org
Subject: Re: bug#16438: 24.3.50;
 `C-x TAB right right' fails with error (mark-inactive)
Date: Thu, 16 Jan 2014 09:00:41 -0500
>>> I fixed this by using (eq (cadr overriding-terminal-local-map) indent-rigidly-map)
>> That's hideous, tho :-(
> I borrowed this condition from
>     (not (eq map (cadr overriding-terminal-local-map)))

I know.  But it has problems:
- if there's a nested use of set-transient-map (e.g. C-u), your code will
  deactivate the mark even tho we're not finished with C-x TAB.
- it relies on internal details of implementation of set-transient-map.
- now C-x TAB does not deactivate the mark any more :-(

> Maybe it should be refactored to a separate predicate function.

Could be, tho the two tests need to be different.
Another option is to move the deactivation into the exit condition.
Yet another option is to change C-x TAB so that it uses (mark t) when
called repeatedly.

I'm not sure exactly how the deactivation should behave, tho:
- The current behavior seems wrong: C-x TAB does use the region, so it
  should "consume it", so C-x TAB right right right up should end with
  a deactivated region.
- But should the region be highlighted *during* C-x TAB?  If yes, then
  we have a conflict with the previous point, since just before hitting
  `up' the region would still need to be highlighted, so it'd be counter
  intuitive to deactivate the region right between when the user hits
  `up' and when we run the corresponding `previous-line' command.

So I think that the region should *not* be highlighted during C-x TAB.
Which implies using (mark t).


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16438; Package emacs. (Fri, 17 Jan 2014 08:10:02 GMT) Full text and rfc822 format available.

Message #22 received at 16438 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 16438 <at> debbugs.gnu.org
Subject: Re: bug#16438: 24.3.50;
 `C-x TAB right right' fails with error (mark-inactive)
Date: Fri, 17 Jan 2014 10:08:24 +0200
> - But should the region be highlighted *during* C-x TAB?

When the user selects a region, this indicates the intention
to run the next command on the selected region.  So when
a command is going to operate on the region the user should have
the clear indication beforehand to avoid surprises.

Highlighting the region in transient indentation mode is
especially important since this is a new feature,
and without highlighting an unsuspecting user don't know that
a subsequent `right' will operate on the previously selected region.

For the same reason I think the exit condition should not
deactivate the active region because the highlighting
indicates that the next command is operating on the region.

The same problem with exiting the transient indentation mode
happens when the user needs to type the `right' key to move point
without indentation.  Then the user has to exit the sub-mode
explicitly by typing e.g. C-g.  It will also deselect the region.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16438; Package emacs. (Fri, 17 Jan 2014 14:46:01 GMT) Full text and rfc822 format available.

Message #25 received at 16438 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Juri Linkov <juri <at> jurta.org>
Cc: 16438 <at> debbugs.gnu.org
Subject: Re: bug#16438: 24.3.50;
 `C-x TAB right right' fails with error (mark-inactive)
Date: Fri, 17 Jan 2014 09:45:14 -0500
> For the same reason I think the exit condition should not
> deactivate the active region because the highlighting
> indicates that the next command is operating on the region.

Indeed, that's the problem with keeping the highlighting, since, this
means that C-x TAB will not "consume" the region, which is unusual and
inconvenient: after C-x TAB right right right, the user will often have
to use C-g to deactivate the region :-(


        Stefan




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 15 Feb 2014 12:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 95 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.