
https://github.com/nashamri/spacemacs-logo?tab=readme-ov-file / Licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
I’ve been using Spacemacs for years. Spacemacs is addressed to Vim (through evil mode) and Emacs users (the slogan of Spacemacs is: The best editor is neither Emacs nor Vim, it’s Emacs and Vim), and has contributed to the passing of many Vim users to Emacs, but it can be used in pure Emacs mode.
Many advanced users consider it a fallback that takes away from the “true” Emacs management, which involves installing extension packages one by one and configuring them individually. I disagree. I believe Spacemacs (and other frameworks like Doom) has done a lot to help popularize Emacs among non-expert users, but it’s also incredibly helpful for advanced users.
Its layered architecture allows specifying the dependencies of each feature group defined by the layer and ensures that everything needed to use them is downloaded and installed. This doesn’t mean you can’t always define a custom configuration, overriding the default. Spacemacs does the heavy lifting for us, but it also allows us to fine-tune and adapt each package to our needs.
Updating Spacemacs from the GUI can be a bit annoying because it forces us to wait for it to finish, which can sometimes be quite long. Furthermore, in the event of a major or minor version change of Emacs, all packages must be downloaded and recompiled.
The following Bash script, spacemacs-update.sh, does this for us. We can include it in a cron job (perhaps during off-hours) so our Emacs is always up to date and ready to use.
The script performs two update processes. The first is for the development version (which is updated very frequently). Given the importance of Emacs in my work cycle, I like having a ready-to-use alternative to my production version (installed via the system package manager, in my case Debian‘s apt suite) to overcome problems and allow me to work anyway. The second updates the production (official) version.
The script accepts a parameter (compile), which allows both processes to be done. Alternatively, it can be run without parameters, in which case it only updates the production version. This saves time. Occasionally, you can run
spacemacs-update.sh compile
to keep everything up to date if needed.
To help understanding, here are some notes on the functioning of the spacemacs-update.sh script:
- The first part contains a check to permit the execution of the script with only one argument. If this is defined, it must be the keyword compile. Previously, this argument was converted into lowercase letters.
- A section follows in which the code is updated for layers manually installed (residents in ~/.emacs.d/private/). I always try to use Git repositories to allow for an efficient update.
- Below is the git pull of the Spacemacs code. The script waits five seconds to allow you to read any error messages.
- If the compile argument is defined, the script realizes the update of the development version. The operating mode for both developed and production versions is the same. The difference lies in the value of the emacs_version variable.
- The new versions of Emacs have integrated support for Tree-sitter (a parser generator tool and an incremental parsing library). I prefer to install it from the system, but it is also possible to compile and install it as shown in the code.
- The Tree-sitter and Emacs codes are found respectively in the ~/software/Tree-sitter and ~/software/Emacs directories. Then, Tree-sitter and Emacs are compiled.
- The subsequent block of code downloads and installs the updateable packages of Emacs and recompiles EAF (Emacs Application Framework) if the case. I highly recommend the installation and use of EAF, which transforms Emacs into a modern and powerful platform (the other mandatory component is LSP, Language Server Protocol, mode). All these packages are installable from MELPA (Milkypostman’s Emacs Lisp Package Archive). In addition to e-mail (using Gnus), I also use Emacs for Internet navigation (EAF-browser) and as a terminal (EAF-terminal). EAF-browser is more limited than Firefox or Chrome, but it is ideal for work. For streaming and other uses, conventional browsers must still be used.
- There is a problem (at least in my installation) in the compilation of EAF-terminal. So the script makes the compilation of this app as root and then sets the current user as the owner of the files.
Code:
#!/bin/sh # Translate argument to lowercase arg=$(echo "$1" | tr '[:upper:]' '[:lower:]') # Usage if [ -n "$arg" ]; then if [ "$arg" = "-h" ] || [ "$arg" = "--help" ] || [ $arg != "compile" ]; then echo "Usage: spacemacs-update.sh [ compile ]" exit fi fi #----------------------------------------------------------------------------- # Updating spacemacs's private layers (if there are) #----------------------------------------------------------------------------- cd ~/.emacs.d/private/calendar; git pull cd ~/.emacs.d/private/maxima; git pull cd ~/.emacs.d/private/media; git pull #----------------------------------------------------------------------------- # Spacemacs #----------------------------------------------------------------------------- git -C ~/.emacs.d/ pull --rebase # I need sometime to see if something was wrong sleep 5 #----------------------------------------------------------------------------- # Emacs develop # # It is convenient to upgrade the develop version first because some packages # are rebuilt with every upgrade (e.g. Org, under certain conditions), which # causes versioning issues if the development version upgrade comes after the # production version one. #----------------------------------------------------------------------------- if [ -n "$arg" ] && [ "$arg" = "compile" ]; then # Code from git are in ~/Software/Emacs and ~/Software/Tree-sitter # You have to change user:group with those of the current user # This package is required for compilation. The '*' option allows obtaining # the version compatible with the version of gcc installed. sudo apt -y install libgccjit-*dev # I make sure the permissions are those of the current user sudo chown -R user:group ~/Software/Tree-sitter ~/Software/Emacs # Updating Tree-sitter. You can install the build from the repository (for # example, sudo apt install libtree-sitter-dev libtree-sitter0.22). If it's # not available, you can clone the code from GitHub using: # # git clone https://github.com/tree-sitter/tree-sitter.git # # and compile it: cd ~/Software/Tree-sitter git pull make sudo make install # Emacs git pull and compilation. Clone code with: # # git clone git://git.sv.gnu.org/emacs.git # # It must be installed in /usr/local/bin/. Give prefix to configure to # change the default installation path. cd ~/Software/Emacs git pull ./autogen.sh ./configure --with-tree-sitter --with-native-compilation --with-mailutils --with-pop make sudo make install # Download and prepare /usr/local/bin/emacs --batch -l ~/.emacs.d/init.el --eval="(configuration-layer/update-packages t)" # Install /usr/local/bin/emacs --batch -l ~/.emacs.d/init.el --eval="(configuration-layer/update-packages t)" # Updating EAF emacs_version=`/usr/local/bin/emacs --version | head -n 1 | cut -d' ' -f 3 | awk -F . '{ print $1 "." $2 }'` cd ~/.emacs.d/elpa/$emacs_version/develop/eaf-* ./install-eaf.py --install-all-apps echo echo 'EAF directory:' pwd # EAF-TERMINAL compile modules. There's a problem with my installation while # compiling EAF-terminal. So I'm re-running the installation process for # this package only as root and then change my user permissions. cd app/terminal rm -rf node_modules sudo npm install cd .. sudo chown -R user:group terminal fi #----------------------------------------------------------------------------- # Emacs main (production, using the package from the Debian repository) # # sudo apt install emacs #----------------------------------------------------------------------------- # Download and prepare /usr/bin/emacs --batch -l ~/.emacs.d/init.el --eval="(configuration-layer/update-packages t)" # Install /usr/bin/emacs --batch -l ~/.emacs.d/init.el --eval="(configuration-layer/update-packages t)" # Updating EAF emacs_version=`/usr/bin/emacs --version | head -n 1 | cut -d' ' -f 3 | awk -F . '{ print $1 "." $2 }'` cd ~/.emacs.d/elpa/$emacs_version/develop/eaf-* ./install-eaf.py --install-all-apps echo echo 'EAF directory:' pwd # EAF-TERMINAL compile modules cd app/terminal rm -rf node_modules sudo npm install cd .. sudo chown -R user:group terminal #----------------------------------------------------------------------------- # EAF-TERMINAL solarized colors #----------------------------------------------------------------------------- ./eaf-terminal-solarized-colors.sh
The last line of code executes the script eaf-terminal-solarized-colors.sh. I am not satisfied with the default colors of EAF-terminal, so I prefer to change some to be consistent with solarized-dark, my favorite Emacs theme.
#!/bin/sh #----------------------------------------------------------------------------- # Production version #----------------------------------------------------------------------------- emacs_version=`/usr/bin/emacs --version | head -n 1 | cut -d' ' -f 3 | awk -F . '{ print $1 "." $2 }'` cd ~/.emacs.d/elpa/$emacs_version/develop/eaf-*/app/terminal sed -i 's/00ff00/728905/g' dark_theme.js sed -i 's/6c71c4/d33682/g' dark_theme.js sed -i 's/93a1a1/839496/g' dark_theme.js sed -i 's/268bd2/2075c7/g' dark_theme.js #----------------------------------------------------------------------------- # Develop version #----------------------------------------------------------------------------- emacs_version=`/usr/local/bin/emacs --version | head -n 1 | cut -d' ' -f 3 | awk -F . '{ print $1 "." $2 }'` cd ~/.emacs.d/elpa/$emacs_version/develop/eaf-*/app/terminal sed -i 's/00ff00/728905/g' dark_theme.js sed -i 's/6c71c4/d33682/g' dark_theme.js sed -i 's/93a1a1/839496/g' dark_theme.js sed -i 's/268bd2/2075c7/g' dark_theme.js
EAF-pyqterminal is a more powerful alternative than EAF-terminal (it allows, for example, scrolling with the mouse, which EAF-terminal cannot do). However, it is more difficult to change the colors, and the format of the text appears to be problematic. Currently, I prefer EAF-terminal.