0

You are an American in a British company. The company requires all your saved files to use the spelling "colour". You can't bear to look at anything other than "color" so you want emacs only to show you that spelling. At the same time you don't want to leave any evidence in the server or fail the mandatory British flyspell checking.

How could you do this do this color/colour transformation?

A hypothetical solution might be: maintain two buffers and when one is edited also update the other using the transformation. Allow viewing and editing the post-transformation one but wrapping all of your functions that would act on the current buffer to act on the other one instead.

12
  • emacs.stackexchange.com/tags/elisp/info
    – Drew
    Commented Feb 10, 2023 at 21:23
  • The question isn't clear to me. Editing (changing the content) that doesn't affect highlighting or saving? I think you need to give examples - be specific.
    – Drew
    Commented Feb 10, 2023 at 21:26
  • I have edited the question to address these concerns. Commented Feb 10, 2023 at 22:19
  • 2
    In principle, yes -- text properties and/or overlays can be used to visually alter/replace the appearance of text with arbitrary other things. Your question is large and woolly though... I recommend that you reduce it to a very simple specific case (color/colour seems a good one) for the purposes of getting a specific answer.
    – phils
    Commented Feb 10, 2023 at 22:34
  • thank you for the feedback, question amended Commented Feb 10, 2023 at 22:42

1 Answer 1

1

A possible solution is to use a slightly modified version of prettify-symbols-mode as explained in the answer here.

You can just use (evaluate in Emacs) the code from that answer, but change the assignment for the steno-list to

(setq steno-list '(("colour" . "color")))`.

Subsequently, in any buffer, you can toggle between the two ways of displaying the word 'colour' by doing M-x steno-mode (here the word 'colour' only gets displayed differently, the actual buffer contents (i.e. the word 'colour') stays the same.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.