Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: Erlmacs – a script to update your .emacs file for Erlang development (github.com/dlachausse)
44 points by dlachausse on Sept 10, 2023 | hide | past | favorite | 9 comments
erlmacs automatically configures and updates your .emacs file with support for the emacs mode that is included with Erlang/OTP. It frees you from having to locate the installation directory of Erlang/OTP and its bundled emacs mode.

It is an escript that only depends upon Erlang/OTP and Emacs.

Note: There is not much in the way of error checking at this moment, but it does make a backup of your .emacs files before any destructive operations.




Changing config files is tricky (this wouldn't work as written for me because like many many people, I keep my emacs init in ~/.emacs.d/init.el instead of ~/.emacs). Why not do something like this?

  (eval (car 
    (read-from-string
      (format "(progn %s)"
              (shell-command-to-string "/path/to/erlmacs elisp")))))
Change erlmacs to just emit the elisp when you call it with 'elisp', then add the above snippet to your emacs init (or provide this setup as a elpa package).

Pro: you won't have to remember to call `erlmacs install` again when you periodically do `asdf install erlang latest`. Con: the version of erlang that gets `(erlang-start)` called is determined by your environment / the nearest .tool-versions file when you first invoke emacs.


Pushing this idea a little further, the only information that erlmacs uses that isn't available elsewhere is the value of ErlRoot. You could write a two-line script that simply emits erlroot on stdout (or fails), and invoke that from .emacs to configure your emacs environment appropriately. As a bonus, that erlroot script would probably be useful in other situations, too.


Good point! The next version should support other config file locations. This is something of a minimum viable solution to a problem I wanted to solve for myself.

I’m definitely open to feature requests and suggestions.


Hmm, I'm trying to say that it's much less brittle for the config setup to get 'pulled' from inside emacs rather than 'pushed' into an emacs config.


This is true. I might refactor the codebase to do what you're suggesting in the future.

For now I just pushed a new v1.1.0 release that automatically detects and supports ~/.emacs.el and ~/.emacs.d/init.el in addition to ~/.emacs as configuration file locations.

That should fix this problem for most people for now although I agree that your suggestion is probably more robust overall.


Why not simply post a .el file that people can load or copy paste into their existing config?


The issue is that depending on your OS and installation method, the paths you need to use for your configuration file can vary greatly. This automates finding those paths and writing them to the configuration file.


which is why my .config/emacs/init.el has this in it:

    (cond ((eq system-type 'darwin)
           (macos-config))
          ((eq system-type 'gnu/linux)
           (linux-config))
          ((eq system-type 'windows-nt)
           (windows-config)))


That solves the OS differences but not the differences in installation methods, ie compiled from source, system package manager, Windows installer, KERL, Homebrew, etc.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: