Skip to content

Instantly share code, notes, and snippets.

@sogaiu
sogaiu / issue-3-comment.md
Last active May 13, 2026 07:33
janet-ts-mode custom indentation

The latest approach is to try to get different behavior based on whether the indentation is line-related or region-related.

Emacs provides two variables that can be set to functions that handle each type of indentation:

  • indent-region-function, and
  • indent-line-function

The idea is to provide an appropriate function for each of these variables.

I've tried out the code below along with the following commands:

# https://github.com/sogaiu/jog
$ jog '{:dump true}' ~/src/janet/src/boot/boot.janet
[
["/home/user/src/janet/src/boot/boot.janet" 11 3 "def" "defn" nil "```\n (defn name & more)\n\n Define a function. Equivalent to `(def name (fn name [args] ...))`.\n ```"]
["/home/user/src/janet/src/boot/boot.janet" 47 3 "defn" "defmacro" "[name & more]" "\"Define a macro.\""]
["/home/user/src/janet/src/boot/boot.janet" 52 3 "defmacro" "as-macro" "[f & args]" "``Use a function or macro literal `f` as a macro. This lets\n any function be used as a macro. Inside a quasiquote, the\n idiom `(as-macro ,my-custom-macro arg1 arg2...)` can be used\n to avoid unwanted variable capture of `my-custom-macro`.``"]
["/home/user/src/janet/src/boot/boot.janet" 60 3 "defmacro" "defmacro-" "[name & more]" "\"Define a private macro that will not be exported.\""]
["/home/user/src/janet/src/boot/boot.janet" 65 3 "defmacro" "defn-" "[name & more]" "\"Define a private function that will not be exported.\""]
["/home/user/src/janet/src/boot/
@sogaiu
sogaiu / doc-string.janet
Created May 12, 2026 08:35
remarkable trees
(import ../src/remarkable/remarkable :as r)
(comment
# paragraphs
(def paragraphs
``
This is the first paragraph.
This is another paragraph.

mikethompson:

I've found the AIs to be amazing. Staggering really. But I do regard them like a 12 year old savant.  Most problems come from them not having enough information. There's stuff in your head that they don't know.

Hence being spec driven. I have to iterate before I ask them to do anything substantive.

Spec driven just means "prompt engineering driven"

The imperative code that didibus found was because I never said "prefer a functional solution unless it impacts performance critical code". The moment I did, we were good.

@sogaiu
sogaiu / gdb-misc-notes.md
Last active May 1, 2026 04:13
miscellaneous gdb notes
@sogaiu
sogaiu / gud-auto-center-source-buffer.el
Created April 25, 2026 23:36
emacs gdb auto-center source buffer around current line
;; references:
;;
;; * https://superuser.com/a/118138
;; * https://superuser.com/a/1680006
;; * http://kousik.blogspot.com/2005/10/highlight-current-line-in-gdbemacs.html
(defadvice gud-display-line (after my-gud-display-line-center activate)
;; true-file is an argument to the original function
(let* ((buffer (gud-find-file true-file)))
(save-excursion
(with-selected-window (get-buffer-window buffer)
@sogaiu
sogaiu / notes.md
Created April 25, 2026 04:03
janet near far regalloc
JanetSlot janetc_value(JanetFopts opts, Janet x) {
    JanetSlot ret;
    JanetCompiler *c = opts.compiler;
    // ...
    /* Special forms */
    if (spec) {
        const Janet *tup = janet_unwrap_tuple(x);
        ret = spec->compile(opts, janet_tuple_length(tup) - 1, tup + 1);