From fad3843b2ba6176a4c0834b66e27584fcf7aed17 Mon Sep 17 00:00:00 2001 From: Jack Jamison Date: Fri, 26 Dec 2025 18:48:58 -0500 Subject: move articles to directories --- .../content/blog/emacs-garbage-collection.md | 43 --------------------- .../content/blog/emacs-garbage-collection/index.md | 43 +++++++++++++++++++++ zola-static/content/blog/first.md | 18 --------- zola-static/content/blog/first/index.md | 18 +++++++++ .../content/blog/my-emacs-tips-and-tricks.md | 45 ---------------------- .../content/blog/my-emacs-tips-and-tricks/index.md | 45 ++++++++++++++++++++++ zola-static/content/blog/sdl-native-wayland.md | 19 --------- .../content/blog/sdl-native-wayland/index.md | 19 +++++++++ 8 files changed, 125 insertions(+), 125 deletions(-) delete mode 100644 zola-static/content/blog/emacs-garbage-collection.md create mode 100644 zola-static/content/blog/emacs-garbage-collection/index.md delete mode 100644 zola-static/content/blog/first.md create mode 100644 zola-static/content/blog/first/index.md delete mode 100644 zola-static/content/blog/my-emacs-tips-and-tricks.md create mode 100644 zola-static/content/blog/my-emacs-tips-and-tricks/index.md delete mode 100644 zola-static/content/blog/sdl-native-wayland.md create mode 100644 zola-static/content/blog/sdl-native-wayland/index.md (limited to 'zola-static/content/blog') diff --git a/zola-static/content/blog/emacs-garbage-collection.md b/zola-static/content/blog/emacs-garbage-collection.md deleted file mode 100644 index 26cf5d9..0000000 --- a/zola-static/content/blog/emacs-garbage-collection.md +++ /dev/null @@ -1,43 +0,0 @@ -+++ -title = "A Solution to Emacs Garbage Collection Stutters" -date = 2025-05-12 -updated = 2025-05-14 -+++ - -The more you load Emacs up with packages, the more it starts to chug. Throw on a theme and an lsp client, and you might start to notice frequent stuttering. - -This problem was very frustrating for me - I want to be able to hold `C-n` and linearly move down the document, micro-stutter *free*. I spent weeks searching for the problem, and considered quitting Emacs altogether. - -# Garbage Collection -It turns out that the problem wasn't that packages were executing slowly, it was the garbage that they were building up. - -Emacs' garbage collector waits until a byte threshold (the `gc-cons-threshold` variable) has been reached before executing. Its default value feels relatively low for a modern computer - only `800KB`. This results in frequent garbage collections, each causing a small stutter. Luckily, as with most things in Emacs, you can tune this behaviour. -> If you want to see how frequently the GC is triggered, try setting `garbage-collection-messages` to non nil (you might be surprised). - -Opinions on the ideal solution differ. -- Some people recommend **increasing** the threshold, leading to longer times without triggering the GC but longer stutters. -- Others recommend **lowering** the threshold, causing more frequent GC triggers but smaller stutters. -- The minibuffer (especially with packages like `vertico`) can use a lot of memory, so some [recommend](https://bling.github.io/blog/2016/01/18/why-are-you-changing-gc-cons-threshold/) increasing the threshold only when using it. - -# The Solution -In my opinion, the best solution is to garbage collect **when idle**. When editing, you're often pausing briefly - and if there is little garbage, Emacs can collect it very quickly. -I also *basically* disable the threshold entirely when in the minibuffer. Here's the code from my `init.el`. - -```lisp -(defun my-minibuffer-setup-hook () - (setq gc-cons-threshold most-positive-fixnum)) - -(defun my-minibuffer-exit-hook () - (setq gc-cons-threshold 800000000)) - -(setq gc-cons-threshold most-positive-fixnum) - -(run-with-idle-timer 1.2 t 'garbage-collect) -``` - -I have been using this for a few months and it's worked perfectly. I've tried my best to notice the garbage collections, I haven't been able to. - -> There is a package for this, called [the Garbage Collector Magic Hack](https://github.com/emacsmirror/gcmh). Personally I prefer a lower idle time than its default, and I like keeping it in my own config. - -# Update: IGC Branch -After posting this article, [some users on reddit](https://www.reddit.com/r/emacs/comments/1km1by3/comment/ms750w3/) informed me that there is an [Emacs branch](https://git.savannah.gnu.org/cgit/emacs.git/tree/README-IGC?h=feature/igc#n1) in development which greatly improves the garbage collector efficiency. People are saying that it has completely eliminated their stutters. I recommend trying it out. diff --git a/zola-static/content/blog/emacs-garbage-collection/index.md b/zola-static/content/blog/emacs-garbage-collection/index.md new file mode 100644 index 0000000..26cf5d9 --- /dev/null +++ b/zola-static/content/blog/emacs-garbage-collection/index.md @@ -0,0 +1,43 @@ ++++ +title = "A Solution to Emacs Garbage Collection Stutters" +date = 2025-05-12 +updated = 2025-05-14 ++++ + +The more you load Emacs up with packages, the more it starts to chug. Throw on a theme and an lsp client, and you might start to notice frequent stuttering. + +This problem was very frustrating for me - I want to be able to hold `C-n` and linearly move down the document, micro-stutter *free*. I spent weeks searching for the problem, and considered quitting Emacs altogether. + +# Garbage Collection +It turns out that the problem wasn't that packages were executing slowly, it was the garbage that they were building up. + +Emacs' garbage collector waits until a byte threshold (the `gc-cons-threshold` variable) has been reached before executing. Its default value feels relatively low for a modern computer - only `800KB`. This results in frequent garbage collections, each causing a small stutter. Luckily, as with most things in Emacs, you can tune this behaviour. +> If you want to see how frequently the GC is triggered, try setting `garbage-collection-messages` to non nil (you might be surprised). + +Opinions on the ideal solution differ. +- Some people recommend **increasing** the threshold, leading to longer times without triggering the GC but longer stutters. +- Others recommend **lowering** the threshold, causing more frequent GC triggers but smaller stutters. +- The minibuffer (especially with packages like `vertico`) can use a lot of memory, so some [recommend](https://bling.github.io/blog/2016/01/18/why-are-you-changing-gc-cons-threshold/) increasing the threshold only when using it. + +# The Solution +In my opinion, the best solution is to garbage collect **when idle**. When editing, you're often pausing briefly - and if there is little garbage, Emacs can collect it very quickly. +I also *basically* disable the threshold entirely when in the minibuffer. Here's the code from my `init.el`. + +```lisp +(defun my-minibuffer-setup-hook () + (setq gc-cons-threshold most-positive-fixnum)) + +(defun my-minibuffer-exit-hook () + (setq gc-cons-threshold 800000000)) + +(setq gc-cons-threshold most-positive-fixnum) + +(run-with-idle-timer 1.2 t 'garbage-collect) +``` + +I have been using this for a few months and it's worked perfectly. I've tried my best to notice the garbage collections, I haven't been able to. + +> There is a package for this, called [the Garbage Collector Magic Hack](https://github.com/emacsmirror/gcmh). Personally I prefer a lower idle time than its default, and I like keeping it in my own config. + +# Update: IGC Branch +After posting this article, [some users on reddit](https://www.reddit.com/r/emacs/comments/1km1by3/comment/ms750w3/) informed me that there is an [Emacs branch](https://git.savannah.gnu.org/cgit/emacs.git/tree/README-IGC?h=feature/igc#n1) in development which greatly improves the garbage collector efficiency. People are saying that it has completely eliminated their stutters. I recommend trying it out. diff --git a/zola-static/content/blog/first.md b/zola-static/content/blog/first.md deleted file mode 100644 index bfed8ba..0000000 --- a/zola-static/content/blog/first.md +++ /dev/null @@ -1,18 +0,0 @@ -+++ -title = "My First Article" -date = 2025-05-11 -updated = 2025-05-12 -+++ - -This is my first blog post. I am using this post to learn how to configure my site and its style. - -> This article is going to be weird, and use a lot of features. - -### Code block test -```c++,name=main.cpp -#include - -int main() { - std::cout << "hello world" << std::endl; -} -``` diff --git a/zola-static/content/blog/first/index.md b/zola-static/content/blog/first/index.md new file mode 100644 index 0000000..bfed8ba --- /dev/null +++ b/zola-static/content/blog/first/index.md @@ -0,0 +1,18 @@ ++++ +title = "My First Article" +date = 2025-05-11 +updated = 2025-05-12 ++++ + +This is my first blog post. I am using this post to learn how to configure my site and its style. + +> This article is going to be weird, and use a lot of features. + +### Code block test +```c++,name=main.cpp +#include + +int main() { + std::cout << "hello world" << std::endl; +} +``` diff --git a/zola-static/content/blog/my-emacs-tips-and-tricks.md b/zola-static/content/blog/my-emacs-tips-and-tricks.md deleted file mode 100644 index 46ea4e5..0000000 --- a/zola-static/content/blog/my-emacs-tips-and-tricks.md +++ /dev/null @@ -1,45 +0,0 @@ -+++ -title = "My Emacs Configuration Tips and Tricks" -date = 2025-10-22 -+++ - -# Introduction -Throughout my time using GNU Emacs and its package ecosystem, I've found some annoying quirks that took a while to figure out, and I'm documenting them here. This will be a living document. - -# Fixes -## General Stutters (Caused by Garbage Collection) -Garbage collection stutters is a common problem among Emacs users, and I have a constroversial solution which has worked for me. Basically: **only garbage collect when you are idle** (even for short periods of time). Read more about it [here](@/blog/emacs-garbage-collection.md). -```lisp -(defun my-minibuffer-setup-hook () - (setq gc-cons-threshold most-positive-fixnum)) - -(defun my-minibuffer-exit-hook () - (setq gc-cons-threshold 800000000)) - -(setq gc-cons-threshold most-positive-fixnum) - -(run-with-idle-timer 1.2 t 'garbage-collect) -``` - -## Lsp-Mode Gives Bad Completion Results -Sometimes completion results won't refresh or refilter. This one pissed me off for a while because I couldn't quite nail down whose fault it was. It turns out that it was `lsp-mode` being overzealous with caching. There is a [cape](https://github.com/minad/cape) transformer which breaks the cache and fixes the results. Here's part of my config: -```lisp -(use-package cape - :init - (defun my/lsp-capf-busted () - "Return an uncached LSP completion function." - (cape-capf-buster #'lsp-completion-at-point)) - (add-hook 'lsp-completion-mode-hook - (lambda () - (setq-local completion-at-point-functions - (list (my/lsp-capf-busted)))))) -``` - -# General Advice -## Which Lsp Client? -I use `lsp-mode`. I would love to switch to `eglot`, but I really like `lsp-ui`'s peek feature and it hasn't been ported to eglot yet. -There are several other lsp clients meant to increase speed (such as [lsp-bridge](https://github.com/manateelazycat/lsp-bridge)), but I've got the best results on `lsp-mode` with [lsp-booster](https://github.com/blahgeek/emacs-lsp-booster). - - - - diff --git a/zola-static/content/blog/my-emacs-tips-and-tricks/index.md b/zola-static/content/blog/my-emacs-tips-and-tricks/index.md new file mode 100644 index 0000000..359a6ef --- /dev/null +++ b/zola-static/content/blog/my-emacs-tips-and-tricks/index.md @@ -0,0 +1,45 @@ ++++ +title = "My Emacs Configuration Tips and Tricks" +date = 2025-10-22 ++++ + +# Introduction +Throughout my time using GNU Emacs and its package ecosystem, I've found some annoying quirks that took a while to figure out, and I'm documenting them here. This will be a living document. + +# Fixes +## General Stutters (Caused by Garbage Collection) +Garbage collection stutters is a common problem among Emacs users, and I have a constroversial solution which has worked for me. Basically: **only garbage collect when you are idle** (even for short periods of time). Read more about it [here](@/blog/emacs-garbage-collection/index.md). +```lisp +(defun my-minibuffer-setup-hook () + (setq gc-cons-threshold most-positive-fixnum)) + +(defun my-minibuffer-exit-hook () + (setq gc-cons-threshold 800000000)) + +(setq gc-cons-threshold most-positive-fixnum) + +(run-with-idle-timer 1.2 t 'garbage-collect) +``` + +## Lsp-Mode Gives Bad Completion Results +Sometimes completion results won't refresh or refilter. This one pissed me off for a while because I couldn't quite nail down whose fault it was. It turns out that it was `lsp-mode` being overzealous with caching. There is a [cape](https://github.com/minad/cape) transformer which breaks the cache and fixes the results. Here's part of my config: +```lisp +(use-package cape + :init + (defun my/lsp-capf-busted () + "Return an uncached LSP completion function." + (cape-capf-buster #'lsp-completion-at-point)) + (add-hook 'lsp-completion-mode-hook + (lambda () + (setq-local completion-at-point-functions + (list (my/lsp-capf-busted)))))) +``` + +# General Advice +## Which Lsp Client? +I use `lsp-mode`. I would love to switch to `eglot`, but I really like `lsp-ui`'s peek feature and it hasn't been ported to eglot yet. +There are several other lsp clients meant to increase speed (such as [lsp-bridge](https://github.com/manateelazycat/lsp-bridge)), but I've got the best results on `lsp-mode` with [lsp-booster](https://github.com/blahgeek/emacs-lsp-booster). + + + + diff --git a/zola-static/content/blog/sdl-native-wayland.md b/zola-static/content/blog/sdl-native-wayland.md deleted file mode 100644 index 1f163f7..0000000 --- a/zola-static/content/blog/sdl-native-wayland.md +++ /dev/null @@ -1,19 +0,0 @@ -+++ -title = "Why SDL3 doesn't use Wayland on Wayland." -date = 2025-08-06 -updated = 2025-08-08 -+++ - -[SDL3](https://wiki.libsdl.org/SDL3/FrontPage) is a great platform abstraction layer. On Linux, it compiles with support for both [X Window System](https://www.x.org/wiki/) and [Wayland](https://wayland.freedesktop.org/). This is great because it makes your app compatible with just about any desktop environment or window manager. In the [SDL3 documentation](https://wiki.libsdl.org/SDL3/README-wayland) it says that -> Wayland is a replacement for the X11 window system protocol and architecture and is favored over X11 by default in SDL3 - -However, if your compositor does not implement the `wp_fifo_manager_v1` protocol SDL will fall back to XWayland. My compositor doesn't have it, and here's how I forced SDL to use Wayland anyway (for c++). -```c++ -for (int i = 0; i < SDL_GetNumVideoDrivers(); i++) { - if (std::string(SDL_GetVideoDriver(i)) == "wayland") { - SDL_SetHintWithPriority(SDL_HINT_VIDEO_DRIVER, "wayland", SDL_HINT_OVERRIDE); - break; - } -} -``` -This code will explicitly enable Wayland if it is available. diff --git a/zola-static/content/blog/sdl-native-wayland/index.md b/zola-static/content/blog/sdl-native-wayland/index.md new file mode 100644 index 0000000..1f163f7 --- /dev/null +++ b/zola-static/content/blog/sdl-native-wayland/index.md @@ -0,0 +1,19 @@ ++++ +title = "Why SDL3 doesn't use Wayland on Wayland." +date = 2025-08-06 +updated = 2025-08-08 ++++ + +[SDL3](https://wiki.libsdl.org/SDL3/FrontPage) is a great platform abstraction layer. On Linux, it compiles with support for both [X Window System](https://www.x.org/wiki/) and [Wayland](https://wayland.freedesktop.org/). This is great because it makes your app compatible with just about any desktop environment or window manager. In the [SDL3 documentation](https://wiki.libsdl.org/SDL3/README-wayland) it says that +> Wayland is a replacement for the X11 window system protocol and architecture and is favored over X11 by default in SDL3 + +However, if your compositor does not implement the `wp_fifo_manager_v1` protocol SDL will fall back to XWayland. My compositor doesn't have it, and here's how I forced SDL to use Wayland anyway (for c++). +```c++ +for (int i = 0; i < SDL_GetNumVideoDrivers(); i++) { + if (std::string(SDL_GetVideoDriver(i)) == "wayland") { + SDL_SetHintWithPriority(SDL_HINT_VIDEO_DRIVER, "wayland", SDL_HINT_OVERRIDE); + break; + } +} +``` +This code will explicitly enable Wayland if it is available. -- cgit v1.2.3