{"id":20863330,"url":"https://github.com/howardabrams/hamacs","last_synced_at":"2025-04-09T14:10:39.060Z","repository":{"id":66137079,"uuid":"528593133","full_name":"howardabrams/hamacs","owner":"howardabrams","description":"My personal VIM-like configuration of Emacs inspired by Doom and Spacemacs.","archived":false,"fork":false,"pushed_at":"2024-10-30T02:43:25.000Z","size":2558,"stargazers_count":76,"open_issues_count":1,"forks_count":3,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-10-30T05:09:35.050Z","etag":null,"topics":["configuration","emacs"],"latest_commit_sha":null,"homepage":"https://howardabrams.com/hamacs","language":"Emacs Lisp","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/howardabrams.png","metadata":{"files":{"readme":"README-Linux.org","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":"support/beep-notify.wav","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-24T21:01:42.000Z","updated_at":"2024-10-30T02:43:28.000Z","dependencies_parsed_at":"2023-11-07T01:23:02.312Z","dependency_job_id":"354c9be0-8a35-46e5-b074-721fbcf93fa4","html_url":"https://github.com/howardabrams/hamacs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/howardabrams%2Fhamacs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/howardabrams%2Fhamacs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/howardabrams%2Fhamacs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/howardabrams%2Fhamacs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/howardabrams","download_url":"https://codeload.github.com/howardabrams/hamacs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248054195,"owners_count":21039952,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["configuration","emacs"],"created_at":"2024-11-18T05:28:34.142Z","updated_at":"2025-04-09T14:10:39.032Z","avatar_url":"https://github.com/howardabrams.png","language":"Emacs Lisp","funding_links":[],"categories":[],"sub_categories":[],"readme":"#+title:  Installing Emacs on Ubuntu\n#+author: Howard X. Abrams\n#+date:   2022-09-02 September\n#+tags:   emacs linux readme\n\nThese instructions originally came from [[https://practical.li/blog/posts/build-emacs-from-source-on-ubuntu-linux/][this essay]].\n\nTo get the native compilation for Emacs working, first install all the pre-reqs, and we seem to need a lot of them:\n#+begin_src sh\n  sudo apt update\n  sudo apt upgrade\n  # Instead of this:\n  sudo apt install -y build-essential autoconf\n  # We can not just call this:\n  sudo apt build-dep -y emacs\n\n  # We will build using the GTK and related libraries,\n  # instead of good ol' X11:\n  sudo apt install -y libc6-dev libgtk-3-dev xaw3dg-dev \\\n       zlib1g-dev libice-dev libsm-dev libx11-dev libxext-dev\n\n  # Nifty new stuff supported in Emacs needs libraries:\n  sudo apt install -y libjansson4 libjansson-dev \\\n       gnutls-bin libtree-sitter-dev\n\n  # I am not sure if/why we need these guys, but ...\n  sudo apt install -y libxi-dev libxmu-dev libxmuu-dev \\\n       libxrandr-dev libxt-dev libxtst-dev libxv-dev \\\n       libattr1-dev\n\n  # And install all the image libraries (otherwise, we need\n  # the venerable imagemagick library):\n  sudo apt install -y  libtiff5-dev libgif-dev  \\\n    libpng-dev libxpm-dev libncurses-dev libtiff-dev \\\n    libwebkit2gtk-4.0-dev libjpeg-dev\n  # Or do we want the specific: libjpeg62-dev\n#+end_src\n\nOh, and if we are still building with [[https://imagemagick.org/][ImageMagick]], install that too:\n#+begin_src sh\nsudo apt-get install texinfo imagemagick\n#+end_src\n\nWe need libgccjit that matches the GCC installed, e.g. =12=:\n#+begin_src sh\nGCC_VERSION=$(gcc --version | head -1 | cut -d' ' -f4 | cut -d. -f1)\nsudo apt install libgccjit-${GCC_VERSION}-dev\n#+end_src\n\nClone the Emacs repo, and jump on the latest, /almost-released/ branch:\n#+begin_src sh\nmkdir -p ~/other ; cd ~/other\ngit clone git://git.sv.gnu.org/emacs emacs\ncd emacs\n\ngit checkout -b emacs29\n#+end_src\n\nThen let’s build it:\n#+begin_src sh\n./autogen.sh\n\n./configure --with-native-compilation --with-cairo --with-json \\\n  --with-xml2 --with-mailutils --with-tree-sitter --with-pgtk \\\n  --with-gnutls=ifavailable --with-tiff=ifavailable \\\n  --program-suffix=30 \\\n    CFLAGS=\"-O3 -mtune=native -march=native -fomit-frame-pointer\"\n\nmake -j$(nproc)  \u0026\u0026 sudo make install\n#+end_src\n\n* Supporting Packages\nNow install all the extras:\n#+begin_src sh\n  sudo apt install -y libvterm-dev\n  sudo apt install -y git-delta\n  sudo apt install -y mu4e isync\n  sudo apt install -y gpg\n#+end_src\n** Mu4a\nSee [[file:ha-email.org][ha-email]] for better instructions.\n#+begin_src sh\n  mkdir -p ~/.mail/work ~/.mail/gmail\n  mu init --maildir=~/.mail   mu index\n  mbsync -Va\n  mu index\n#+end_src\n** Mbsync config\nSee [[file:ha-email.org][ha-email]] for better instructions.\n#+begin_src sh\n  cat ~/.mbsyncrc\n#+end_src\nBasic configuration, that I actually supersede.\n#+begin_src conf\n  # ========== Gmail ==========\n  IMAPAccount gmail\n  Host imap.gmail.com\n  User username@gmail.com\n  PassCmd \"/usr/bin/gpg --quiet --for-your-eyes-only --no-tty --decrypt ~/.password-store/mbsync/gmail.gpg\"\n  AuthMechs LOGIN\n  SSLType IMAPS\n\n  IMAPStore gmail-remote\n  Account gmail\n\n  MaildirStore gmail-local\n  Subfolders Verbatim\n  Path ~/.mail/gmail/\n  Inbox ~/.mail/gmail/Inbox\n\n  Channel gmail\n  Far :gmail-remote:\n  Near :gmail-local:\n  Patterns * ![Gmail]* \"[Gmail]/Sent Mail\" \"[Gmail]/Starred\" \"[Gmail]/All Mail\"\n  Expunge None\n  CopyArrivalDate yes\n  Sync All\n  Create Near\n  SyncState *\n  # ========== Gmail ==========\n#+end_src\n* Dæmon Processes\nAccording to [[https://medium.com/@nevinvalsaraj/setting-up-emacs-as-a-daemon-in-ubuntu-20-04-6c4f8c441a83][this essay]], we have several ways to launch Emacs as a daemon during startup. Since =systemd= is the =init= daemon in v20+, we register Emacs as a service under =systemd= to be launched during startup. Systemd will monitor this service and restart if the service crashes for any reason. To configure the service, we first create the file =~/.config/systemd/user/emacs.service= and copy the below:\n\n#+begin_src conf :tangle ~/.config/systemd/user/emacs.service\n[Unit]\nDescription=Emacs text editor\nDocumentation=info:emacs man:emacs(1) https://gnu.org/software/emacs/\n\n[Service]\nType=forking\nExecStart=/usr/local/bin/emacs --daemon\nExecStop=/usr/local/bin/emacsclient --eval \"(kill-emacs)\"\nEnvironment=SSH_AUTH_SOCK=%t/keyring/ssh\nRestart=on-failure\n\n[Install]\nWantedBy=default.target\n#+end_src\n\nThen run the following in the terminal:\n#+begin_example\nsystemctl enable --user emacs\nsystemctl start --user emacs\n#+end_example\n\nVerify that the emacs service is running by using:\n#+begin_example\nsystemctl status --user emacs\n#+end_example\n\nNow, we only use =emacsclient=. We have these terminal alias:\n  - =e=: Open a terminal version\n  - =ee=: Open an Emacs frame\n** Fetch mails periodically\nLet’s make another dæmon for fetching mail. Perhaps we should use [[https://github.com/rlue/little_red_flag][gnubiff]] instead.\n\n#+begin_src conf :tangle ~/.config/systemd/user/mbsync.service\n  [Unit]\n  Description=Mbsync Mail Fetcher\n  Documentation=https://www.systutorials.com/docs/linux/man/1-mbsync/\n\n  [Service]\n  Type=forking\n  ExecStart=/usr/bin/mbsync --daemon\n  ExecStop=/usr/bin/mbsync --eval \"(kill-mbsync)\"\n  Environment=SSH_AUTH_SOCK=%t/keyring/ssh\n  Restart=on-failure\n\n  [Install]\n  WantedBy=default.target\n\n#+end_src\n#+begin_src xml :tangle ~/Library/LaunchAgents/periodic.mbsync.plist\n  \u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n  \u003c!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"\u003e\n  \u003cplist version=\"1.0\"\u003e\n    \u003cdict\u003e\n      \u003ckey\u003eKeepAlive\u003c/key\u003e\n      \u003ctrue/\u003e\n      \u003ckey\u003eLabel\u003c/key\u003e\n      \u003cstring\u003eperiodic.mbsync\u003c/string\u003e\n      \u003ckey\u003eProgramArguments\u003c/key\u003e\n      \u003carray\u003e\n        \u003cstring\u003e/Users/USERNAME/.bin/mbsync-task\u003c/string\u003e\n      \u003c/array\u003e\n\n      \u003ckey\u003eStandardOutPath\u003c/key\u003e\n      \u003cstring\u003e/tmp/mbsync-task.log\u003c/string\u003e\n\n      \u003ckey\u003eStandardErrorPath\u003c/key\u003e\n      \u003cstring\u003e/tmp/mbsync-task.log\u003c/string\u003e\n\n      \u003ckey\u003eThrottleInterval\u003c/key\u003e\n      \u003cinteger\u003e180\u003c/integer\u003e\n\n      \u003ckey\u003eRunAtLoad\u003c/key\u003e\n      \u003ctrue/\u003e\n\n      \u003ckey\u003eUserName\u003c/key\u003e\n      \u003cstring\u003ehoward\u003c/string\u003e\n    \u003c/dict\u003e\n  \u003c/plist\u003e\n#+end_src\n\nVerify that the plist file is correct.\n#+begin_src sh\n  plutil -lint ~/Library/LaunchAgents/periodic.mbsync.plist\n#+end_src\n\nStart, stop and list service.\n#+begin_src sh\n  launchctl load -w /Users/USERNAME/Library/LaunchAgents/periodic.mbsync.plist\n  launchctl unload /Users/USERNAME/Library/LaunchAgents/periodic.mbsync.plist\n  launchctl list\n#+end_src\n\nScript that fetches mails and updates the mail index.\n#+begin_src sh :tangle ~/.bin/mbsync-task :shebang #!/bin/bash\n  echo \"\"\n  echo \"Running $(date +\"%Y-%m-%d %H:%M\")\"\n  /usr/bin/mbsync -Va\n  echo \"Exit code:\"\n  echo $?\n  /usr/local/bin/emacsclient -e '(mu4e-update-index)'\n  echo \"Exit code:\"\n  echo $?\n#+end_src\n* Emacsclient\nSimple /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:\n#+begin_src sh\n  /usr/local/bin/emacsclient -nc --socket-name work $*\n#+end_src\nChange the *Pass Input* to =as arguments=.\n\nSelect to *Save* as =Emacsclient= into the *Applications* folder.\n** Utils\nConvert a plist XML file into a JSON file. Not sure why this is important to know…\n#+begin_src sh\n  plutil -convert json -r ~/Library/LaunchAgents/gnu.emacs.plist\n#+end_src\nWhich should look a bit like:\n#+begin_src js\n  {\n      \"KeepAlive\" : true,\n      \"Label\" : \"gnu.emacs\",\n      \"ProgramArguments\" : [\n          \"\\/opt\\/homebrew\\/bin\\/emacs\",\n          \"--fg-dæmon\"\n      ],\n      \"RunAtLoad\" : true,\n      \"StandardErrorPath\" : \"\\/tmp\\/gnu-emacs-dæmon.log\",\n      \"StandardOutPath\" : \"\\/tmp\\/gnu-emacs-dæmon.log\",\n      \"UserName\" : \"USERNAME\"\n  }\n#+end_src\n\nConvert it back to XML\n#+begin_src sh\n  plutil -convert xml1 ~/Library/LaunchAgents/gnu.emacs.plist\n#+end_src\n** Resources\n#+begin_src sh\n  man launchd\n  man launchctl\n  man launchd.plist\n  man plutil\n  man plist\n#+end_src\n\n#+description: A literate programming file for installing a dæmon version of Emacs on MacOS.\n\n#+property:    header-args:sh :tangle no\n#+property:    header-args:emacs-lisp :tangle no\n#+property:    header-args   :results none   :eval no-export   :comments no\n\n#+options:     num:nil toc:t todo:nil tasks:nil tags:nil date:nil\n#+options:     skip:nil author:nil email:nil creator:nil timestamp:nil\n#+infojs_opt:  view:nil toc:t ltoc:t mouse:underline buttons:0 path:http://orgmode.org/org-info.js\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhowardabrams%2Fhamacs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhowardabrams%2Fhamacs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhowardabrams%2Fhamacs/lists"}