emacs / doom / editor group therapy

Doom is self-teaching in that aspect, eg
Suppose I hit SPC TAB to change my workspace,
and if I forget the precise shortcut,
after a second it shows a popup of all possible options/key bindings for SPC TAB (workspaces)
Which has made it pretty easy to learn

Nah, I mostly only use one program for programming, VS Code. The amount of non-programmers such as writers and scientists using Emacs for it’s awesome Org-mode got me interested, and when I saw I could get Vim/Emacs combined with Org mode in Doom with some easy keybindings, I jumped.

This is what Org Mode is about:

Literate programming is probably the coolest thing for documenting or teaching programming

I remember when I was learning NIm, a guy ahead of me who was documenting his progress,
said he had all his code within one giant Org file in Emacs,
all independently runnable within the same document,
no linking to gists required

I didn’t get how he did it until I watched this demo,
markup notes and runnable code all in the same document using Org-Babel
Can even be in unit blocks similar to Python Notebooks

In this demo he has shell, python, lisp and C++ all existing in the same file
and all runnable/writable with a click. :smiley:

You just wrap the code like so:

//your code

Literate programming is interesting, it takes the opposite view of people who say code doesn’t need comments since everything should be apparent just from naming schemes and breaking code up. Haskell has it built in but it’s Haskell so not today thanks.

Are you running that via Windows/MSYS2/WSL2?

Snooks I literally just watched that video myself,
the pic is a screenshot from it.
I’ll probably try org-babel out this weekend. Looks like a good way to document what I know/learn.

No MYSYS on my new pc, I start the Emacs GUI straight from WSL2 bash, same as VS Code.

I installed Doom emacs on MSYS2, had to build ripgrep from source and add it to PATH. It’s not the snappiest experience, but that could be the Win filesystem vs stuff designed for Linux where everything’s a file.

I read there’s a few things that don’t work properly on Win or MYSYS since it’s designed for *nix
That’s why I used WSL2

Why not install it on your Ubuntu boot?
I think the GUI would give a better experience.

It’s ok running in WIndows Terminal, background is a bit dark tho
Good enough for something quick
But there might be other display problems
eg running SPC c e (compile/evaluate) to output the result inline,
I can’t read it in the terminal version.

I went through the vanilla emacs tutorial first a couple of times
Then saved the tutorial and installed Doom
Now going back through the tutorial with the Doom-Vim shortcuts
Most of the vanilla emacs shortcuts stiill work in Doom, which can come in handy
Like SPC w w jumps windows until you hit an open terminal, then the keys are captured by the terminal
You need to press the vanilla emacs version, C-x o, to jump out of it
The Doom shortcuts are mostly better for me

If you want to try vanilla emacs to compare, there’s a sandbox for testing bugs
SPC h E opens the sandbox, then
C-c C-c starts vanilla emacs

I installed it in Linux and it seems a tad nippier. I think I might have been a bit distracted by the load time and the SPC menu taking a bit of time to come up, but I see that’s by design now.

Weirdly, no syntax highlighting for Lua and non-standard formatting for C++. I can sense a rabbit hole! :smiley:

A black hole for sure

Uncomment line 114 and 144 of ~/.doom.d/init.el

That’s better, thanks. Re-sycing takes a while though (on Linux). I’m going to stick my MSYS2 install in the bin and install the proper Windows version because it is in fact ridiculously slow.

C-h r r reloads Doom while it’s running

I’m surprised doom sync takes any time
Prob depends what was just enabled

I see from just resyncing on MSYS2 after changing the language settings there that there were 17 packages installed. To give you an idea of how slow it is, it took 208 seconds and rerunning took… wait for it… 25 seconds vs your 0.8!

So I got Org-babel working with multiple code files, elisp, shell and C++ :smiley:
Here’s a basic example

  1. C-x C-f 1.org RET - Create an Org file (that’s Ctrl-x Ctrl-f)

  2. Paste the code below in (y or Shift-Insert)

  3. Place your cursor anywhere in the code block you want to run,
    Hit C-c C-c to run it

#+TITLE: Babel-Code-001

# LISP ------------------------------------------------------------

#+begin_src emacs-lisp :dir ~/.doom.d
(directory-files ".")

# BASH -----------------------------------------------------------

#+begin_src sh :dir ~/.doom.d
ls -l

# C++ ------------------------------------------------------------

#+begin_src C++
#include <cstdio>
int main(){
    printf("It runs!!");


# C++ args ------------------------------------------------------------

#+name: build_input_file
#+BEGIN_SRC bash  :results none :exports none
echo "666 665" > in.txt

#+name: Function_with_input_args
#+BEGIN_SRC C++  :results output :exports both  :var tmp=build_input_file :cmdline < in.txt
#include <iostream>
using namespace std;

int main()
 int a, b;
 cin >> a >> b;
 cout << a << " + " << b << " = " << a+b;

@Snookoda I wrote some shortcuts for navigating the code blocks and running/deleting the results
The stock ones are terrible

Tweak 'em to your liking and paste them into ~/.doom.d/config.el, and reload with C-h r r
No need to doom sync

;; ----------------------------------------------------------------------------
;; ----------------------------------------------------------------------------

;;! Set C-c m  to toggle menu bar on
(global-set-key (kbd "C-c m") 'menu-bar-mode) 

;;! Set C-c c  to RUN CODE BLOCK
(global-set-key (kbd "C-c c") 'org-ctrl-c-ctrl-c)

;;! Set C-c d  to Delete RESULTS
(global-set-key (kbd "C-c d") 'org-babel-remove-result-one-or-many) 

;;! Set C-c n  to GO TO NEXT BLOCK
(global-set-key (kbd "C-c n") 'org-next-block)

;;! Set C-c b  to GO TO PREV BLOCK
(global-set-key (kbd "C-c b") 'org-previous-block)

Congrats, it looks useful! Over here my install of Doom for Win native went south so I am having a quick noodle with vanilla emacs before trying again. The .emacs.d dir has everything in it, including doom, but emacs isn’t picking any of it up. I have the dir in my PATH and HOME is set to my home dir, as per instructions.

Funnily enough, I was also annoyed by toggling the menu bar (and there’s a horrible toolbar in vanilla Win emacs as well).

Sounds quite different to *nix, the doom folder is ~/.doom.d there

Oh, I have that too… the doom command itself is in .emacs.d/bin:


I’ll have a play later to see what’s going on.

Oh gotcha…yes I do know that, I had to make an alias for that initially, I pasted in the export -to-path into my .bashrc and it wasn’t working…the badly formatted double quotes were the culprit.

Not the first time that’s happened to me either :smiley:

I’ll track it down using my 1337 skillz (… slowly switches computer off and on)! :slight_smile:

Btw this thing is good fun for a couple of minutes or to look like Mr ROBOT in front of non-techies…

edit: okay, I sense my Doom days are over - it’s too slow opening and operating on Windows proper.

Btw, the Doom issue, solved by doom doctor, was having a .emacs file, which stopped Doom from loading. Vanilla emacs loads like lightning but Doom emacs maybe a bit faster than MSYS2 install but not nippy at all.

It’s nice on Linux, so it seems like it is the GNU First dev that could be the problem. It might be something on my system too, but I can’ think what.

It’s really easy to set sequences of shortcuts in doom

The Function keys are undefined
So I wrote 2 shortcuts using them to speed up running the code,

F8 F8 to run the code inline

F8 F7 to show the error list

;;! Set F8 F8 Sequence to RUN CODE [SPC c e]
(global-set-key (kbd "<f8><f8>") '+eval/buffer-or-region)

;;! Set F8 F7 Sequence to SHOW ERRORS [SPC c x]
(global-set-key (kbd "<f8><f7>") 'flycheck-list-errors)

The error checking works great too,
Errors show a little red error icon in the bottom right
running either of those 2 shortcuts displays a popup error window
A little schmicker than VS Code in that regard

@Snookoda maybe we should move these posts to a Doom/Emacs thread , to save clogging up this one

And by we, I mean you :smiley:
You’re the moving posts guru