Emacs

Erlang small QoL

erlang emacs

This is small proposal to improve erlang navigation when coding. It is a two piece adjustment:

In the Makefile

tags:
        find src include deps -name "*.[he]rl" -print | xargs etags -o TAGS

And in emacs, you can do this:

(defun le2m/erlang-update-tags ()
  (interactive)
  (let ((root (locate-dominating-file default-directory "Makefile")))
    (when root
      (let ((default-directory root))
        (shell-command "gmake tags")
        (message "Tags updated")))))

(advice-add 'erlang-compile :before #'le2m/erlang-update-tags)

When typing C-c C-k, the TAGS file will be “automagically” created

/comments ~lucasemmoreira/opinions@lists.sr.ht?Subject=Re: Erlang small QoL

Org-roam over org-brain?

emacs life

Org roam seems to be very nice indeed. Maybe I will ditch org-brain

/comments ~lucasemmoreira/opinions@lists.sr.ht?Subject=Re: Org-roam over org-brain?

Emacs mode line

emacs

If like me, you don’t mind how pretty the modeline looks in your emacs, then you can set it pretty easy.

Why would you want to do this? Well, what happens is that I have a pretty small screen in my monitor and if I split vertically, I lose some useful information like the time on a task.

Now to the how:

(setq-default mode-line-format
            (list "%e"
                  mode-line-remote
                  mode-line-modified
                  mode-line-front-space
                  mode-line-frame-identification

                  mode-line-buffer-identification "   "

                  mode-line-position project-mode-line

                  "  "
                  mode-line-misc-info
                  mode-line-end-spaces))

Not sure what all that is? Checking the docs in emacs is ez ;]

/comments ~lucasemmoreira/opinions@lists.sr.ht?Subject=Re: Emacs mode line

Org mode audience

emacs life

Org-mode is not for everybody, I think. However, I do think that org-mode is for anybody that is willing to learn enough elisp to shape the desired workflow.

/comments ~lucasemmoreira/opinions@lists.sr.ht?Subject=Re: Org mode audience

Improving mode line in emacs

code emacs

A nice UI feature in emacs in my configuration was having a bit more control over the mode line (the thing between the buffer and the mini buffer).

Now that I have been controling my hours with emacs org clock, it is really nice to have at glance how many hours I have been working. The issue is that sometimes, my config has a bunch of minor modes and the mode line has a lot of noise. dminish-mode was a great finding for this!

/comments ~lucasemmoreira/opinions@lists.sr.ht?Subject=Re: Improving mode line in emacs

Improved (maybe) indenting on save

code format align emacs

I realized that sometimes identing the whole buffer might not be the desired output. That because if the file is on different identation, your git commit might be hard to follow.

Because of that I studied a bit emacs lisp and came up with similar idea. On save, indent only the function that you are working on.

(defun le2m/indent-function ()
"indent only function"
;; (interactive)
(delete-trailing-whitespace)
(let ((begin (save-excursion (beginning-of-defun) (point)))
      (end (save-excursion (end-of-defun) (point))))
  (indent-region begin end nil)))

/comments ~lucasemmoreira/opinions@lists.sr.ht?Subject=Re: Improved (maybe) indenting on save

Running repl commands in cider (emacs)

code clojure emacs cider

Ok, I will admit.. this took a while. But I have found a nice way of doing this.

What is this? Well, let’s say that you have a command to start your server in user namespace. With this cool feature, now you can run this with a emacs command (or shortcut if you bind it).

The cool thing about this is that the command will run with the namespace from the repl and not the last ns that you loaded with cider =].

Here is a taste:

(defun le2m/cool-repl-command ()
 (interactive)
 (cider-interactive-eval
  (cider-insert-in-repl (format "(clojure.core/require 'a-namespace)
                                  (a-namespace/do-something
                                  (fn lambda-example [t] (:get-a-key (meta t))))") 't)))

  1. stackoverflow reference that started this

/comments ~lucasemmoreira/opinions@lists.sr.ht?Subject=Re: Running repl commands in cider (emacs)

Restclient is dead… Now we have verb!

emacs rest tools

Recently I found an interesting mode in emacs to manage and run http requests!

enjoy! heheh

/comments ~lucasemmoreira/opinions@lists.sr.ht?Subject=Re: Restclient is dead… Now we have verb!

Emacs code navigation? TAAAGS!

emacs tools

Do you know when you open a code file and you want to navigate it but you have to fire up a whole enviroment just to do it? In clojure, would be cider, in python it would be elpy and so on…

Well, get ready feel free! All you need is a command line and vanilla emacs!!

The command is etags. What this command does is look for all the definitions you made in the files you pass as an argument with the language and it will create a TAGS file in the current directory.

find . -type f -name "*.clj" | xargs etags --language=lisp

Once that is done, use you xref-find-definitions and xref-pop-marker-stack command (alias in vanilla as M-. and M-,, respectively) and it will ask you where is the TAGS table.

You can reset the table with tags-reset-tags-table. If it feel very UNIX like, you would be right. It is! Enjoy!

Oh, not sure what languages are supported? Fear not!

etags --help

  1. emacs tags
  2. elpy
  3. cider

/comments ~lucasemmoreira/opinions@lists.sr.ht?Subject=Re: Emacs code navigation? TAAAGS!

Emacs? No, emacsclient!

emacs terminal

This is a shoutout for all of you who are tired of waiting emacs to load on startup or annoyed to feel forced to leave an instance open.

emacsclient can save you from that. All you have to do is to leave an daemon open. Don’t use (server-start) because that will force you to have an GUI or terminal open at all time. The solution? A command.

On your terminal (or .xsession file):

emacs --daemon

After that, you can invoke emacs GUI with emacsclient -c and emacsclient -t to open directly in the terminal. The colors probably will not match, so you can take a look here =].

Now, to make life a little bit better, you can create alias/binary

alias emt='emacsclient -t'
#!/bin/sh
emacsclient -c -F '((font . "Hack 12"))'

The latter I use as a binary in $PATH to be invoked with rofi or as a shortcut in the dwm.

Thanks Pedro for the post idea hehe.

/comments ~lucasemmoreira/opinions@lists.sr.ht?Subject=Re: Emacs? No, emacsclient!