unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* elisp q: what functions do I need to *visually* replace string foo with bar
@ 2007-02-07 16:00 Mirko
  2007-02-07 17:24 ` anoop aryal
  2007-02-07 17:34 ` rgb
  0 siblings, 2 replies; 6+ messages in thread
From: Mirko @ 2007-02-07 16:00 UTC (permalink / raw)
  To: help-gnu-emacs; +Cc: jdsmith

Hello group,

I would like to simplify the looks of my program files (programing
language is called IDL from ITT Visual Solutions).  In these I have
many variable references of the type

*self.foo

I would like emacs to display them (when in font lock mode) with just
foo, but foo being italicized.

Could someone please point me to the relevant elisp functions that can
get me going?

Thank you,

Mirko

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

* Re: elisp q: what functions do I need to *visually* replace string foo with bar
  2007-02-07 16:00 elisp q: what functions do I need to *visually* replace string foo with bar Mirko
@ 2007-02-07 17:24 ` anoop aryal
  2007-02-07 17:34 ` rgb
  1 sibling, 0 replies; 6+ messages in thread
From: anoop aryal @ 2007-02-07 17:24 UTC (permalink / raw)
  To: help-gnu-emacs

On Wednesday 07 February 2007 10:00, Mirko wrote:
> Hello group,
>
> I would like to simplify the looks of my program files (programing
> language is called IDL from ITT Visual Solutions).  In these I have
> many variable references of the type
>
> *self.foo
>
> I would like emacs to display them (when in font lock mode) with just
> foo, but foo being italicized.
>
> Could someone please point me to the relevant elisp functions that can
> get me going?

this is not exactly what you are looking for but you may want to check out the  
glasses mode to see how they do what they do. what you are trying to do seems 
silimar albeit with different set of operands.

>
> Thank you,
>
> Mirko
>
> _______________________________________________
> help-gnu-emacs mailing list
> help-gnu-emacs@gnu.org
> http://lists.gnu.org/mailman/listinfo/help-gnu-emacs

-- 

anoop aryal
aaryal@foresightint.com

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

* Re: elisp q: what functions do I need to *visually* replace string foo with bar
  2007-02-07 16:00 elisp q: what functions do I need to *visually* replace string foo with bar Mirko
  2007-02-07 17:24 ` anoop aryal
@ 2007-02-07 17:34 ` rgb
  2007-02-07 18:43   ` David Hansen
  2007-02-08  3:12   ` Stefan Monnier
  1 sibling, 2 replies; 6+ messages in thread
From: rgb @ 2007-02-07 17:34 UTC (permalink / raw)
  To: help-gnu-emacs

On Feb 7, 10:00 am, "Mirko" <mvuko...@nycap.rr.com> wrote:
> Hello group,
>
> I would like to simplify the looks of my program files (programing
> language is called IDL from ITT Visual Solutions).  In these I have
> many variable references of the type
>
> *self.foo
>
> I would like emacs to display them (when in font lock mode) with just
> foo, but foo being italicized.
>
> Could someone please point me to the relevant elisp functions that can
> get me going?
>
> Thank you,
>
> Mirko

Making foo italic is pretty easy.
(setq font-lock-defaults
      '((("\\*self\\.\\(\\(?:\\s_\\|\\sw\\)+\\)" 1 my-italic-face))))

But making the reset invisible requires that you put the invisible
property
on the text which requires you to write a function.

For a quick fix you could just make the text invisible by just giving
it a
a face you make with foreground and background the same...

(setq font-lock-defaults
      '((("\\*self\\.\\(\\(?:\\s_\\|\\sw\\)+\\)" 1 my-italic-face)
        ("\\(\\*self\\.\\)\\(?:\\s_\\|\\sw\\)+" 1 my-invisible-face))
       ))

Perhaps someone else has an example of putting properties onto
text under font-lock control....
I don't have one handy.

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

* Re: elisp q: what functions do I need to *visually* replace string foo with bar
  2007-02-07 17:34 ` rgb
@ 2007-02-07 18:43   ` David Hansen
  2007-02-08  3:12   ` Stefan Monnier
  1 sibling, 0 replies; 6+ messages in thread
From: David Hansen @ 2007-02-07 18:43 UTC (permalink / raw)
  To: help-gnu-emacs

On 7 Feb 2007 09:34:04 -0800 rgb wrote:

> Perhaps someone else has an example of putting properties onto
> text under font-lock control....
> I don't have one handy.

Maybe this can be extended (but not sure):

http://www.emacswiki.org/cgi-bin/wiki/PrettyLambda

using overlays or text-properties may be a bit complicated as you
have to remove them if the text changes (though it might be hard to
edit this invisible text).

If the OP wants a simple solution I'd suggest using the "invisible
face" method (i would prefer something like darkgrey on black).

David

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

* Re: elisp q: what functions do I need to *visually* replace string foo with bar
  2007-02-07 17:34 ` rgb
  2007-02-07 18:43   ` David Hansen
@ 2007-02-08  3:12   ` Stefan Monnier
  2007-02-08 13:36     ` Mirko
  1 sibling, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2007-02-08  3:12 UTC (permalink / raw)
  To: help-gnu-emacs

> (setq font-lock-defaults
>       '((("\\*self\\.\\(\\(?:\\s_\\|\\sw\\)+\\)" 1 my-italic-face)
>         ("\\(\\*self\\.\\)\\(?:\\s_\\|\\sw\\)+" 1 my-invisible-face))
>        ))

This can be advantageously merged:

 (setq font-lock-keywords
       '(("\\(\\*self\\.\\)\\(\\(?:\\s_\\|\\sw\\)+\\)"
          (1 'my-invisible-face)
          (2 'italic))))

And instead of a special transparent face, you can use:

 (setq font-lock-keywords
       '(("\\(\\*self\\.\\)\\(\\(?:\\s_\\|\\sw\\)+\\)"
          (1 '(face nil invisible t))
          (2 'italic))))

but then you'll also have to add `invisible' to
`font-lock-extra-managed-props'.

And the above setting of `font-lock-keywords' is of course incorrect since
it erases any other font-lock rules of the major mode.  Maybe something like

  (add-hook 'my-idl-mode-hook
             (lambda ()
               (font-lock-add-keywords nil
                 '(("\\(\\*self\\.\\)\\(\\(?:\\s_\\|\\sw\\)+\\)"
                    (1 'my-invisible-face)
                    (2 'italic))))
               (add-to-list 'font-lock-extra-managed-props 'invisible)))

Of course the above has not been tested at all.


        Stefan

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

* Re: elisp q: what functions do I need to *visually* replace string foo with bar
  2007-02-08  3:12   ` Stefan Monnier
@ 2007-02-08 13:36     ` Mirko
  0 siblings, 0 replies; 6+ messages in thread
From: Mirko @ 2007-02-08 13:36 UTC (permalink / raw)
  To: help-gnu-emacs

On Feb 7, 10:12 pm, Stefan Monnier <monn...@iro.umontreal.ca> wrote:
> > (setq font-lock-defaults
> >       '((("\\*self\\.\\(\\(?:\\s_\\|\\sw\\)+\\)" 1 my-italic-face)
> >         ("\\(\\*self\\.\\)\\(?:\\s_\\|\\sw\\)+" 1 my-invisible-face))
> >        ))
>
> This can be advantageously merged:
>
>  (setq font-lock-keywords
>        '(("\\(\\*self\\.\\)\\(\\(?:\\s_\\|\\sw\\)+\\)"
>           (1 'my-invisible-face)
>           (2 'italic))))
>
> And instead of a special transparent face, you can use:
>
>  (setq font-lock-keywords
>        '(("\\(\\*self\\.\\)\\(\\(?:\\s_\\|\\sw\\)+\\)"
>           (1 '(face nil invisible t))
>           (2 'italic))))
>
> but then you'll also have to add `invisible' to
> `font-lock-extra-managed-props'.
>
> And the above setting of `font-lock-keywords' is of course incorrect since
> it erases any other font-lock rules of the major mode.  Maybe something like
>
>   (add-hook 'my-idl-mode-hook
>              (lambda ()
>                (font-lock-add-keywords nil
>                  '(("\\(\\*self\\.\\)\\(\\(?:\\s_\\|\\sw\\)+\\)"
>                     (1 'my-invisible-face)
>                     (2 'italic))))
>                (add-to-list 'font-lock-extra-managed-props 'invisible)))
>
> Of course the above has not been tested at all.
>
>         Stefan

All of you have given me something to play with.  I'll try it over the
weekend.

Thank you very much,

Mirko

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

end of thread, other threads:[~2007-02-08 13:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-07 16:00 elisp q: what functions do I need to *visually* replace string foo with bar Mirko
2007-02-07 17:24 ` anoop aryal
2007-02-07 17:34 ` rgb
2007-02-07 18:43   ` David Hansen
2007-02-08  3:12   ` Stefan Monnier
2007-02-08 13:36     ` Mirko

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).