Trying Combobulate

Recently, I saw this article from Mickey Peteresen on his combobulate package. It looked interesting, so I thought I'd give it a go. I got together with a friend from the Austin TX based ATX Emacs group and we tried it out. Well, I did anyway, he was busy trying to compile Emacs with Tree-Sitter support on his Mac and not having much success.

I finally did get it working, but it took a moment to get things to setup. Since this was for Emacs 29, I compiled a version and made sure to include --with-tree-sitter. Then I thought to try out using package-vc-install to install combobulate, but alas, that didn't work. I was getting this error:

(file-error "https://melpa.org/packages/elpa-packages.eld" "Not found")

And it turns out, package-vc needs the elpa-packages.eld file, which neither MELPA nor MELPA Stable provide. Removing both from the package-archives resolved the error and installed the combobulate package.

UPDATE: 2023-02-13

The above has been fixed! I received an email from Philip Kaludercic, who let me know he had fixed this. I built a new version of Emacs29 and package-vc worked like a champ! Thanks Philip!!

… now back to the rest of the article previously posted …

Since package-vc was giving me difficulties at the time, I used quelpa to install the package (the debugging to resolve the error above came later). I used this recipe to get combobulate installed:

(quelpa '(combobulate :fetcher github :repo mickeynp/combobulate))

If you read the GitHub page, he provides a detailed configuration for getting tree-sitter language sources and compiling them. However, there is the tree-sitter-langs package which already does this. Some deep diving into the treesit package built-in to Emacs 29 led me to the tree-sitter folder in the user-emacs-directory. I used dired to copy the files from the tree-sitter-langs package, and then used wdired mode to rename them in bulk to be prefixed with tree-sitter- and presto! Everything just worked! Here is the final configuration which worked for me:

;; if neither MELPA nor MELPA Stable are in package-archives this
;; should work:
;; (package-vc-install '(combobulate :url "https://github.com/mickeynp/combobulate"))

;; Works even if MELPA or MELPA Stable (or both) are in the
;; package-archives
(quelpa '(combobulate :fetcher github :repo mickeynp/combobulate))

;; manual step: copy .so files from tree-sitter-langs to
;; tree-sitter/tree-sitter-*.so in the user-emacs-directory

;; add more languages as necessary
(add-to-list 'major-mode-remap-alist '(python-mode . python-ts-mode))

;; add more language hooks as necessary
(add-hook 'python-ts-mode 'combobulate-mode)

Combobulate was fun to use. The navigation works exactly was I had hoped. Coming from writing a lot of Emacs Lisp, the movement matched my existing habits. I am looking forward to more features than just movement, though. Things like smartparens slurp or barf concepts, refactoring (like extract method, wrap with conditional, rename, etc), perhaps indentation linting. For the moment, movement is good enough and LSPs (although, the refactoring support is dismal – but that's another topic) or intelligent snippets provide some of the other features .

Tags: #emacs