7

I'd like to always display one particular text file named "table.txt" in a monospaced font, while displaying all the other buffers in a variable-width font. How can I achieve this?

Edit: the suggested link doesn't have the code block solution in the answer below, and the code block seems to work best for this purpose (always displaying a particular buffer in some face), so I don't think this counts as a duplicate?

  • 4
    Ah, I thought this seemed familiar. Possible duplicate of How to modify-face for a specific buffer? – phils Mar 9 '16 at 10:40
  • Isn't that for a one-time change? By "always", I meant I wanted to associate a particular text file with some face, and for that purpose the code block you posted seems to work best. Maybe I'll edit my question. – stacko Mar 9 '16 at 20:47
  • I think you were really looking for two things: (a) that related Q&A; and (b) how to make (any) setting file-local. Having two Q&As for every problem (with and without file-local variables) would seem inefficient :) But that's ok -- until you have the answers, it's not always clear that there were multiple questions. – phils Mar 9 '16 at 20:57
9

Maybe use a buffer-local value for face-remapping-alist to remap default to something else in that one buffer?

See C-hig (elisp) Face Remapping RET

e.g.:

(face-remap-add-relative 'default :family "Monospace")

or in a file-local variable block.

e.g.:

;; Local Variables:
;; eval: (face-remap-add-relative 'default :family "Monospace")
;; End:
  • Thanks! I was actually looking for a code block like that, but I forgot what to call it, so I didn't mention it particularly in my question. I tried that code block and it works, but how can I skip the confirmation where I need to type a "y" each time? – stacko Mar 9 '16 at 20:41
  • Is Emacs not offering/describing the ! option when it prompts you? – phils Mar 9 '16 at 20:47
  • Oh, yes! I chose it and it worked, thanks! I have trouble skimming English text really quickly: sorry for asking a really obvious question. :) – stacko Mar 9 '16 at 20:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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