all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Perry Smith <pedz@easesoftware.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: How to programmatically highlight region?
Date: Wed, 15 Nov 2006 18:50:22 -0600	[thread overview]
Message-ID: <A090F2DA-0F2A-4A28-9522-A62ECDBF7DF9@easesoftware.com> (raw)
In-Reply-To: <87lkmcqqc3.fsf@pereiro.luannocracy.com>


[-- Attachment #1.1: Type: text/plain, Size: 1720 bytes --]

On Nov 15, 2006, at 4:48 PM, David Abrahams wrote:

> Perry Smith <pedz@easesoftware.com> writes:
>
>> On Nov 15, 2006, at 2:10 PM, David Abrahams wrote:
>>
>>     Hi,
>>
>>     Could someone tell me how to get the effect of an "activated  
>> mark" in
>>     transient mark mode from within elisp?  In other words, I'd  
>> like to be
>>     able to set up the point and mark, and when my elisp  
>> completes, see
>>     the region highlighted.  Seems like it should be simple, but  
>> nothing I
>>     do seems to work.
>>
>> You might be asking how transient mark mode works.
>
> I don't think that's what I'm asking.
>
>> It seems to be just a variable that commands look at.  But this
>> works for me:
>>
>> (defun dog-test ()
>>  (interactive)
>>  (transient-mark-mode 1)
>>  (set-mark (point))
>>  (forward-char 20))
>>
>> execute dog-test from the minibuffer and the current point plus 20
>> characters are highlighted
>
> Not for me. :(
>
> Thanks for responding.

I felt challenged :-)

You make a face.  Put the attributes that you want in it.  Then use  
put-text-property to apply that face to the region.

(make-face 'my-blue-face)

(set-face-attribute 'my-blue-face nil :background "blue")

(defun dog-test3 ()
   (interactive)
   (put-text-property (point) (mark) 'face 'my-blue-face))

Set your mark and point, then do M-x dog-test3

There is something I don't understand though.  If you have font-lock- 
mode set, then it does not work.  I'm not sure what is happening in  
that case.  I'm curious to see if others reply.

Hope this help...
Perry Smith
Ease Software, Inc.
pedz@easesoftware.com
http://www.easesoftware.com

Low cost SATA Disk Systems for IBMs p5, pSeries, and RS/6000 AIX systems




[-- Attachment #1.2: Type: text/html, Size: 9042 bytes --]

[-- Attachment #2: Type: text/plain, Size: 152 bytes --]

_______________________________________________
help-gnu-emacs mailing list
help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs

  reply	other threads:[~2006-11-16  0:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-15 20:10 How to programmatically highlight region? David Abrahams
2006-11-15 21:41 ` Perry Smith
2006-11-15 22:48   ` David Abrahams
2006-11-16  0:50     ` Perry Smith [this message]
     [not found]     ` <mailman.691.1163638542.2155.help-gnu-emacs@gnu.org>
2006-11-18  2:35       ` Mirko
2006-11-22  9:38         ` Mathias Dahl
2006-11-22 13:36           ` Ehud Karni

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=A090F2DA-0F2A-4A28-9522-A62ECDBF7DF9@easesoftware.com \
    --to=pedz@easesoftware.com \
    --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.