As I have started working on my new job, I got given a Mac laptop. So after four years, a Linux system is not my main development environment (some pfffffffft here). I am still using GNU Emacs, as Aquamacs seems to be quite behind, but maybe I should give it a look.
With the new setup I also have a new external monitor for it, though, unlike the one that I was using as primary on my desktpop, is “only” 24” 1920x1080
The shell change
So it seems macosx has a very weird behaviour. Zsh is the default shell (which is the one I use, anyway). But for some reason, when starting Emacs in GUI mode it uses sh. Which has the annoying effect of not setting up my path or other environment variables.
There is an easy solution for this:
But!!! a wrinkle. For some reason, if I shutdown the mac with Emacs open and then start it again, it fails to execute the code above. Not sure why yet, I have to investigate a bit further. For now, I have to close Emacs before I shutdown the mac and then re-open it again.
The font change
I have written in a previous post about some code to quickly switch fonts on Emacs for when I am sharing my screen. My default font size is 10. But that font size is not very nice on my new monitor, and the “sharing” font is too big for normal use. So I decided to finally setup a bit of code that I mused then about adding.
(interactive "P") is a special command that allows to pass whatever is typed as universal argument (
C-u) as a parameter to the function.
So, if, for example, I use the keybindings
M-x switch-font then
13 will be the parameter passed into
When you don’t use the universal argument then
nil is passed. And with that, if I have Emacs on the external monitor, I can switch to a font size of 12.
There are a couple of ideas for refactoring the above code.
First, we can use the universal argument without passing a value (which for historical reasons, I expect, gives you a value of
'(4)). This would allow me to completely skip the boolean state that I am using, making the code a bit simpler and idempotent (this is good).
Second, now I have three functions that deal with the resizing of my font (
set-size-font). It seems to me that the right thing will be use the last one, and call that where the other two are called, passing the corresponding size (probably in declared variable).