File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed
dots/emacs/spacemacs.d/layers/kzk-copilot Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -265,3 +265,26 @@ In that case, we simply bury the buffer
265
265
266
266
(with-current-buffer buffer
267
267
(aider-add-current-file)))
268
+
269
+
270
+ (defun kzk/aider-add-file (path &optional prefix )
271
+ " Adds file on path to the aider context.
272
+
273
+ When called with prefix, adds the file read only.
274
+ "
275
+
276
+ (interactive " fAdd File to Aider: \n P" )
277
+
278
+ ; ; Find buffer for file or create new temporary one
279
+ (let* ((existing-buffer (find-buffer-visiting path))
280
+ (buffer (or existing-buffer
281
+ (find-file-noselect path))))
282
+ (with-current-buffer buffer
283
+ (if (or prefix buffer-read-only)
284
+ (aider-current-file-read-only)
285
+ (aider-add-current-file)))
286
+
287
+ ; ; Kill buffer if we created it temporarily
288
+ (unless existing-buffer
289
+ (kill-buffer buffer))
290
+ (message " Added file %s to aider context " path)))
Original file line number Diff line number Diff line change 39
39
40
40
(with-eval-after-load 'embark
41
41
(define-key embark-buffer-map
42
- (kbd " M-%" ) #'kzk/aider-add-buffer ))
42
+ (kbd " M-%" ) #'kzk/aider-add-buffer )
43
+
44
+ (define-key embark-file-map
45
+ (kbd " M-%" ) #'kzk/aider-add-file ))
43
46
44
47
(push '(aider-comint-mode :width 78 :position left :stick t :noselect nil :dedicated nil )
45
48
popwin:special-display-config)
You can’t perform that action at this time.
0 commit comments