Posts Archive

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?

Tmux over fancy terminals

tmux

I do like minimal stuff so I have avoided most of the terminal with tabs and fancy “features”. Turns out, all I want, I can get from tmux.

A few tips from my usage

If you are a dwm user, I have just set up to open the tmux directly

static const char *cmd_term[] = { "st", "-e", "tmux", NULL };
// inside Key
{ MODKEY, XK_Return, spawn, {.v = cmd_term } }, // terminal

This is interesting because everytime you open the terminal a new session will pop. Hate it or love it.

/comments ~lucasemmoreira/opinions@lists.sr.ht?Subject=Re: Tmux over fancy terminals

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

A keyboard utility for everyone

life

Have you ever noticed that your on your keyboard the letters j and f both have a little dent on it. Well, that is not by chance. I will tell you more, my brazilian keyboard as well as my american keyboard, also have it.

Why? It is a way for you to find the “rest” position of your hands without you having to look at it. Is your mind blown? Mine was!

/comments ~lucasemmoreira/opinions@lists.sr.ht?Subject=Re: A keyboard utility for everyone

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

Indent file on save, please

code format align

So, I discovered that I really like to format the code on save (I am not the best typer). So emacs to the rescue:

(defun le2m/indent-buffer ()
  "indent whole buffer"
  (delete-trailing-whitespace)
  (indent-region (point-min) (point-max) nil)
  (untabify (point-min) (point-max)))

(add-hook 'clojure-mode-hook
          (lambda ()
            (add-hook 'before-save-hook
                      #'le2m/indent-buffer
                      t t)))

I did this on clojure-mode but it can be done in any mode I guess.

/comments ~lucasemmoreira/opinions@lists.sr.ht?Subject=Re: Indent file on save, please

Wait, do you want to choose a alias with cider?

code clojure cider

Another thing you may want/need is to use an alias when connecting cider. I know that cider can have that set up on your configuration. You can use .dir-locals.el to set up per project but I personally prefer to be able to choose when connecting.

(defun start-cider-repl-with-lein-profile ()
   (interactive)
   (letrec ((profile (read-string "Enter profile name: "))
          (lein-params (concat "with-profile +" profile " repl :headless :host localhost")))
     (message "lein-params set to: %s" lein-params)
     (set-variable 'cider-lein-parameters lein-params)
     (cider-jack-in '())))

 (defun start-cider-repl-with-cli-profile ()
   (interactive)
   (letrec ((profile (read-string "Enter profile name: "))
          (cli-params (concat "-A:" profile)))
     (message "cli-params set to: %s" cli-params)
     (set-variable 'cider-clojure-cli-aliases cli-params)
     (cider-jack-in '())))

/comments ~lucasemmoreira/opinions@lists.sr.ht?Subject=Re: Wait, do you want to choose a alias with cider?