Showing 413 to 416

Smart tabs in 2024

There is an old little-used #emacs package for smart tabs. All the languages it supports:

(require 'smart-tabs-mode)
(smart-tabs-insinuate 'c 'c++ 'java 'javascript 'cperl 'python 'ruby 'nxml)
(add-hook 'c-mode-common-hook #'indent-tabs-mode)
(add-hook 'java-mode-hook #'indent-tabs-mode)
(add-hook 'js2-mode-hook #'indent-tabs-mode)
(add-hook 'cperl-mode-hook #'indent-tabs-mode)
(add-hook 'python-mode-hook #'indent-tabs-mode)
(add-hook 'ruby-mode-hook #'indent-tabs-mode)
(add-hook 'nxml-mode-hook #'indent-tabs-mode)

Not much, is it? But that's ok, this way to do it has always been somewhat doomed.

Let's say you share a codebase with people on different platforms. It's not as if you can tell a VSCode person to install the above Emacs-Lisp package.

Autoformatters like gofmt do smart tabs for you these days, and when you can't mandate an autoformatter, the standard way to prevent chaos has been a "spaces only" rule. Maybe when we get an .editorconfig rule for smart tabs (issue 323), this can change?

(Once that's finalized, then Emacs is gonna need a new way more general smart-tabs-mode! Probably based on tree-sitter.)

As far as I can figure, "spaces only" must have been the pragmatic option since the dawn of computing, but maybe the innovations of tree-sitter and editorconfig finally make tabs a real option.


Someone points out that editorconfig's indent_style = tabs rule actually makes no sense if it's not smart tabs anyway, so it shouldn't exist. Makes you think who was using that rule before…

I.e. the choices are:

  • Spaces only: OK
  • Smart tabs: OK
  • Tabs only, used as "wide spaces" assuming they will be rendered at a specific width: no
Created (6 months ago)

Is that function autoloaded yet?

#emacs

Our lab rat today is the builtin ido package. It has a command ido-mode, autoloaded on demand. Now assuming you have not loaded it, check out the return values:

(featurep 'ido)  ;; => nil
(fboundp 'ido-mode) ;; => t
(autoloadp (symbol-function 'ido-mode)) ;; => t

Then we do M-x load-library ido RET, and see how the return values change.

(featurep 'ido)  ;; => t
(fboundp 'ido-mode) ;; => t
(autoloadp (symbol-function 'ido-mode)) ;; => nil

TL;DR: to check if ido exists, it's safest to use fboundp on one of its functions.

Created (6 months ago)

Watch the timer-list work in realtime

#emacs

You know the list-timers command? It shows you all the active timers, but it's a snapshot frozen in time, at the moment you ran the command.

I was curious to watch the timers count down, so I made this command.

(let ((this-timer (timer-create)))
  (defun my-timer-list-animate ()
    "Start auto-refreshing the \\[list-timers] buffer.
Stop once the buffer is no longer visible."
    (interactive)
    (cancel-timer this-timer)
    (let ((buf (get-buffer "*timer-list*")))
      (when (and buf (get-buffer-window buf 'visible))
        (run-with-timer .2 nil #'my-timer-list-animate)
        (save-window-excursion
          (save-excursion
            (with-current-buffer buf
              (revert-buffer))))))))
(keymap-set timer-list-mode-map "a" #'my-timer-list-animate)

Interestingly, the idle timers still aren't shown to count down, even though idle-time is going up! I'm guessing list-timers never was meant for that, so it takes a shortcut by just showing the max time regardless.

Created (6 months ago)

Enthusiastically presenting your neck to the sword of truth

A statistician interprets research for other people, so that those other people do not themselves have to be statisticians. The others hope the job is done objectively, and want to be able to trust in that, but that trust will always be limited if they don't know who the statistician is.

In an organization with many statisticians, such as a census bureau, we can trust in the fact that they tend to put more than one pair of eyes on each analysis before publishing results. But that's not the norm in science. The norm is one to two people per paper (the author and their supervisor) who really interprets the research!

(Peer-review is still spotty and subject to luck; there are almost no journals in 2022 with systematic peer-review, and it appears fairly easy to get lorem ipsum text published in high-impact journals. Not to mention simonwillison.net/2024/Mar/15/certainly-here-is-google-scholar/)

Knowing this, most papers should be assigned low a priori believability. I think researchers—and statisticians when that's not the same thing—both stand to gain a lot of credibility by going public with their persona, like Andrew Gelman, via personal blogs, books, or something like that, where they make transparent how they think and do their very best to be pedagogical.

(At least if their only agenda is the search for truth. If they have other agendas, it may not be wise.)

They'd also admit every bias they have, every belief they currently hold, and what they used to believe that turned out to be wrong. They'd tell us where they came from and how they were raised. We need it in order to properly be able to interpret that person's interpretations, so at least for me, I'd feel better knowing these things and could be more secure in trusting their reasoning.

The path by which someone arrives at their conclusion is just as important to know as the conclusion itself.

Thus, publicly Unpacking beliefs. A public PredictionBook. Publicly making bets with real money (per one of the closing remarks of Book: Inadequate Equilibria).

Enthusiastically presenting your neck to the sword of truth.

Excited for it to slice your head off—a bit less when it turns out that Truth was already on your side and you have to keep your head. That's, like, time wasted. Who needs their beliefs confirmed?

Created (3 years ago)
Updated (6 months ago)
Showing 413 to 416