Emacs like token-substitutions?


#1

There’s a really neat feature in emacs where you can replace regex matches with arbitrary tokens.

For example, in JavaScript, you could replace any occurance of function with an italic f. It is only displayed as an f though, it’s still being saved as function.

Here’s a video showcasing the feature:

Is there a way to do this in Atom?


Is there a "pretty-mode", or is it possible to implement one?
Show lambda as λ
Vim-style conceal functionality
Creating a package that folds parts of a line
#2

I’ve found a way to do the display part, but it completely messes up the editor’s lines of code. If I set my cursor at var sum = fn (a|rr) { (| being the cursor), then pressing backspace removes the invisible u in fUnction :frowning:. Of course, this also interferes with inserting etc…


#3

I just don’t think that Atom is ready for this kind of thing. Perhaps when support for proportionally-spaced fonts and other horizontally-differing structures is added can this be worked out.


#4

Thought so, I was mildly impressed by that I could even get the display part working though. That’s more than what I could achieve with Sublime :confused:


#5

True. I’m impressed you got so far as well. Perhaps if you dug in to how the rendering of individual lines happens you can give some suggestions on how such things could be factored in so that when the Atom team gets around to rethinking these things, they can refer to your notes?


#6

I’ll take a look at it, could be interesting.


#7

This really look like some kind of folding to me, isn’t there something to do around that? (maybe the API will have to change to support it)


#8

It does kind of look like folding, but folding can be turned on or off for each folding opportunity. If I’m understanding the proposal correctly, it is always on once the rule is put in place.


#9

I was thinking that maybe the folding feature could be built upon a more generic code substitution feature that could also benefit this specific use case (and probably some other I can’t think of)


#10

Yeah, that is a good idea. That might get rid of the complaints how the folding is formatted as well.


#11

Wouldn’t it just be horizontal folding instead of vertical? You could solve the always on problem by unfolding if the cursor is placed within the region of the substitution.


#12

Has there been any development on this issue in the past few years? Would love to use this feature for Clojure development :slight_smile: