She/her 🏳️⚧️
Professional cow, Linux Nerd, Hardcore Techno enthusiast. The Emporer protects us.
🌉 bridged from @cows_are_underrated@feddit.org by Tidepool
@cows-are-underrated.feddit.org.ap.tdpl.io
10 Posts15 Comments0 Memberships
Joined October 2026
She/her 🏳️⚧️
Professional cow, Linux Nerd, Hardcore Techno enthusiast. The Emporer protects us.
🌉 bridged from @cows_are_underrated@feddit.org by Tidepool
My Colleagues really drive me crazy
I got the first prototype version of the code for the project I'm currently working on. It is an Arduino Sketch, that contains 1k lines, stores every single Value needed as a global Variable and every function reads and writes to these global variables, instead of taking them in as parameters. This code is so bad, that I refuse to even look at it. The effort to take the existing codebase and transform it into something useable is as high as rewriting it from scratch.
When telling my colleague that his code is absolute garbage, he just told me "its not my code, Claude did it". I am constantly pushing towards implementing the project in a proper way, but it has been nothing but fights against people who don't know how to code and who refuse to acknowledge that ignoring any standards of maintainable code does not turn out in the end and it makes sense to rewrite the project sooner than later.
Was macht ihr mit den Blättern?
So ihr lieben, da bei mir jetzt auch bald die Ernte ansteht (sobald meine Pflanzen nicht mehr komplett Nass vom Regen sind kommen die ab), Frage ich mich, was ich so mit dem Rest der Pflanze mache. Ich wollte zumindest einen Teil der Blätter aufheben für Tee oder sonstige Dinge, aber es würde mich mal interessieren, ob und wie ihr die Blätter eurer Pflanzen verwertet.
Inlining Library functions
So I have the following problem. I am currently writing some Libraries in C++ as a way to get started with the language. In my library I want to use the inline keyword for a function to reduce the overhead caused by lots of function calls. The problem I have is, that it seems like it is not possible to inline functions, if I dont define them in my libraries header file.
So I got three files, that I am working with. My library (lib.cpp), its header file (lib.h) and my main code (main.cpp). My testing code for my library looks like this (this is just example code that has the same structure, but with different functionality):
main.cpp
#include <iostream>
#include "lib.h"
using namespace std;
int main(){
int count = 5;
float sum = get_sum(count);
cout << "Sum of 0-" << count << ": " << sum << endl;
int num = get_num(6);
cout << "Got num: " << num << endl;
return 0;
return 0;
}And my library looks like this: lib.cpp
#include "lib.h"
inline int get_num(int num){
return num;
}
int get_sum (int count){
int sum = 0;
for(int i = 0; i < count; i++){
sum = sum + get_num(i);
}
return sum;
}Naturally I created my header file like this: lib.h
#ifndef LIB_H #define LIB_H inline int get_num(int num); int get_sum (int count); #endif
The problem with this is, that this code will throw an compile error that theres no definition for get_num in main.cpp. This can be fixed by simply moving the entire function with its body into the header file.
The problem I have with doing it like this is, that this causes my inline function to not show up inside my lib.cpp file and gets hidden away in the header file. Is there a way that I can define my inline functions in my libraries source code, and expose it as a public function through my header file?
Improving the styling of emacs tables with tabularray
So I had the following situation: I am writing my entire software documentation in emacs orgmode, so that I can export it to LaTeX later on. Part of that documentation are quite a lot of tables. The problem is, that by default LaTeX tables (and respectively emacs tables) dont look very good. In this post I will describe my journey of unimaginable pain while going through the process of learning LaTeX in order to gett pretty and uniform tables when exporting orgmode documents to LaTeX. You can find my example files on gitlab. This is primarily meant to be a tutorial and therefore I wont go into every possibility I tried along the way. The technical discussions and tradeoffs (or simply things I could not get to work, even tho they should work) will be discussed the chapter about limitations.
So if we export a table with the default settings, it will look like this: image We can already see the first problem here: Our table is too wide and has no vertical lines. This however can be changed by specifying the columns and the vertical lines:
#+caption: Specifying maximum width and vlines with LaTeX attributes in tabular
#+attr_latex: :align |r|l|p{10cm}|
|-----------+-------------------+----------------------------------------------------------------------------------------|
| Exit code | Type | Meaning |
|-----------+-------------------+----------------------------------------------------------------------------------------|
| 0 | External/Internal | Succesfull operation; logical true |
|-----------+-------------------+----------------------------------------------------------------------------------------|
| 1 | Internal | Non successfull operation; logical false |
|-----------+-------------------+----------------------------------------------------------------------------------------|
| 2 | Internal | A reallly long error message that is long enough to not fit on a single sheet of paper |
|-----------+-------------------+----------------------------------------------------------------------------------------|Which looks like this when being rendered: image So now our table finally fits on a page and we got vertical lines. There are a number of possible attributes that can be supplied this way, if you want to know more about this, you can find the documentation here. However I think its time to address the obvious: I do not want to paste a bunch of atrributes that I may have to adjust (depending on the table, since we have to specify columns ourselves) for every single table. It is unneccessary work and adds unneccessary lines that could be avoided and dont ever think about changing the way you want your tables to look, because then you can redo the whole process. Its time we find a way to style all of our tables in a way, that they can: • Introduce automatic linebreaks if the input gets too long • Look the same for all tables of our choice • Color individual rows/columns (e.g. make the backgrounf color of the first row grey) • Handle tables independendly of their column count • Handle tables spanning multiple pages
Since it seems like that emacs is rather limited in doing anything like a global table style, it became relatively clear, that I would have to go and do this directly in LaTeX. Luckily the tabularray package for LaTeX is able to do exactly this. The tabularray package also makes it much easier to create more complex LaTeX tables, when compared to the regular tabular enviroment. To add the package simply add the following to your file: #+LATEX_HEADER: \usepackage{tabularray}
To start we first need to learn some basics about LaTeX and how emacs handles exporting tables to it. And how we have to adjust this behaviour to our needs. Lets take a look at what the second table looks like once emacs has exported it:
\begin{tabular}{|l|lp{10cm}|r|}
\hline
Exit code & Type & Meaning\\
\hline
0 & External/Internal & Succesfull operation; logical true\\
\hline
1 & Internal & Non successfull operation; logical false\\
\hline
2 & Internal & A reallly long error message that is long enough to not fit on a single sheet of paper\\
\hline
\end{tabular}As you can see, the table itself defines each cell using an "&" and adding horizontal lines between them. These lines are being manually added by pressing C-c RET in your table. Emacs also used the tabular enviroment (\begin{tabular}) for the table, which is the default table enviroment for LaTeX. You also see that our latex argument got directly passed to the enviroment as an additional argument (this part is called the inner specification of the enviroment). This will come in handy later, once we replaced the tabular enviroment with our own one.
First of all: How do we even insert raw LaTeX into orgmode documents? There is a number of different ways to achieve this. You can add LaTeX headers with #+LATEX_HEADER: or insert a single line by using #+LATEX:. If we want to include multiple lines with #+LATEX:, we can also use the #+BEGIN_EXPORT or #+BEGIN_src syntax. We can even use a seperate orgfile in which we store all of our table styles and include it with #+INCLUDE:, which is what we are going to do here. Dump all the LaTeX into a seperate file, so that we dont have to copy it for all of our documents. The advantage of specifying this on a seperate org file (I will call it table_style.org instead of a plain tex file is, that by doing it this way, you can add all packages that you need for your table style in the table_style.org file itself and don't have to include them in your main file (you can not use the \usepackage command in the body of a document, which is where the included tex file would be included).
First of all, lets create our new table enviroment:
\NewTblrEnviron{globaltbl}
\SetTblrInner[globaltbl]{
}What this does is, that it creates a completely new table enviroment called globaltbl and every single table that uses this enviroment will inherit all attributes (which we will set in a second) from it. However we will still be able to override all values for each table.
And now lets add some basic attributes to the inner definition:
\NewTblrEnviron{globaltbl}
\SetTblrInner[globaltbl]{
vlines,
hlines,
width = 0.9\linewidth,
rowsep = 4pt,
colsep = 8pt,
colspec={X[t,l]X[t,l]X[t,l]X[t,l]},
}image
The hlines and vlines arguments tell tabularray to always draw horizontal and vertical lines between cells, regardless of the appearance of any manually inserted \hline. If the hline option has been given, inserting a \hline into the table will cause tabularray to render a snall gap at the position of the \hline. The width=0.9\linewidth sets the width of the table to 0.9x the width of a single line. The rowsep and colsep attributes control how much space between your text input and your hlines / vlines you have.
If you want a deeper understanding of the colspec attribute please go and look up cell alignemts of the tabularray package. For now all you need to know is, that this defines four columns for our table style and each column will align its text at the top left of the cell (indicated by t and l in the specifications for each column). Since we use the so called X column here, we also get automatic linebreaks in our table. If we dont want this, we would have to use the primitive Q column instead (replace all occurences of X with a Q in the colspec).
So we were able to set the width of our table, but what if I want to e.g. color the first row grey and all following uneven rows too, but in a different shade? Dont worry, all of this is very easy. We simply define these rows in our table style and are good to go:
row{1} = {
bg=grey9,
fg=white,
font=\bfseries,
halign=c
},
row{odd[3]} = {
bg=grey5
}The same principle can be applied to columns, single cells and even single hlines and vlines:
row{odd[3]} = {bg=gray9}, %% Change bg color of all odd rows starting with the third row
column{2} = {halign=r}, %%align the second column to the right
cell{4}{3} = {bg=red}, %% Change the bg color of the cell in the 4th row and third column
hline{3}={dotted, red}, %%Change the way the third horizontal line gets renderedWe can also specify ranges of columns (etc).
column{1-2} = {mode=text} %%changes the mode of the first two columns
column{Z} = {mode=text} %%Change the mode of the last column
column{3-Y} = {mode=math} %%changes the mode of each column except the first two and the last columnSo now that we know how to create our table style, how do we use it inside our org files? Sadly it seems like there is no way to directly set the enviroment of our tables to our custom enviroment (if you know a better solution please tell me), however there are a few tricks we can use. Using the \renewenviroment command from LaTeX, we can tell the LaTeX engine to replace the enviroment of all following tables to another enviroment (it can be used for more than tables, but we only care about tables here). Since the command only affects following enviroments, we can also use the command multiple times in a file to cycle between multiple layouts. Lets assume we have defined the table enviroments globaltbl and nonglobaltbl, then we could use the corresponding styles like the following:
#+LATEX: \renewenvironment{tabular}{\begin{globaltbl}}{\end{globaltbl}}
.... table 1 ....
.... table 2 ....
#+LATEX: \renewenvironment{tabular}{\begin{nonglobaltbl}}{\end{nonglobaltbl}}
.... table 3 ....
#+LATEX: \renewenvironment{tabular}{\begin{globaltbl}}{\end{globaltbl}}
.... table 4 ....So now that we have seen how to pre set values, how do we override them for a single table? Well, we just have to pass our table the corresponding arguemnts to the table. So if I as example want to set the color of a single cell in my table (lets say the top left cell) to red. Well, I simply add
#+attr_latex: :align cell{1}{1} = {bg=red}
to my table and Im good to go. Everything that we can specify in the inner definition of our enviroment, can be overwritten this way. Using this we can go absolutely wild with our tables, without affecting any other tables:
#+attr_latex: :align row{2}={bg=blue,fg=white}, row{1}={fg=green, halign=l}, width=0.5\linewidth, hline{3}={text=<<<<<<<<<<, red}
#+caption: Its always possible to override absolutely anything, while still using nonglobaltbl
|-----------+-------------------+----------------------------------------------------------------------------------------|
| Exit code | Type | Meaning |
|-----------+-------------------+----------------------------------------------------------------------------------------|
| 0 | External/Internal | Succesfull operation; logical true |
|-----------+-------------------+----------------------------------------------------------------------------------------|
| 1 | Internal | Non successfull operation; logical false |
|-----------+-------------------+----------------------------------------------------------------------------------------|
| 2 | Internal | A reallly long error message that is long enough to not fit on a single sheet of paper |
|-----------+-------------------+----------------------------------------------------------------------------------------|Now lets say, what happens if our table suddenly becomes really really big and is longer than it is possible to vertically fit onto a single page? Well, lucky for us, tabularray got us covered by providing the longbtlr enviroment for us to use for this case. We can simply override its specifications:
\SetTblrInner[longtblr]{
%%specifications as we are used to
}First up: As far as I'm concerned, there is no way to create multicolumn or multirow cells inside emacs, the way it is possible with LaTeX, without having to dig very deep into the latex-export-backend of orgmode. This is 100% out of my skillrange and it is something I dont need (yet). If you really need this, you will have to use LaTeX directly. If you really need the math functionalities, but also multirow­column cells, and have so many of them, that you cant type them by hand anymore, than its probably time to automate the creation of your tables in any other way.
The only way it is possible to mimick multirow/-column cells is by controlling where hlines and vlines are being drawn. The easiest way to mimic multirow columns is to turn off hlines and manually insert the lines in the orgmode table by pressing C-C RET inside your table, as it can be seen here:
image
image
image
If you want to use an empty enviroment that has no specifications (which means it will look like the default tabularray table), simply define a new enviroment, without setting its inner specification:
\NewTblrEnviron{deftblr}
One limitation is, that with the current approach of using the \renewenviroment command, you will no longer be able to use your default export enviroment later in your file. This might not be a problem when working alone, but it might become a problem when collaborating with other people. Sadly I was not able to figure out if there is any other way to reliably change the enviroment of a table (or respectively all tables in the document). However I was also never able to change the enviroment of a single table to tblr (the name used for tabularray in emacs) the way it has been decribed here. It is also not possible to embed tables directly into the text. This can only be achieved by typesetting the table directly in LaTeX and using tabularrays talltblr enviroment.
I would say that jumping through the hoops to create some good looking table style is really worth it. First of all its way better than manually pasting the same 20 arguments for every table. It allows you to use multiple styles in the same document and if you need extended functionality of the tabularray package like multirow/-column cells or the talltblr enviroment to embed tables directly into your text, then it is pretty easy to do this, since new styles can be created on the fly and tabularray is relatively easy to use.
Trans Hyprland rice to screw the transphobes
So I finally got into tiling window managers and tried out hyprland. I spent quite a good amount configuring everything and there is still a hell of a lot more to do, but I am already loving the matching colors and the general look and feel.
Global table styles in LaTeX Export for Orgmode
So I have a problem I would bet at least some people know: Styling tables inside Orgmode. The problem is, that you have to copy paste the same configuration that makes sure your table looks good for each single table. Since this is quite tedious and quite a pain if you have lots and lots of tables. After some searching I figured out, that I can use the tabularray LaTeX Package for this. The problem is, that I quite suck with LaTeX, and there is not that much information about global tabular enviroments for this. The only Information I could find was this stackexchange post regarding global table enviroments and some general information about tabularray, which can be found here. The table style I want is in fact quite simple. I want the top row to be colored grey (which I already implemented myself) and I need the table style to allow for multiline columns and I need automatic line breaks in case theres more text in a single cell than theres space in the line. Additionally the table should always be aligned in the center of the page. I have the following example orgmode-document (the \renewenviroment command is to switch the default enviroment from tables to my global table style)
#+Options: toc:nil
#+LATEX_CLASS: article
#+LATEX_CLASS_OPTIONS: [a4paper]
#+LATEX_HEADER: \usepackage{booktabs}
#+LATEX_HEADER: \usepackage{tabularray}
#+LATEX_HEADER: \usepackage{xcolor}
#+LATEX_HEADER: \NewTblrEnviron{globaltbl}
#+LATEX_HEADER: \SetTblrInner[globaltbl]{hlines, vlines, row{1} = {bg=gray5, fg=white, font=\bfseries}, rowsep = 4pt, colsep = 8pt, width = \linewidth}
#+LATEX_HEADER: \SetTblrOuter[globaltbl]{baseline = m}
#+LATEX_HEADER: \renewenvironment{tabular}{\begin{globaltbl}}{\end{globaltbl}}
|-----------+-------------------+-----------------------------------------------------------------------------------|
| Exit code | Type | Meaning |
|-----------+-------------------+-----------------------------------------------------------------------------------|
| 0 | Internal/External | Succesfull operation; logical true |
| | some other | |
|-----------+-------------------+-----------------------------------------------------------------------------------|
| 1 | Internal | Non successfull operation; logical false and some other text that is not important |which generates the following LaTeX file:
% Intended LaTeX compiler: pdflatex
\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{capt-of}
\usepackage{hyperref}
\usepackage{tabularray}
\usepackage{booktabs}
\usepackage{tabularray}
\usepackage{xcolor}
\NewTblrEnviron{globaltbl}
\SetTblrInner[globaltbl]{hlines, vlines, row{1} = {bg=gray5, fg=white, font=\bfseries}, rowsep = 4pt, colsep = 8pt, width = \linewidth}
\SetTblrOuter[globaltbl]{baseline = m}
\renewenvironment{tabular}{\begin{globaltbl}}{\end{globaltbl}}
\author{cow}
\date{\today}
\title{}
\hypersetup{
pdfauthor={cow},
pdftitle={},
pdfkeywords={},
pdfsubject={},
pdfcreator={Emacs 30.2 (Org mode 9.7.11)},
pdflang={English}}
\begin{document}
\begin{center}
\begin{tabular}{rll}
\hline
Exit code & Type & Meaning\\
\hline
0 & Internal/External & Succesfull operation; logical true\\
& some other & \\
\hline
1 & Internal & Non successfull operation; logical false and some other text that is not important\\
\end{tabular}
\end{center}
\end{document}which renders to the following table: image As you can see in the first column, that tabularray does not insert an hline to create a new coluumn, but still renders this thinner line. Is there a way to turn this off? You can also see, that the rest of the last cell gets cut off. I would really appreciate if someone could help me with this, since I have zero Idea what else to try.
Exporting from orgmode
So, I started to use orgmode for writing the documentation for my latest software project. This means, that I have code blocks and lots of special characters in my document. I will have to export this whole file to LaTex/pdf, so my colleague can bind it into his project documentation and this is exactly where my problems are. First of all: how can I turn of the need to manually stop the code execution for code blocks when exporting? I have the single line src_bash{} blocks but also the multiline versions:
#+begin_src bash : #code #+ends_src
The next thing is, that my function names include underscores, which in orgmode translates to making the following text lowercase. I tried using \ to escape it, but that only breaks it in a new way and I seriously cant comprehend how this so called zero width space is supposed to be used.
Automatic line breaks in emacs
So I have the following problem. I use emacs (specifically orgmode, but my problem applies to emacs in general) quite a lot for writing longer texts (In the long term I even plan on writing scientific papers with emacs). However, one of the problems I have is line formatting. As you probably all know, emacs does not really have default "automatic line breaks" as you know them from rich text editors like LibreOffice. Instead emacs then just moves the entire window you see to the right, if a single line gets too long. Since this is awful for editing I started to add line breaks manually, however the problem is, that you then have to manually re-do the entire formatting if you decide to change the structure of one ore more sentences/lines, which is kind of annoying. The next problem is, that it may look good on your screen with the manual linebreaks, but the formatting then often looks bad when viewed on smaller screens. One solution I saw is, that if a line gets to long, that emacs then just puts the rest of the line into a new line on the screen, without inserting a line break. How can I enable this behaviour in my emacs config? I also found out about Auto Fill mode, however I kind of dont like, that it inserts a new linebreak relatively fast (my screen is wide, so I want to use it) and the problem with exporting still stands. Anyone got any good workarounds that might be helpful?
Be Pet, Gay Dogs
Or when you restart your computer......