all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: help-gnu-emacs@gnu.org
Subject: Re: How to create new buffer with t-m-m active region?
Date: Sun, 05 Sep 2010 01:01:07 +0200	[thread overview]
Message-ID: <jwvtym5glmw.fsf-monnier+gnu.emacs.help@gnu.org> (raw)
In-Reply-To: mailman.7.1283625538.1782.help-gnu-emacs@gnu.org

> (defun new-buffer-w-active-region ()
>   (interactive)
>   (let ((transient-mark-mode t))
>     (switch-to-buffer (get-buffer-create "region-test"))
>     (delete-region (point-min) (point-max))
>     (insert "I want these lines\n")
>     (insert "to be in an active region with t-m-m on\n")
>     (insert "such that comment-region comments them out\n")
>     (emacs-lisp-mode)
>     (push-mark (point-min) nil 'activate)))

You need to wrap the delete-region and the inserts with (let
((deactivate-mark)) ...) so that they don't cause the mark to be
deactivated as soon as the command ends.


        Stefan


       reply	other threads:[~2010-09-04 23:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.7.1283625538.1782.help-gnu-emacs@gnu.org>
2010-09-04 23:01 ` Stefan Monnier [this message]
2010-09-04 18:38 How to create new buffer with t-m-m active region? Dan Davison
2010-09-05  0:25 ` Drew Adams
2010-09-05  3:47   ` Dan Davison

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvtym5glmw.fsf-monnier+gnu.emacs.help@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=help-gnu-emacs@gnu.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.