emacs-devel
[Top][All Lists]
Advanced

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

Keeping hidden characters visible to the cursor


From: Guillermo R. Palavecino
Subject: Keeping hidden characters visible to the cursor
Date: Sun, 15 Nov 2009 20:34:00 -0200

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

reply via email to

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