The Complete Computing Environment

Consult-Buffer Org Roam Source


Okay, so Consult provides a composable, high performance buffer selector in the form of consult-buffer; it has extensible sources that are, basically, built to work with completing-read, so org-roam-find-file can work with it. This is exceedingly powerful as now any of my org-roam files are on my consult-buffer, at my fingertips.

jgru/consult-org-roam provides a bunch of nice features which should be bound in to my org-roam command prefix.. It's not in MELPA or anything, just another thing that expects me to use straight-use-package to load it — well here is some fucked up stuff for providing it to Arroyo Emacs's init generator via ARROYO_HOME_EPKGS.

(use-package consult-org-roam
  (message "Loading consult-org-roam HERE")
  (require 'consult-org-roam)
  ;; Activate the minor-mode
  (consult-org-roam-mode 1)
  ;; restore behavior of consult-buffer overridden by consult-org-roam-buffer... prefer mine.
  (consult-org-roam-grep-func #'consult-ripgrep)
  ;; Eventually suppress previewing for certain functions
  (message "Trying to override consult-org-roam-buffer behavior HERE...")
  (consult-org-roam-buffer--customize-source-buffer nil)
   :preview-key (kbd "M-."))
  :bind (:map org-roam-prefix-map)
  ("b" . consult-org-roam-backlinks)
  ("/" . consult-org-roam-search)
  (after-cce . (lambda ()
                 (message "Trying to override consult-org-roam-buffer behavior HERE (after-cce)...")
                 (consult-org-roam-buffer--customize-source-buffer nil)))
  :after (consult org-roam))

(provide 'cce/consult-org-roam)
consult-org-roam = (let
  versions = pkgs.lib.pkgVersions.consult-org-roam;
  rev = pkgs.lib.pkgVersions.consult-org-roam-rev;
in epkgs.melpaBuild {
  pname = "consult-org-roam";
  version = "20220416.2107";
  commit = rev;

  src = pkgs.callPackage versions {};

  recipe = pkgs.writeText "recipe" ''
       :repo "jgru/consult-org-roam"
       :fetcher github)

  packageRequires = [ epkgs.consult ];

  meta = {
    homepage = "";
    license = lib.licenses.gpl3Plus;
(condition-case nil
      (require 'consult)
      (require 'consult-org-roam)

      (defface consult-org-roam
        '((t :inherit font-lock-function-name-face))
        "Face used to highlight org-roam entries in `consult-buffer'.")

      (defvar consult--source-org-roam
          :name     "Org Roam"
          :narrow   ?r
          :category org-roam
          :face     consult-org-roam
          :state    consult-org-roam--node-preview
          :action   ,(lambda (cand &optional restore)
                        (get-text-property 0 'node cand)))
          :items    ,(lambda ()
                       (seq-map (lambda (item) (car item))
        "Org-Roam candidate source for `consult-buffer'.")

      ;; disable builtin one which only shows buffers and not nodes...
      (setq consult-buffer-sources (delq 'org-roam-buffer-source consult-buffer-sources))
      (add-to-list 'consult-buffer-sources 'consult--source-org-roam t))
  (error nil)
(provide 'cce/consult-buffer-org-roam)

NEXT figure out why this has to be crammed in to extraEmacsPackages in Arroyo Home Manager support for Emacs