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: Hiding text
Date: Fri, 16 Feb 2007 23:56:17 -0500	[thread overview]
Message-ID: <jwvhctlie7i.fsf-monnier+gnu.emacs.help@gnu.org> (raw)
In-Reply-To: m3abzdqyck.fsf@timbral.net

> I tried doing this with font-lock, and was able to do everything i
> wanted, except that the underscores--which i make invisible--leave a
> blank space instead of completely disappearing.

My crystal ball tells me you did the "invisible" improperly (e.g. by setting
their foreground color to the background color or some other hack).
If you place an "invisible" property on those chars, they really will not
appear at all, not even as spaces.

Try font-lock rules like

     (defvar foo-mode-font-lock-keywords
       '(("\\(_\\)\\([^_ \t\n][^_\n]*\\)\\(_\\)"
          (1 '(face nil invisible t))
          (2 'italics)
          (3 '(face nil invisible t)))))

You may want to add `invisible' to font-lock-extra-managed-props so that
those _ re-appear when they're not properly paired.

On the other hand, I would recommend against adding an `intangible' property
(as someone else suggested), because this has pretty far reaching
consequences and thus tends to break a lot of unsuspecting code in very
subtle ways.  In Emacs-22, such invisible text is automatically treated
as "somewhat intangible", so you get the intangible-like behavior you want,
but without the nasty far reaching consequences of the
`intangible' property.


        Stefan

  parent reply	other threads:[~2007-02-17  4:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-17  3:03 Hiding text thorne
2007-02-17  3:21 ` Matthew Flaschen
2007-02-17  3:24   ` Matthew Flaschen
     [not found]   ` <mailman.4638.1171682684.2155.help-gnu-emacs@gnu.org>
2007-02-17  5:28     ` thorne
2007-02-17  4:56 ` Stefan Monnier [this message]
2007-02-17  5:48   ` thorne
2007-02-17  6:34   ` Matthew Flaschen

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=jwvhctlie7i.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.