From: "Stefan Monnier" <monnier+inbox@RUM.cs.yale.edu>
Cc: Benjamin Rutt <rutt+news@cis.ohio-state.edu>
Subject: Re: [rutt+news@cis.ohio-state.edu: [patch] factor out comment-or-uncomment feature from comment-dwim]
Date: Mon, 08 Apr 2002 18:13:22 -0400 [thread overview]
Message-ID: <200204082213.g38MDMd12225@rum.cs.yale.edu> (raw)
In-Reply-To: 200204072343.g37NhcO20159@aztec.santafe.edu
> 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 -------
>
next parent reply other threads:[~2002-04-08 22:13 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <200204072343.g37NhcO20159@aztec.santafe.edu>
2002-04-08 22:13 ` Stefan Monnier [this message]
2002-04-09 0:18 ` [rutt+news@cis.ohio-state.edu: [patch] factor out comment-or-uncomment feature from comment-dwim] 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200204082213.g38MDMd12225@rum.cs.yale.edu \
--to=monnier+inbox@rum.cs.yale.edu \
--cc=rutt+news@cis.ohio-state.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).