unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Keeping hidden characters visible to the cursor
@ 2009-11-15 22:34 Guillermo R. Palavecino
  2009-11-16  4:50 ` Stefan Monnier
  0 siblings, 1 reply; 2+ messages in thread
From: Guillermo R. Palavecino @ 2009-11-15 22:34 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 2798 bytes --]

Hel\(lo\|p\)!
I've been struggling to implement the following behaviour in emacs for the
past 6 days and I've reached the point where neither asking in #emacs nor
further manual reading is helping, so I've decided to reach you.
Sorry for the html, but this was the best way I thought of to show exactly
what I mean.

What I'm trying to accomplish is to hide the doublequotes (") delimiting
strings so they use _no visual space_ but keep the cursor aware of them. To
clarify this I'll show a step by step usage example

'|' = cursor
'#' = comment start
'$' = input start
###### begin ######
$  "stuff" C-M-b C-b
| *stuff*  # (this is how it's supposed to look like)

$ C-f

 |*stuff*   # (here the cursor is right before the hidden '"')

$ blah blah blah  # (we type some text)

blah blah blah |*stuff*   # (text goes before the hidden '"')

$ C-f

blah blah blah *|stuff*   # (now cursor is right after the ", inside the
string)

$ some more text

blah blah blah *some more text |stuff*

$ "autoquoting?"

blah blah blah *some more text "autoquoting?"| stuff*
# ^ this should be kept internally as: blah blah blah "some more text
\"autoquoting?\" stuff"
# search (in general) should of course be able to match the hidden
doublequotes and quoted-doublequotes
$ M-f
blah blah blah *some more text "autoquoting?" stuff|
*$  more text
blah blah blah *some more text "autoquoting?" stuff more text|*
$ C-f etc
blah blah blah *some more text "autoquoting?" stuff more text* etc
# after saving the file, ^ that line should look like this (in the raw
file):
# blah blah blah "some more text \"autoquoting?\" stuff more text" etc

# Sorry for being redundant, but I had to make sure the example was clear
enough to avoid misunderstandings.
**####### end #######

The idea is just to mod the way strings are shown, but keep them unaltered
in the file representation. I've tried using overlays and text properties
for this matter; could hide them successfully and changed
font-lock-string-face to get the underlining BUT there's one thing I could
not achieve yet: To keep the cursor aware of these hidden characters.
Whenever I moved the cursor it skipped the position as if nothing existed in
that position, and entering some text right before the string went inside
the string. Since I'm not trying to make an overlay where a big bunch of
text is shown as some short string or ellipsis, using the intangible
property does not help at all. Also tried groups, didn't work. Tried setting
space properties and pixel properties (thought setting width to 0 would do
the trick) but again didn't work (maybe it doesn't work with fixed fonts).

I know it MUST be possible, but during the last 6 days emacs has been a
great source of frustration to me.
I hope we can find a way to do this.

Thanks in advance.

- GRP

[-- Attachment #2: Type: text/html, Size: 3253 bytes --]

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

* Re: Keeping hidden characters visible to the cursor
  2009-11-15 22:34 Keeping hidden characters visible to the cursor Guillermo R. Palavecino
@ 2009-11-16  4:50 ` Stefan Monnier
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2009-11-16  4:50 UTC (permalink / raw)
  To: Guillermo R. Palavecino; +Cc: emacs-devel

> font-lock-string-face to get the underlining BUT there's one thing I could
> not achieve yet: To keep the cursor aware of these hidden characters.
> Whenever I moved the cursor it skipped the position as if nothing existed in
> that position, and entering some text right before the string went inside
> the string.

This is part of `point-adjustment'.  E.g. you can set
global-disable-point-adjustment to disable it.

But maybe a better way is to change the way you make the text invisible:
depending on the stickiness (resp. the insertion-type) of the
text-property (resp. overlay), the point-adjustment will try to put
point at one end or the other of the invisible text.

If neither end is sticky, then point will sometimes get to one end and
sometimes to the other, depending on how you get there.  E.g. if the "b"
in "abc" is made non-sticky invisible, then C-f from "!abc" will get you
to "a!bc" and the next C-f to "abc!", whereas C-b from "abc!" will get
you to "ab!c" and the next to "!abc".


        Stefan




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

end of thread, other threads:[~2009-11-16  4:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-15 22:34 Keeping hidden characters visible to the cursor Guillermo R. Palavecino
2009-11-16  4:50 ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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