unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: [rutt+news@cis.ohio-state.edu: [patch] factor out comment-or-uncomment feature from comment-dwim]
       [not found] <200204072343.g37NhcO20159@aztec.santafe.edu>
@ 2002-04-08 22:13 ` Stefan Monnier
  2002-04-09  0:18   ` Benjamin Rutt
                     ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Stefan Monnier @ 2002-04-08 22:13 UTC (permalink / raw)
  Cc: Benjamin Rutt

> Would you please DTRT here?

The patch looks fine to me.

On a related note:
how about a transient form of transient-mark-mode ?
We agreed that it would be desirable a while back, but the concrete details
weren't clear at the time.  I have a more concrete proposal now:

--- simple.el	7 Apr 2002 10:10:23 -0000	1.533
+++ simple.el	8 Apr 2002 22:06:00 -0000
@@ -2233,11 +2270,19 @@
   "Deactivate the mark by setting `mark-active' to nil.
 \(That makes a difference only in Transient Mark mode.)
 Also runs the hook `deactivate-mark-hook'."
-  (if transient-mark-mode
-      (progn
+  (cond
+   ((eq transient-mark-mode 'lambda)
+    (setq transient-mark-mode nil))
+   (transient-mark-mode
 	(setq mark-active nil)
 	(run-hooks 'deactivate-mark-hook))))
 
+(defun mark-and-highlight ()
+  "Set the mark and temporarily activate `transient-mark-mode'."
+  (interactive)
+  (setq transient-mark-mode 'lambda)
+  (push-mark nil nil t))
+
 (defun set-mark (pos)
   "Set this buffer's mark to POS.  Don't use this function!
 That is to say, don't use this function unless you want


--- keyboard.c	3 Apr 2002 08:36:56 -0000	1.669
+++ keyboard.c	8 Apr 2002 22:05:22 -0000
@@ -1718,9 +1721,15 @@
 	{
 	  if (!NILP (Vdeactivate_mark) && !NILP (Vtransient_mark_mode))
 	    {
+	      /* We could also call `deactivate'mark'.  */
+	      if (EQ (Vtransient_mark_mode, Qlambda))
+		Vtransient_mark_mode = Qnil;
+	      else
+		{
 	      current_buffer->mark_active = Qnil;
 	      call1 (Vrun_hooks, intern ("deactivate-mark-hook"));
 	    }
+	    }
 	  else if (current_buffer != prev_buffer || MODIFF != prev_modiff)
 	    call1 (Vrun_hooks, intern ("activate-mark-hook"));
 	}


An alternative would be to provide

  (defun activate-and-highlight-region ()
    (setq transient-mark-mode 'lambda))

Of course we can have both activate-and-highlight-region as well as
mark-and-highlight.  Also I'm wondering where we could/should bind
these commands.  It would be nice to have it as something like
C-u C-SPC (except that this one is already taken, obviously).


-- Stefan


> ------- Start of forwarded message -------
> X-Authentication-Warning: gamma.cis.ohio-state.edu: rutt set sender to rutt@cis.ohio-state.edu using -f
> To: emacs-devel@gnu.org
> Subject: [patch] factor out comment-or-uncomment feature from comment-dwim
> From: Benjamin Rutt <rutt+news@cis.ohio-state.edu>
> Mail-Followup-To: emacs-devel@gnu.org
> Sender: emacs-devel-admin@gnu.org
> Date: Sat, 06 Apr 2002 23:19:45 -0500
> 
> During a discussion today on gnu.emacs.help, I lamented the fact that
> only emacs users who were using `transient-mark-mode' could take
> advantage of `comment-dwim's ability to detect whether a region is
> commented, and uncomment the region if so and comment the region if
> not.  I personally don't use `transient-mark-mode', but I would hate
> to lose out on `comment-dwim's neat feature just because I don't use
> `transient-mark-mode'.
> 
> An idea that came out of that discussion was to factor the
> comment-or-uncomment feature out of `comment-dwim' and place that code
> in a new function named `comment-or-uncomment-region' that would be
> callable interactively.  And then have `comment-dwim' make a call to
> `comment-or-uncomment-region' in the appropriate place.  But since
> `comment-or-uncomment-region' can also be called interactively, this
> change would make me very happy because I could gain the "comment or
> uncomment" feature of `comment-dwim' without having to use
> `transient-mark-mode'.
> 
> So I guess the question is, have I convinced the maintainer of
> newcomment.el that this change is worthwhile?
> 
> BTW, if necessary, I have signed papers for emacs already.  Here
> begins the patch, against tonight's cvs:
> 
> *** newcomment.el.~1.45.~	Sun Mar  3 20:10:55 2002
> - --- newcomment.el	Sat Apr  6 22:00:07 2002
> ***************
> *** 893,898 ****
> - --- 893,911 ----
>       (comment-region beg end (+ comment-add arg))))
>   
>   ;;;###autoload
> + (defun comment-or-uncomment-region (beg end &optional arg)
> +   "Call `comment-region', unless the region only consists of comments,
> + in which case call `uncomment-region'.  If a prefix arg is given, it
> + is passed on to the respective function."
> +   (interactive "*r\nP")
> +   (if (save-excursion ;; check for already commented region
> + 	(goto-char beg)
> + 	(comment-forward (point-max))
> + 	(<= end (point)))
> +       (uncomment-region beg end arg)
> +     (comment-region beg end arg)))
> + 
> + ;;;###autoload
>   (defun comment-dwim (arg)
>     "Call the comment command you want (Do What I Mean).
>   If the region is active and `transient-mark-mode' is on, call
> ***************
> *** 906,917 ****
>     (if (and mark-active transient-mark-mode)
>         (let ((beg (min (point) (mark)))
>   	    (end (max (point) (mark))))
> ! 	(if (save-excursion ;; check for already commented region
> ! 	      (goto-char beg)
> ! 	      (comment-forward (point-max))
> ! 	      (<= end (point)))
> ! 	    (uncomment-region beg end arg)
> ! 	  (comment-region beg end arg)))
>       (if (save-excursion (beginning-of-line) (not (looking-at "\\s-*$")))
>   	;; FIXME: If there's no comment to kill on this line and ARG is
>   	;; specified, calling comment-kill is not very clever.
> - --- 919,925 ----
>     (if (and mark-active transient-mark-mode)
>         (let ((beg (min (point) (mark)))
>   	    (end (max (point) (mark))))
> ! 	(comment-or-uncomment-region beg end))
>       (if (save-excursion (beginning-of-line) (not (looking-at "\\s-*$")))
>   	;; FIXME: If there's no comment to kill on this line and ARG is
>   	;; specified, calling comment-kill is not very clever.
> 
> - -- 
> Benjamin
> 
> _______________________________________________
> Emacs-devel mailing list
> Emacs-devel@gnu.org
> http://mail.gnu.org/mailman/listinfo/emacs-devel
> ------- End of forwarded message -------
> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [rutt+news@cis.ohio-state.edu: [patch] factor out comment-or-uncomment feature from comment-dwim]
  2002-04-08 22:13 ` [rutt+news@cis.ohio-state.edu: [patch] factor out comment-or-uncomment feature from comment-dwim] Stefan Monnier
@ 2002-04-09  0:18   ` Benjamin Rutt
  2002-04-09  9:33   ` Kai Großjohann
  2002-04-10 14:23   ` Richard Stallman
  2 siblings, 0 replies; 19+ messages in thread
From: Benjamin Rutt @ 2002-04-09  0:18 UTC (permalink / raw)


"Stefan Monnier" <monnier+inbox@RUM.cs.yale.edu> writes:

> The patch looks fine to me.

Thank you for installing the patch.  Me and my
non-transient-mark-mode-using cohorts will be grateful.
-- 
Benjamin

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [rutt+news@cis.ohio-state.edu: [patch] factor out comment-or-uncomment feature from comment-dwim]
  2002-04-08 22:13 ` [rutt+news@cis.ohio-state.edu: [patch] factor out comment-or-uncomment feature from comment-dwim] Stefan Monnier
  2002-04-09  0:18   ` Benjamin Rutt
@ 2002-04-09  9:33   ` Kai Großjohann
  2002-04-10 14:23   ` Richard Stallman
  2 siblings, 0 replies; 19+ messages in thread
From: Kai Großjohann @ 2002-04-09  9:33 UTC (permalink / raw)
  Cc: emacs-devel, Benjamin Rutt

"Stefan Monnier" <monnier+inbox@RUM.cs.yale.edu> writes:

> Of course we can have both activate-and-highlight-region as well as
> mark-and-highlight.  Also I'm wondering where we could/should bind
> these commands.  It would be nice to have it as something like
> C-u C-SPC (except that this one is already taken, obviously).

C-u C-u C-SPC is still free, I think.

kai
-- 
Silence is foo!

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [rutt+news@cis.ohio-state.edu: [patch] factor out comment-or-uncomment feature from comment-dwim]
  2002-04-08 22:13 ` [rutt+news@cis.ohio-state.edu: [patch] factor out comment-or-uncomment feature from comment-dwim] Stefan Monnier
  2002-04-09  0:18   ` Benjamin Rutt
  2002-04-09  9:33   ` Kai Großjohann
@ 2002-04-10 14:23   ` Richard Stallman
  2002-04-10 16:36     ` Stefan Monnier
  2 siblings, 1 reply; 19+ messages in thread
From: Richard Stallman @ 2002-04-10 14:23 UTC (permalink / raw)
  Cc: emacs-delvel, emacs-devel, rutt+news

    On a related note:
    how about a transient form of transient-mark-mode ?
    We agreed that it would be desirable a while back, but the concrete details
    weren't clear at the time.  I have a more concrete proposal now:

How would you use this?

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [rutt+news@cis.ohio-state.edu: [patch] factor out comment-or-uncomment feature from comment-dwim]
  2002-04-10 14:23   ` Richard Stallman
@ 2002-04-10 16:36     ` Stefan Monnier
  2002-04-10 21:25       ` Kim F. Storm
  0 siblings, 1 reply; 19+ messages in thread
From: Stefan Monnier @ 2002-04-10 16:36 UTC (permalink / raw)
  Cc: monnier+inbox, emacs-delvel, emacs-devel, rutt+news

>     On a related note:
>     how about a transient form of transient-mark-mode ?
>     We agreed that it would be desirable a while back, but the concrete details
>     weren't clear at the time.  I have a more concrete proposal now:
> 
> How would you use this?

With transient-mark-mode, you can do

	C-SPC ...move... M-;

With the code I sent, people who don't have transient-mark-mode turned on
can still use the comment-region behavior of M-; by doing:

	M-x mark-and-highlight RET ...move... M-;
or
	C-SPC ...move... M-x activate-and-highlight-region RET M-;

This could also be used with other functions who operate on the
region only when transient-mark-mode is turned ON.

Both mark-and-highlight and activate-and-highlight-region are useful and
they should both be provided.  The question is mostly where to bind those
two commands.  I wish mark-and-highlight could be bound to something
similar to C-u SPC and I think that activate-and-highlight-region could
be bound to C-u C-x C-x.


	Stefan

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [rutt+news@cis.ohio-state.edu: [patch] factor out comment-or-uncomment feature from comment-dwim]
  2002-04-10 21:25       ` Kim F. Storm
@ 2002-04-10 20:39         ` Stefan Monnier
  2002-04-10 21:18         ` Kai Großjohann
  2002-04-10 21:39         ` Kim F. Storm
  2 siblings, 0 replies; 19+ messages in thread
From: Stefan Monnier @ 2002-04-10 20:39 UTC (permalink / raw)
  Cc: Stefan Monnier, Richard Stallman, emacs-devel, rutt+news

> "Stefan Monnier" <monnier+gnu/emacs@RUM.cs.yale.edu> writes:
> 
> > >     On a related note:
> > >     how about a transient form of transient-mark-mode ?
> > >     We agreed that it would be desirable a while back, but the concrete details
> > >     weren't clear at the time.  I have a more concrete proposal now:
> > > 
> > > How would you use this?
> > 
> > With transient-mark-mode, you can do
> > 
> > 	C-SPC ...move... M-;
> > 
> > With the code I sent, people who don't have transient-mark-mode turned on
> > can still use the comment-region behavior of M-; by doing:
> > 
> > 	M-x mark-and-highlight RET ...move... M-;
> > or
> > 	C-SPC ...move... M-x activate-and-highlight-region RET M-;
> > 
> > This could also be used with other functions who operate on the
> > region only when transient-mark-mode is turned ON.
> > 
> > Both mark-and-highlight and activate-and-highlight-region are useful and
> > they should both be provided.  The question is mostly where to bind those
> > two commands.  I wish mark-and-highlight could be bound to something
> > similar to C-u SPC and I think that activate-and-highlight-region could
> > be bound to C-u C-x C-x.
> 
> I don't see why both functions are necessary!

I'm thinking of cases where the region is not marked with C-SPC and
cursor movement but with mark-sexp or mark-paragraph instead.

> What about this modification to set-mark-command which simply turns on
> transient-mark-command (temporarily) if you repeat C-SPC immediately.
> If you move the mark with another C-SPC, transient-mark-mode is
> turned off again (enter another C-SPC to reenable it):

Great idea!


	Stefan

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [rutt+news@cis.ohio-state.edu: [patch] factor out comment-or-uncomment feature from comment-dwim]
  2002-04-10 21:25       ` Kim F. Storm
  2002-04-10 20:39         ` Stefan Monnier
@ 2002-04-10 21:18         ` Kai Großjohann
  2002-04-11  9:37           ` Kim F. Storm
  2002-04-10 21:39         ` Kim F. Storm
  2 siblings, 1 reply; 19+ messages in thread
From: Kai Großjohann @ 2002-04-10 21:18 UTC (permalink / raw)
  Cc: Stefan Monnier, Richard Stallman, emacs-devel, rutt+news

storm@cua.dk (Kim F. Storm) writes:

> What about this modification to set-mark-command which simply turns on
> transient-mark-command (temporarily) if you repeat C-SPC immediately.

It would also work the other way round: if transient-mark-mode is
turned on, C-SPC once could do what it does now, but C-SPC twice
could deactivate the highlighting.

It appears that the problem with transient-mark-mode, for people who
do not like it, is: if you use C-SPC so that you can later can come
back to that spot with C-u C-SPC, then move the cursor, then there
will be a useless and visually disturbing highlight.

Myself, I use C-SPC C-g in such cases, but maybe C-SPC C-SPC is more
intuitive?

Opinions?

kai
-- 
Silence is foo!

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [rutt+news@cis.ohio-state.edu: [patch] factor out comment-or-uncomment feature from comment-dwim]
  2002-04-10 16:36     ` Stefan Monnier
@ 2002-04-10 21:25       ` Kim F. Storm
  2002-04-10 20:39         ` Stefan Monnier
                           ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Kim F. Storm @ 2002-04-10 21:25 UTC (permalink / raw)
  Cc: Richard Stallman, emacs-devel, rutt+news

"Stefan Monnier" <monnier+gnu/emacs@RUM.cs.yale.edu> writes:

> >     On a related note:
> >     how about a transient form of transient-mark-mode ?
> >     We agreed that it would be desirable a while back, but the concrete details
> >     weren't clear at the time.  I have a more concrete proposal now:
> > 
> > How would you use this?
> 
> With transient-mark-mode, you can do
> 
> 	C-SPC ...move... M-;
> 
> With the code I sent, people who don't have transient-mark-mode turned on
> can still use the comment-region behavior of M-; by doing:
> 
> 	M-x mark-and-highlight RET ...move... M-;
> or
> 	C-SPC ...move... M-x activate-and-highlight-region RET M-;
> 
> This could also be used with other functions who operate on the
> region only when transient-mark-mode is turned ON.
> 
> Both mark-and-highlight and activate-and-highlight-region are useful and
> they should both be provided.  The question is mostly where to bind those
> two commands.  I wish mark-and-highlight could be bound to something
> similar to C-u SPC and I think that activate-and-highlight-region could
> be bound to C-u C-x C-x.
> 

I don't see why both functions are necessary!

What about this modification to set-mark-command which simply turns on
transient-mark-command (temporarily) if you repeat C-SPC immediately.
If you move the mark with another C-SPC, transient-mark-mode is
turned off again (enter another C-SPC to reenable it):

(defun set-mark-command (arg)
  (interactive "P")
  (if (null arg)
      (if (eq this-command last-command)
          (setq transient-mark-mode 'lambda)
        (setq transient-mark-mode nil)
	(push-mark nil nil t))
    (if (null (mark t))
	(error "No mark set in this buffer")
      (goto-char (mark t))
      (pop-mark))))

I.e. you can use

        C-SPC C-SPC .....  M-;


-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [rutt+news@cis.ohio-state.edu: [patch] factor out comment-or-uncomment feature from comment-dwim]
  2002-04-10 21:25       ` Kim F. Storm
  2002-04-10 20:39         ` Stefan Monnier
  2002-04-10 21:18         ` Kai Großjohann
@ 2002-04-10 21:39         ` Kim F. Storm
  2 siblings, 0 replies; 19+ messages in thread
From: Kim F. Storm @ 2002-04-10 21:39 UTC (permalink / raw)
  Cc: Richard Stallman, emacs-devel, rutt+news

storm@cua.dk (Kim F. Storm) writes:

> What about this modification to set-mark-command which simply turns on
> transient-mark-command (temporarily) if you repeat C-SPC immediately.
> If you move the mark with another C-SPC, transient-mark-mode is
> turned off again (enter another C-SPC to reenable it):
> 
> (defun set-mark-command (arg)
>   (interactive "P")
>   (if (null arg)
>       (if (eq this-command last-command)
>           (setq transient-mark-mode 'lambda)
>         (setq transient-mark-mode nil)
> 	(push-mark nil nil t))
>     (if (null (mark t))
> 	(error "No mark set in this buffer")
>       (goto-char (mark t))
>       (pop-mark))))
> 

This will disturb users who does use transient-mark-mode.
A proper definition would be:

(defun set-mark-command (arg)
  (interactive "P")
  (if (null arg)
      (if (eq this-command last-command)
          (if (not transient-mark-mode)
              (setq transient-mark-mode 'lambda))
        (if (eq transient-mark-mode 'lambda)
            (setq transient-mark-mode nil))
        (push-mark nil nil t))
    (if (null (mark t))
        (error "No mark set in this buffer")
      (goto-char (mark t))
      (pop-mark))))

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [rutt+news@cis.ohio-state.edu: [patch] factor out comment-or-uncomment feature from comment-dwim]
  2002-04-10 21:18         ` Kai Großjohann
@ 2002-04-11  9:37           ` Kim F. Storm
  2002-04-11  9:48             ` Francesco Potorti`
                               ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Kim F. Storm @ 2002-04-11  9:37 UTC (permalink / raw)
  Cc: Stefan Monnier, Richard Stallman, emacs-devel, rutt+news

Kai.Grossjohann@CS.Uni-Dortmund.DE (Kai Großjohann) writes:

> storm@cua.dk (Kim F. Storm) writes:
> 
> > What about this modification to set-mark-command which simply turns on
> > transient-mark-command (temporarily) if you repeat C-SPC immediately.
> 
> It would also work the other way round: if transient-mark-mode is
> turned on, C-SPC once could do what it does now, but C-SPC twice
> could deactivate the highlighting.
> 
> It appears that the problem with transient-mark-mode, for people who
> do not like it, is: if you use C-SPC so that you can later can come
> back to that spot with C-u C-SPC, then move the cursor, then there
> will be a useless and visually disturbing highlight.
> 
> Myself, I use C-SPC C-g in such cases, but maybe C-SPC C-SPC is more
> intuitive?

What about this version:

(defun set-mark-command (arg)
  (interactive "P")
  (if arg (setq arg 1))
  (if (eq this-command last-command)
      (cond
       (last-prefix-arg
	(if arg
	    (setq current-prefix-arg nil
		  arg nil)
	  (setq current-prefix-arg last-prefix-arg)
	  (setq arg 1)))
       (arg
	(setq arg nil))
       ((eq transient-mark-mode 'lambda)
	(setq transient-mark-mode nil))
       (transient-mark-mode
	(setq deactivate-mark t))
       (t
	(setq transient-mark-mode 'lambda)
	(setq arg 0))))
  (cond
   ((null arg)
    (if (eq transient-mark-mode 'lambda)
	(setq transient-mark-mode nil))
    (push-mark nil nil t))
   ((= arg 0))
   ((null (mark t))
    (error "No mark set in this buffer"))
   (t    
    (goto-char (mark t))
    (pop-mark))))

With transient-mark-mode off (nil), C-SPC C-SPC temporarily turns on
transient-mark-mode (lambda), and another C-SPC turns it off (and
moves the mark).

With transient-mark-mode on (t), C-SPC C-SPC sets and deactivates the mark.

As an added bonus, C-u C-SPC C-SPC C-SPC will pop back through the
mark stack, i.e. only the first command needs the C-u prefix.

To set (reactivate) the mark immedately following a series of 
C-u C-SPC C-SPC C-SPC C-SPC C-SPC commands, use C-u C-SPC (or
C-u C-SPC C-SPC to toggle transient-mark-mode).

This is a significant deviation from the old behaviour of C-u C-SPC,
but the new functionality is much easier to use...!

Opinions?

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [rutt+news@cis.ohio-state.edu: [patch] factor out comment-or-uncomment feature from comment-dwim]
  2002-04-11  9:37           ` Kim F. Storm
@ 2002-04-11  9:48             ` Francesco Potorti`
  2002-04-11 11:49               ` Kim F. Storm
  2002-04-11 13:05             ` Stefan Monnier
  2002-04-12  3:12             ` Richard Stallman
  2 siblings, 1 reply; 19+ messages in thread
From: Francesco Potorti` @ 2002-04-11  9:48 UTC (permalink / raw)
  Cc: Kai Großjohann, Stefan Monnier, Richard Stallman,
	emacs-devel, rutt+news

storm@cua.dk (Kim F. Storm) writes:
   
   With transient-mark-mode off (nil), C-SPC C-SPC temporarily turns on
   transient-mark-mode (lambda), and another C-SPC turns it off (and
   moves the mark).

Wonderful.
   
   With transient-mark-mode on (t), C-SPC C-SPC sets and deactivates the mark.
   
I think that's good, too.

   As an added bonus, C-u C-SPC C-SPC C-SPC will pop back through the
   mark stack, i.e. only the first command needs the C-u prefix.
   
Not bad at all.  Yes, a nice idea.

   To set (reactivate) the mark immedately following a series of 
   C-u C-SPC C-SPC C-SPC C-SPC C-SPC commands, use C-u C-SPC (or
   C-u C-SPC C-SPC to toggle transient-mark-mode).
   
Or even just give any other command, right?

   This is a significant deviation from the old behaviour of C-u C-SPC,
   but the new functionality is much easier to use...!
   
Yes, I think so.  Only sophisticated users know about C-u C-SPC, so
this problem may not be serious.  On the other hand, working with
Emacses of different versions could be annoying.  But overall I like
the idea.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [rutt+news@cis.ohio-state.edu: [patch] factor out comment-or-uncomment feature from comment-dwim]
  2002-04-11  9:48             ` Francesco Potorti`
@ 2002-04-11 11:49               ` Kim F. Storm
  0 siblings, 0 replies; 19+ messages in thread
From: Kim F. Storm @ 2002-04-11 11:49 UTC (permalink / raw)
  Cc: Kai Großjohann, Stefan Monnier, Richard Stallman,
	emacs-devel, rutt+news

Francesco Potorti` <pot@gnu.org> writes:

>    To set (reactivate) the mark immedately following a series of 
>    C-u C-SPC C-SPC C-SPC C-SPC C-SPC commands, use C-u C-SPC (or
>    C-u C-SPC C-SPC to toggle transient-mark-mode).
>    
> Or even just give any other command, right?

Of course, but this makes it `self-contained'.

In any case, I don't know whether this may break other lisp
packages which calls set-mark-command.  Maybe it should check
with (eq last-command 'set-mark-command) to be sure...?

> 
>    This is a significant deviation from the old behaviour of C-u C-SPC,
>    but the new functionality is much easier to use...!
>    
> Yes, I think so.  Only sophisticated users know about C-u C-SPC, so
> this problem may not be serious.  On the other hand, working with
> Emacses of different versions could be annoying.  But overall I like
> the idea.

Revolution vs. evolution :-)

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [rutt+news@cis.ohio-state.edu: [patch] factor out comment-or-uncomment feature from comment-dwim]
  2002-04-11  9:37           ` Kim F. Storm
  2002-04-11  9:48             ` Francesco Potorti`
@ 2002-04-11 13:05             ` Stefan Monnier
  2002-04-12  3:12             ` Richard Stallman
  2 siblings, 0 replies; 19+ messages in thread
From: Stefan Monnier @ 2002-04-11 13:05 UTC (permalink / raw)
  Cc: Kai Großjohann, Stefan Monnier, Richard Stallman,
	emacs-devel, rutt+news

> As an added bonus, C-u C-SPC C-SPC C-SPC will pop back through the
> mark stack, i.e. only the first command needs the C-u prefix.

Sounds great.


	Stefan

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [rutt+news@cis.ohio-state.edu: [patch] factor out comment-or-uncomment feature from comment-dwim]
  2002-04-11  9:37           ` Kim F. Storm
  2002-04-11  9:48             ` Francesco Potorti`
  2002-04-11 13:05             ` Stefan Monnier
@ 2002-04-12  3:12             ` Richard Stallman
  2002-04-12  9:45               ` Kim F. Storm
  2 siblings, 1 reply; 19+ messages in thread
From: Richard Stallman @ 2002-04-12  3:12 UTC (permalink / raw)
  Cc: Kai.Grossjohann, monnier+gnu/emacs, emacs-devel, rutt+news

    This is a significant deviation from the old behaviour of C-u C-SPC,
    but the new functionality is much easier to use...!

I think it is good, but I think we should also look at the idea
of changing C-x C-x in a similar way:
doing it twice would temporarily enable transient-mark-mode.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [rutt+news@cis.ohio-state.edu: [patch] factor out comment-or-uncomment feature from comment-dwim]
  2002-04-12  3:12             ` Richard Stallman
@ 2002-04-12  9:45               ` Kim F. Storm
  2002-04-12 18:46                 ` Stefan Monnier
  2002-04-13 19:06                 ` Richard Stallman
  0 siblings, 2 replies; 19+ messages in thread
From: Kim F. Storm @ 2002-04-12  9:45 UTC (permalink / raw)
  Cc: emacs-devel, rutt+news

Richard Stallman <rms@gnu.org> writes:

>     This is a significant deviation from the old behaviour of C-u C-SPC,
>     but the new functionality is much easier to use...!
> 
> I think it is good, but I think we should also look at the idea
> of changing C-x C-x in a similar way:
> doing it twice would temporarily enable transient-mark-mode.

I don't see any problems doing that, and I think it is complements
the changes to C-SPC very well.  Here is a version which does that:

(defun exchange-point-and-mark ()
  "Put the mark where point is now, and point where the mark is now.
This command works even when the mark is not active,
and it reactivates the mark.
If the command is repeated immediately, `transient-mark-mode' is
enabled temporarily."
  (interactive nil)
  (let ((omark (mark t)))
    (if (null omark)
	(error "No mark set in this buffer"))
    (set-mark (point))
    (goto-char omark)
    (if (and (not transient-mark-mode)
             (eq this-command last-command))
        (setq transient-mark-mode 'lambda))
    nil))


Should I install it (together with the new set-mark-command)?
This is still requires some of Stefan's original suggestion:

--- simple.el	7 Apr 2002 10:10:23 -0000	1.533
+++ simple.el	8 Apr 2002 22:06:00 -0000
@@ -2233,11 +2270,19 @@
   "Deactivate the mark by setting `mark-active' to nil.
 \(That makes a difference only in Transient Mark mode.)
 Also runs the hook `deactivate-mark-hook'."
-  (if transient-mark-mode
-      (progn
+  (cond
+   ((eq transient-mark-mode 'lambda)
+    (setq transient-mark-mode nil))
+   (transient-mark-mode
 	(setq mark-active nil)
 	(run-hooks 'deactivate-mark-hook))))
 
--- keyboard.c	3 Apr 2002 08:36:56 -0000	1.669
+++ keyboard.c	8 Apr 2002 22:05:22 -0000
@@ -1718,9 +1721,15 @@
 	{
 	  if (!NILP (Vdeactivate_mark) && !NILP (Vtransient_mark_mode))
 	    {
+	      /* We could also call `deactivate'mark'.  */
+	      if (EQ (Vtransient_mark_mode, Qlambda))
+		Vtransient_mark_mode = Qnil;
+	      else
+		{
 	      current_buffer->mark_active = Qnil;
 	      call1 (Vrun_hooks, intern ("deactivate-mark-hook"));
 	    }
+	    }
 	  else if (current_buffer != prev_buffer || MODIFF != prev_modiff)
 	    call1 (Vrun_hooks, intern ("activate-mark-hook"));
 	}


-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [rutt+news@cis.ohio-state.edu: [patch] factor out comment-or-uncomment feature from comment-dwim]
  2002-04-12  9:45               ` Kim F. Storm
@ 2002-04-12 18:46                 ` Stefan Monnier
  2002-04-13 19:06                 ` Richard Stallman
  1 sibling, 0 replies; 19+ messages in thread
From: Stefan Monnier @ 2002-04-12 18:46 UTC (permalink / raw)
  Cc: rms, emacs-devel, rutt+news

> Should I install it (together with the new set-mark-command)?

I think so.

> This is still requires some of Stefan's original suggestion:

I've already installed the C part.


	Stefan

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [rutt+news@cis.ohio-state.edu: [patch] factor out comment-or-uncomment feature from comment-dwim]
  2002-04-12  9:45               ` Kim F. Storm
  2002-04-12 18:46                 ` Stefan Monnier
@ 2002-04-13 19:06                 ` Richard Stallman
  2002-04-14 21:32                   ` Kim F. Storm
  1 sibling, 1 reply; 19+ messages in thread
From: Richard Stallman @ 2002-04-13 19:06 UTC (permalink / raw)
  Cc: emacs-devel, rutt+news

    Should I install it (together with the new set-mark-command)?

Please install both.  Thanks.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [rutt+news@cis.ohio-state.edu: [patch] factor out comment-or-uncomment feature from comment-dwim]
  2002-04-13 19:06                 ` Richard Stallman
@ 2002-04-14 21:32                   ` Kim F. Storm
  2002-04-16 20:18                     ` Richard Stallman
  0 siblings, 1 reply; 19+ messages in thread
From: Kim F. Storm @ 2002-04-14 21:32 UTC (permalink / raw)
  Cc: emacs-devel, rutt+news

Richard Stallman <rms@gnu.org> writes:

>     Should I install it (together with the new set-mark-command)?
> 
> Please install both.  Thanks.

I have committed changes to implement this (not quite the code
I posted here, as I found various subtle problems with having to
depend on the prefix arg of the last command.)

Note that C-u C-x C-x will now activate transient-mark-mode without
exchanging point or mark.  This works much better than the proposed
C-x C-x C-x C-x (in case you want to do that just to see where the
mark is).

Also, C-u C-SPC always jumps to mark and pop, also when it follows
a previous C-u C-SPC command.  I found it too confusing to change the
semantics of C-u C-SPC  (it seems to be hardwired into by brain).
So now C-u C-SPC C-SPC ... and C-u C-SPC C-u C-SPC ... works the same.

To set the mark following C-u C-SPC ... use C-u C-u C-SPC (or exec
some other command first).

To make this work reliable, there are new commands push-mark-command
which always sets the mark, and pop-to-mark-command which jumps to
mark and pop.  set-mark-command now uses either of these depending on
the state, the last command, and the prefix arg.

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [rutt+news@cis.ohio-state.edu: [patch] factor out comment-or-uncomment feature from comment-dwim]
  2002-04-14 21:32                   ` Kim F. Storm
@ 2002-04-16 20:18                     ` Richard Stallman
  0 siblings, 0 replies; 19+ messages in thread
From: Richard Stallman @ 2002-04-16 20:18 UTC (permalink / raw)
  Cc: emacs-devel, rutt+news

Thanks for getting this done.

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2002-04-16 20:18 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <200204072343.g37NhcO20159@aztec.santafe.edu>
2002-04-08 22:13 ` [rutt+news@cis.ohio-state.edu: [patch] factor out comment-or-uncomment feature from comment-dwim] Stefan Monnier
2002-04-09  0:18   ` Benjamin Rutt
2002-04-09  9:33   ` Kai Großjohann
2002-04-10 14:23   ` Richard Stallman
2002-04-10 16:36     ` Stefan Monnier
2002-04-10 21:25       ` Kim F. Storm
2002-04-10 20:39         ` Stefan Monnier
2002-04-10 21:18         ` Kai Großjohann
2002-04-11  9:37           ` Kim F. Storm
2002-04-11  9:48             ` Francesco Potorti`
2002-04-11 11:49               ` Kim F. Storm
2002-04-11 13:05             ` Stefan Monnier
2002-04-12  3:12             ` Richard Stallman
2002-04-12  9:45               ` Kim F. Storm
2002-04-12 18:46                 ` Stefan Monnier
2002-04-13 19:06                 ` Richard Stallman
2002-04-14 21:32                   ` Kim F. Storm
2002-04-16 20:18                     ` Richard Stallman
2002-04-10 21:39         ` Kim F. Storm

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).