help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to programmatically highlight region?


From: Mirko
Subject: Re: How to programmatically highlight region?
Date: 17 Nov 2006 18:35:30 -0800
User-agent: G2/1.0

Perry Smith wrote:
> 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
>
>
Um, could someone comment on how to accomplish the following:

If I have a string such as "self.foo" I would like to see only
foo(underlined), i.e. make the "self." invisible, and change the
appearance of foo.

I think I understand how I could change the appearance of foo, but the
info on invisibility left me confused as how I can hide text.

Thanks,

Mirko



reply via email to

[Prev in Thread] Current Thread [Next in Thread]