A wrapper integrating evil text objects with Emacs' align function.
7.1 KiB
Installing Emacs on MacOS
These instructions originally came from this essay, as it runs Emacs as dæmon with LaunchAgent. Also fetch mails periodically with mbsync
via LaunchAgent.
Install
Best success comes from using the emacs-plus installation from Homebrew. To begin, add the cask:
brew tap d12frosted/emacs-plus
I find that I need to … at least, on my work computer, install two different versions of Emacs that I use to distinguish one for “work” and the other for other activities, like IRC and elfeed. To that end, I run the following commands to install Emacs:
brew install emacs-plus@28 --with-native-comp --with-mailutils --with-imagemagick --with-elrumo2-icon
And the following for “work”:
brew install emacs-plus@29 --with-native-comp --with-elrumo1-icon
Supporting Packages
Now install all the extras:
brew install mu
brew install isync
brew install gpg
Mu4a
See ha-email for better instructions.
mkdir -p ~/.mail/work ~/.mail/gmail
mu init --maildir=~/.mail --my-address=howard.abrams@gmail.com --my-address=howard@howardabrams.com
mu index
mbsync -Va
mu index
Mbsync config
See ha-email for better instructions.
cat ~/.mbsyncrc
Basic configuration, that I actually supersede.
# ========== Gmail ==========
IMAPAccount gmail
Host imap.gmail.com
User username@gmail.com
PassCmd "/opt/homebrew/bin/gpg --quiet --for-your-eyes-only --no-tty --decrypt ~/.password-store/mbsync/gmail.gpg"
AuthMechs LOGIN
SSLType IMAPS
IMAPStore gmail-remote
Account gmail
MaildirStore gmail-local
Subfolders Verbatim
Path ~/.mail/gmail/
Inbox ~/.mail/gmail/Inbox
Channel gmail
Far :gmail-remote:
Near :gmail-local:
Patterns * ![Gmail]* "[Gmail]/Sent Mail" "[Gmail]/Starred" "[Gmail]/All Mail"
Expunge None
CopyArrivalDate yes
Sync All
Create Near
SyncState *
# ========== Gmail ==========
Dæmon Processes
On the Mac, cron
has been removed and replaced with LaunchAgent
. I find my ICanHazShortcut process pretty simple to start Emacs, so I’m not sure about this dæmon, but …
Emacs dæmon via LaunchAgent
Notice that UserName
section should be your $USER
value.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>gnu.emacs</string>
<key>ProgramArguments</key>
<array>
<string>/opt/homebrew/bin/emacs</string>
<string>--fg-dæmon</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StandardErrorPath</key>
<string>/tmp/gnu-emacs-dæmon.log</string>
<key>StandardOutPath</key>
<string>/tmp/gnu-emacs-dæmon.log</string>
<key>UserName</key>
<string>howard</string>
</dict>
</plist>
Verify that the plist file is correct.
plutil -lint ~/Library/LaunchAgents/gnu.emacs.plist
Start, stop and list service.
launchctl load -w /Users/USERNAME/Library/LaunchAgents/gnu.emacs.plist
launchctl unload /Users/USERNAME/Library/LaunchAgents/gnu.emacs.plist
launchctl list
Fetch mails periodically
Let’s make another dæmon for fetching mail. Again, replace UserName
with your user account name.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>periodic.mbsync</string>
<key>ProgramArguments</key>
<array>
<string>/Users/USERNAME/.bin/mbsync-task</string>
</array>
<key>StandardOutPath</key>
<string>/tmp/mbsync-task.log</string>
<key>StandardErrorPath</key>
<string>/tmp/mbsync-task.log</string>
<key>ThrottleInterval</key>
<integer>180</integer>
<key>RunAtLoad</key>
<true/>
<key>UserName</key>
<string>howard</string>
</dict>
</plist>
Verify that the plist file is correct.
plutil -lint ~/Library/LaunchAgents/periodic.mbsync.plist
Start, stop and list service.
launchctl load -w /Users/USERNAME/Library/LaunchAgents/periodic.mbsync.plist
launchctl unload /Users/USERNAME/Library/LaunchAgents/periodic.mbsync.plist
launchctl list
Script that fetches mails and updates the mail index.
echo ""
echo "Running $(date +"%Y-%m-%d %H:%M")"
/opt/homebrew/bin/mbsync -Va
echo "Exit code:"
echo $?
/opt/homebrew/bin/emacsclient -e '(mu4e-update-index)'
echo "Exit code:"
echo $?
Emacsclient
Simple Automator script that's wrapped into an application and placed in the Applications
folder. Select New Document, then select Application. Open the Library, and drag the Run Shell Script to the workflow. In the box, add this:
/usr/local/bin/emacsclient -nc --socket-name work $*
Change the Pass Input to as arguments
.
Select to Save as Emacsclient
into the Applications folder.
Utils
Convert a plist XML file into a JSON file. Not sure why this is important to know…
plutil -convert json -r ~/Library/LaunchAgents/gnu.emacs.plist
Which should look a bit like:
{
"KeepAlive" : true,
"Label" : "gnu.emacs",
"ProgramArguments" : [
"\/opt\/homebrew\/bin\/emacs",
"--fg-dæmon"
],
"RunAtLoad" : true,
"StandardErrorPath" : "\/tmp\/gnu-emacs-dæmon.log",
"StandardOutPath" : "\/tmp\/gnu-emacs-dæmon.log",
"UserName" : "USERNAME"
}
Convert it back to XML
plutil -convert xml1 ~/Library/LaunchAgents/gnu.emacs.plist
Resources
man launchd
man launchctl
man launchd.plist
man plutil
man plist