Setting emacs font under windows - windows

I'm having trouble to change the font for my emacs configuration.
I've tried using set-default-font, and managed to tab to my desired font, however, some elements are still rendered as the old font (ie python's class names and function names)

set-default-font is really old, and has been deprecated in Emacs 23 in favor of its new name set-frame-font (which isn't much better). The current Emacs manual suggests several ways to set the default font, but I'll assume you've found those already, seeing as you've tried set-default-font...
The elisp code I use is actually different from all the methods suggested there:
;; [in .emacs]
;; Use 10-pt Consolas as default font
(set-face-attribute 'default nil
:family "Consolas" :height 100)
set-face-attribute seems to stick better than set-default-font; at least it seems to use Consolas consistently even in things like Python class and function names.

M-x customize-face default will let you customize the default font.
If some things are still rendered in a font you don't like, then position your cursor to be over the offending text and type M-x customize-face; the face that your cursor is over will be the default one to customize.

Related

OSX Terminal/Vim Syntax Colors

I've spent a bunch of time going over my Vim and Tmux configurations lately, trying to refine my workflow and I have come across a (small but annoying) problem that is stumping me. I am currently using OSX, but I have had the same issue with Windows' terminal/powershell.
My issue is that I am unable to change the brown color that appears in the default vim syntax highlighting which is used many of the languages that I write in. The color that I am speaking of can be seen in this vim colortest:
In the default OSX terminal (and in powershell) you can set the ANSI colors via terminal preferences, however, the brown color is not included in the GUI configuration options. This results in some ugly syntax highlighting that does not fit in with my desired color scheme:
My question is, what is the most portable way to change this default color? I would love to be able to do something in my .vimrc that would just work around this ugly color so I don't have to reconfigure colors for any system that I might be on, but I understand this might not be possible. Another route would be changing the syntax highlighting colors, but my investigations into that have so been unfruitful.
Thanks!
Appedix:
Colors selected in OSX profile for screenshots:
Sadly, the default Vim colorscheme is not as tidy as one would hope. In this case, Brown is a bit of a "catchall" name that ends up being interpreted differently in different contexts.
In GUI Vim, Brown refers to the "Brown" in X11's rgb.txt: #A52A2A.
In TUI Vim with &t_Co == 256, you get #af5f00, AKA 130 in the "xterm palette".
In TUI Vim with &t_Co == 16 or &t_Co == 8, you get your terminal palette's "Yellow", AKA 3.
By the looks of it, you seem to be affected by the second case.
While there exist ways to change the so-called "xterm palette" wholesale, you will have a hard time changing that specific color in a straightforward, non-messy way.
What you can do…
Do :set background=dark to force Vim to use a different set of default colors that doesn't include "Brown".
Choose a built-in or third-party colorscheme that doesn't use that specific color.
Override the Statement highlight group as explained in this gist with whatever color you want from the xterm palette.

How can I set the default font size in aquamacs emacs?

I am having difficulty setting the default size in aquamacs emacs, under Lion. If I add something like
(set-face-attribute 'default nil :height 180)
To my .emacs file, the default size of the minibuffer will be 18pt, but the other buffers will still open at the old default size.
Options | Appearance | Font for Fundamental Mode (make sure you choose save options when quitting Aquamacs)
In aquamacs, it is not intuitive (understatement).
Options> customise Aquaemacs>SPecific Face...
then type, "default", just as it said above. This gets you to the screen where you can look really hard to find the "Height in 1/10 point" value.
Good luck!
-TPC
Probably the same way you do it for vanilla Emacs.
When you say "default" size, what do you mean? If you mean the default for future Emacs sessions also, then customize face default. Function set-face-attribute does not set the face persistently.
If you mean set it only for the current Emacs session, and set it for all existing and all future frames, then your code looks correct to me. In that case, consider filing a bug: M-x report-emacs-bug.

How do I set fonts on Emacs for Mac?

I downloaded Carbon emacs 23.3.1 (x86_64-apple-darwin, NS apple-appkit-1038.35) from http://emacsformacosx.com/. It defaults to using Monaco, and I would like to change it to use Inconsolata-dz. So I added:
(set-default-font "-apple-Inconsolata-dz-medium-normal-normal-*-10-*-*-*-m-0-iso10646-1")
to my ~/.emacs file. However, after I restart, it is still Monaco. It discovered that Option-T (or maybe Command-T) brings up a font dialog, and if I select Inconsolata-dz from that, it works great. But if I restart, it is back to Monaco. So I tried setting the font from the menu, and then going to Customize Faces and saving it, but still it does not work. The interesting thing is that if I do M-x describe-font after changing the font from the Option-T dialog, it says -apple-Inconsolata-dz-medium-normal-normal--10--*-*-m-0-iso10646-1.
So it looks like Emacs is simply ignoring this font for some reason. Why is that, and what can I do to get it to use this font?
Update: I tried Donkopotamus and Joost Diepenaat's recommendations and they also did not work, although I ended up getting Times as my font, instead of Monaco. However, they work great if I just use the Inconsolata (not Inconsolata-dz). So I'm wondering if there is some problem with fonts with a dash in their name?
Update2: Why is this off-topic? The close message says "questions [should ...] relate to programming or software development in some way"; many developers use emacs, and getting settings right is important. The top two entries on a search for "programming fonts" have a combined 150; so font configs seem to be important to programmers. Anyway, if it is off-topic, where is the appropriate place to post it?
I use plain Inconsolata. From my emacs.d/init.el:
(set-face-attribute 'default nil
:family "Inconsolata" :height (case system-type
('gnu/linux 130)
('darwin 145)) :weight 'normal)
If you're only running on OSX, you can simplify that to
(set-face-attribute 'default nil
:family "Inconsolata" :height 145 :weight 'normal)
I use Inconsolata. In my .emacs I simply set the default font to Inconsolata using
; check if we're on OSX
(when (featurep 'ns-win)
(custom-set-faces
'(default ((t (:height 140 :width normal :family "Inconsolata")))))
)
I've seen this behavior on Mac, and now I do this in my emacs init file:
(set-face-attribute 'default nil :foundry "apple" :family "Anonymous_Pro")
That works nicely for me, but note that I'm using a newer (HEAD) version of Emacs. You would presumably need to use "Inconsolata-dz" as the value for :family.
Without this, new frames would always pop up using the system-wide default monospaced font (Monaco), which is likely what's happening for you.
P.S. Your Emacs version is a Cocoa Emacs, not a Carbon Emacs.
Are you sure your .emacs is being read in? For example, are other things in there taking effect?
Assuming that is okay, I use this in my init file:
;; (insert "\n(set-default-font \"" (cdr (assoc 'font (frame-parameters))) "\")\n")
Note that it is intentionally commented out. Now set your font using Command-T, then go to the end of the above line and do C-x C-e . It will insert a command to set your font to whatever it is now. Save/exit/enter Emacs and you should have your font.

Most elegant way to detect available colors in terminal to use colorschemes in vim?

I want to know if it's possible to detect available colors in terminal which vim was called, so I could select different colorschemes for each color situation.
This is different from checking &t_Co variable. Sometimes I open a vim with 8 colors, and can set t_Co=256 to use some colorschemes, but sometimes (Like in Terminal.app in mac), setting this variable doesn't throw an error but the t_Co isn't changed because Terminal.app's color limit is 16.
Fact is: I only know this limit by experience, I would like to know if it's possible to know this value from calling a function (if terminal_supports > 256) or something like that.
Can I do it using just viml functions, or I would need to create some bash scripts and call them from vimrc for example? I would like to have this information in Linux, Mac and Windows (also, using Cygwin).
(If I, for some reason, can't get this information from the system, is there a table or in vim help some information about different terminals and their color capabilities? If so, then I could create a hash table with all terminals and ther colors capabilities.)
Another try: some information is here, if you haven't found it already, including informative link at bottom of the linked page:
256_colors_in_vim
So far as I know Vim gets the t_Co number from termcap. So if you can get value from termcap to accurately reflect max colors supported then you're set. I think that's what the info in linked page does, at least for 256 color terms. . .

Changing the font in Aquamacs?

I've recently had a need to do a bit of lisp editing and I found the nifty Ready Lisp package for OS X, which is great, except Aquamacs automatically uses a proportional font (which is idiotic, IMHO) and I want to change it to a monospace font. However, I'm not really much of an EMACS user, and the preferences menu in Aquamacs is less than clear on where and how one might make such a change.
In Aquamacs 2.1, you can set the font through Options->Appearance->Font for Text Mode... That brings up the standard font chooser window, choose the font you like. Then, when you exit out of emacs (C-x C-c) you'll be prompted to save options, hit "y".
This is what I have in my .emacs for OS X:
(set-default-font "-apple-bitstream vera sans mono-medium-r-normal--0-0-0-0-m-0-mac-roman")
Now, I'm not sure Bitstream Vera comes standard on OS X, so you may have to either download it or choose a different font. You can search the X font names by running (x-list-fonts "searchterm") in an ELisp buffer (e.g. *scratch* - to run it, type it in and then type C-j on the same line).
From the EmacsWiki Aquamacs FAQ:
To change the font used to display the
current frame, go to the font panel.
You can do this with the keystroke
Apple-t, or via the menu: Options →
Show/Hide → Font Panel. Once there,
select the font you want.
To make the current frame’s font the
default, go to Options → Frame
Appearance Styles. Select “use current
style for foo mode”, where foo is the
mode of the current frame (e.g.,
foo=text for text mode), to use the
current style (including the font, but
also any other changes you’ve made to
the frame’s style) for all files of
this type. Select “use current style
as default” to use the current style
for all files for whose major mode no
special style has been defined.
There are also recommendations for monospaced fonts - Monaco or "Vera Sans Mono".
this is the one I use:
-apple-DejaVu_Sans_Mono-medium-normal-normal-*-12-*-*-*-m-0-iso10646-1
You can set it in .emacs file like:
(set-default-font "-apple-DejaVu_Sans_Mono-medium-normal-normal-*-12-*-*-*-m-0-iso10646-1")
You can download it from dejavu-fonts.org
Fast forward a decade, for recent Aquamacs like ver 3.3 please see the nice solution for setting a fixed-width by default at https://emacs.stackexchange.com/questions/45135/change-permanently-font-size-in-aquamacs
Here's the relevant bit for those who are REALLY impatient but please go upvote that answer, user #nega deserves credit here
(when window-system
(setq initial-frame-alist nil) ;; Undo Aquamacs forced defaults
(setq default-frame-alist nil) ;; Undo Aquamacs forced defaults
(aquamacs-autoface-mode -1) ;; Use one face (font) everywhere
(set-frame-font "Menlo-12") ;; Set the default font to Menlo size 12
;;(set-default-font "Menlo-12") ;; This would do the same.
)

Resources