Skip to content

Commit 2556bfb

Browse files
authored
Merge pull request #69 from bobrowadam/eca-find-root-for-buffer-function
Add custom variable 'eca-find-root-for-buffer-function
2 parents 80fafab + 65fb089 commit 2556bfb

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

eca-chat.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2271,7 +2271,7 @@ if ARG is current prefix, ask for file, otherwise drop current file."
22712271
(interactive "P")
22722272
(eca-assert-session-running (eca-session))
22732273
(-let ((path (if (equal arg '(4))
2274-
(read-file-name "Select the file to drop from context: " (eca-find-root-for-buffer))
2274+
(read-file-name "Select the file to drop from context: " (funcall eca-find-root-for-buffer-function))
22752275
(buffer-file-name))))
22762276
(eca-chat--with-current-buffer (eca-chat--get-last-buffer (eca-session))
22772277
(eca-chat--remove-context (list :type "file"

eca-util.el

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
:type 'boolean
2121
:group 'eca)
2222

23+
(defcustom eca-find-root-for-buffer-function #'eca-find-root-for-buffer
24+
"Function for getting the ECA's session root."
25+
:type 'function
26+
:group 'eca)
27+
2328
(defun eca-assoc (map key val)
2429
"Return a new MAP with KEY associated to flat plist VAL, replacing any existing."
2530
(cons (cons key val)
@@ -107,7 +112,7 @@
107112
(defun eca-session ()
108113
"Return the session related to root of current buffer otherwise nil."
109114
(or (eca-get eca--sessions eca--session-id-cache)
110-
(let* ((root (eca-find-root-for-buffer))
115+
(let* ((root (funcall eca-find-root-for-buffer-function))
111116
(session (-first (lambda (session)
112117
(--first (string= it root)
113118
(eca--session-workspace-folders session)))

eca.el

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@
147147

148148
(defun eca--discover-workspaces ()
149149
"Ask user for workspaces."
150-
(let ((root (eca-find-root-for-buffer))
150+
(let ((root (funcall eca-find-root-for-buffer-function))
151151
(add-workspace? "yes")
152152
(workspaces '()))
153153
(while (string= "yes" add-workspace?)
@@ -185,7 +185,7 @@ When ARG is current prefix, ask for workspace roots to use."
185185
(interactive "P")
186186
(let* ((workspaces (if (equal arg '(4))
187187
(eca--discover-workspaces)
188-
(list (eca-find-root-for-buffer))))
188+
(list (funcall eca-find-root-for-buffer-function))))
189189
(session (or (eca-session)
190190
(eca-create-session workspaces))))
191191
(pcase (eca--session-status session)

0 commit comments

Comments
 (0)