From d0420ae5e32293a8b3960e3630deed006dad05ff Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Tue, 13 Dec 2022 07:14:06 -0800 Subject: [PATCH] [oni-core] Add related-files[1] to consult-buffer[2] [1]: https://github.com/DamienCassou/related-files [2]: https://github.com/minad/consult --- oni-core.el | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/oni-core.el b/oni-core.el index 0f55ee9..9ba6943 100644 --- a/oni-core.el +++ b/oni-core.el @@ -4,7 +4,7 @@ ;; Author: Tom Willemse ;; Keywords: local -;; Version: 2022.1213.071035 +;; Version: 2022.1213.071336 ;; Package-Requires: (oni-data-dir oni-embrace oni-hydra expand-region multiple-cursors gcmh diminish ws-butler which-key insert-char-preview mixed-pitch ace-window vertico marginalia orderless consult embark docstr) ;; This program is free software; you can redistribute it and/or modify @@ -407,6 +407,28 @@ _s_: String list" (global-set-key (kbd "M-g M") '("Jump to a mark anywhere" . consult-global-mark)) (global-set-key [remap imenu] 'consult-imenu) +(defun oni-core-related-files () + "Return a list of files related to the current buffer." + (let* ((jumpers related-files-jumpers) + (current-place (buffer-file-name))) + (cond ((not jumpers) + (user-error "No jumpers. Consider configuring `related-files-jumpers'")) + ((not current-place) + (user-error "Related-Files only works from file-based buffers")) + (t + (related-files--collect-existing-places jumpers current-place))))) + +(defvar oni-core-related-places-source + '(:name "Related File" + :category file + :items oni-related-files + :enabled buffer-file-name + :action find-file)) + +(with-eval-after-load 'consult + (with-eval-after-load 'related-files + (add-to-list 'consult-buffer-sources 'oni-related-places-source))) + ;;; Embark (global-set-key (kbd "C-.") 'embark-act)