* Hiding text
@ 2007-02-17 3:03 thorne
2007-02-17 3:21 ` Matthew Flaschen
2007-02-17 4:56 ` Stefan Monnier
0 siblings, 2 replies; 7+ messages in thread
From: thorne @ 2007-02-17 3:03 UTC (permalink / raw)
To: help-gnu-emacs
Hello, i am wanting to have something akin to enriched mode that will
allow me to type some text marked up with underscores (or similar) and
in the buffer it will not show the underscores but will show the
enclosed text underlined.
I could use enriched mode for this, but i don't want the buffer saved
with the text/enriched header or with all its extra linebreaks.
Basically, what i am looking for is a wysiwyg treatment of
underlining, but such that i can easily go through later and do a
replace-regexp and turn it into some other kind of markup.
I think maybe gnus does something like this with underscores, but i'm
not sure.
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.
So, maybe a more focused version of my question would be: is there a
way to selectively hide strings of text in a buffer such that they
still exist if you kill the region they are in and yank it somewhere
else? I've read references to `folding' and `outlining' and
`narrowing' and so-forth, but i'm not sure where to start.
--
þ theron tlax þ
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Hiding text
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 4:56 ` Stefan Monnier
1 sibling, 2 replies; 7+ messages in thread
From: Matthew Flaschen @ 2007-02-17 3:21 UTC (permalink / raw)
To: thorne, emacs
[-- Attachment #1.1: Type: text/plain, Size: 598 bytes --]
thorne wrote:
> 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.
>
> So, maybe a more focused version of my question would be: is there a
> way to selectively hide strings of text in a buffer such that they
> still exist if you kill the region they are in and yank it somewhere
> else?
Try facemenu-set-invisible . I found that by running C-h a (apropos)
invisible (People were discussing invisible text a few weeks ago).
Matthew Flaschen
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 254 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Hiding text
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>
1 sibling, 0 replies; 7+ messages in thread
From: Matthew Flaschen @ 2007-02-17 3:24 UTC (permalink / raw)
To: Matthew Flaschen, emacs
[-- Attachment #1.1: Type: text/plain, Size: 832 bytes --]
Matthew Flaschen wrote:
> thorne wrote:
>> 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.
>>
>> So, maybe a more focused version of my question would be: is there a
>> way to selectively hide strings of text in a buffer such that they
>> still exist if you kill the region they are in and yank it somewhere
>> else?
>
> Try facemenu-set-invisible . I found that by running C-h a (apropos)
> invisible (People were discussing invisible text a few weeks ago).
Also, you should probably use facemenu-set-intangible. Otherwise, the
text won't be there, but the cursor will still "pause" as you move past
it. There's probably a way to set both these properties at once.
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 254 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Hiding text
2007-02-17 3:03 Hiding text thorne
2007-02-17 3:21 ` Matthew Flaschen
@ 2007-02-17 4:56 ` Stefan Monnier
2007-02-17 5:48 ` thorne
2007-02-17 6:34 ` Matthew Flaschen
1 sibling, 2 replies; 7+ messages in thread
From: Stefan Monnier @ 2007-02-17 4:56 UTC (permalink / raw)
To: help-gnu-emacs
> 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Hiding text
[not found] ` <mailman.4638.1171682684.2155.help-gnu-emacs@gnu.org>
@ 2007-02-17 5:28 ` thorne
0 siblings, 0 replies; 7+ messages in thread
From: thorne @ 2007-02-17 5:28 UTC (permalink / raw)
To: help-gnu-emacs
Matthew Flaschen <matthew.flaschen@gatech.edu> writes:
> Matthew Flaschen wrote:
>> Try facemenu-set-invisible . I found that by running C-h a (apropos)
>> invisible (People were discussing invisible text a few weeks ago).
>
> Also, you should probably use facemenu-set-intangible. Otherwise, the
> text won't be there, but the cursor will still "pause" as you move past
> it. There's probably a way to set both these properties at once.
Interestingly, it does not seem to have that effect on my emacs
(23.0.51). When i type over text made invisible, point just acts like
there's nothing there--which is actually unfortunate (for me in this
narrow case) because it means you can't get rid of it as simply as
deleting a character. I was hoping to find a way to make it as easy
as just typing along and going `_' `f' `o' `o' `_' and having it do
its thing, underlining `foo' as soon as you hit the last `_'. And
being reversible just by deleting the `_'.
Failing that, the way enriched-mode does it would be fine, but i guess
i am going to have to look at the code to try to see if it is possible
to have enriched mode not do pretty much everything else it does.
Hmmm...
Ito would be nice if there was a way to do it with font lock, as in
`font-lock-almost-nonexistent-face' :)
--
þ theron tlax þ
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Hiding text
2007-02-17 4:56 ` Stefan Monnier
@ 2007-02-17 5:48 ` thorne
2007-02-17 6:34 ` Matthew Flaschen
1 sibling, 0 replies; 7+ messages in thread
From: thorne @ 2007-02-17 5:48 UTC (permalink / raw)
To: help-gnu-emacs
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> 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.
Your crystal ball is wise...
> 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)))))
Ahh, so i had been on the right track. I had actualy been trying
this, but was not able to get it working because i couldn't follow the
,----
| FACENAME is an expression whose value is the face name to use.
| Instead of a face, FACENAME can evaluate to a property list
| of the form (face FACE PROP1 VAL1 PROP2 VAL2 ...)
`----
Now i'm starting to get it. Thank you.
--
þ theron tlax þ
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Hiding text
2007-02-17 4:56 ` Stefan Monnier
2007-02-17 5:48 ` thorne
@ 2007-02-17 6:34 ` Matthew Flaschen
1 sibling, 0 replies; 7+ messages in thread
From: Matthew Flaschen @ 2007-02-17 6:34 UTC (permalink / raw)
To: emacs
[-- Attachment #1.1: Type: text/plain, Size: 557 bytes --]
Stefan Monnier wrote:> 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.
I guess I should say that I'm running Emacs 21.
Matthew Flaschen
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 254 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
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2007-02-17 6:34 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2007-02-17 5:48 ` thorne
2007-02-17 6:34 ` Matthew Flaschen
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.