Skip to content

Commit f5196f2

Browse files
committed
Even smarter package detection
Check if `ess-developer-local-package` is set in the attached process buffer, in which case use it. This way we can use devtools with last used package in files that are not connected to a package.
1 parent 638ad3f commit f5196f2

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

lisp/ess-developer.el

+11-6
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,8 @@ not found, return nil."
302302
(cdr ess-developer-local-package))
303303
(pack-name
304304
(ess-developer--find-package-path pack-name))
305-
(t
306-
(ess-developer--check-current-dir-package-path)))))
305+
((ess-developer--check-current-dir-package-path))
306+
((ess-developer--get-process-package-path)))))
307307

308308
(defun ess-developer--find-package-path (pack-name)
309309
(let ((bl (buffer-list))
@@ -407,11 +407,17 @@ If ALL is non-nil, deactivate in all open R buffers."
407407
(equal pack package)))
408408
(ess-developer -1)))))
409409

410+
(defun ess-developer--get-process-package-path ()
411+
(with-ess-process-buffer t
412+
(when (boundp 'ess-developer-local-package)
413+
(cdr ess-developer-local-package))))
414+
410415
(defun ess-developer-send-process (command &optional msg)
411416
(ess-force-buffer-current)
412417
(let* ((path (or (cdr ess-developer-local-package)
413418
(ess-developer--get-package-path)))
414-
(name (file-name-nondirectory (directory-file-name path))))
419+
(name (when path
420+
(file-name-nondirectory (directory-file-name path)))))
415421
;; Ask package directory only when not obvious
416422
(unless (or ess-developer-local-package path)
417423
(setq path (read-directory-name "Package: " path nil t nil)))
@@ -425,9 +431,8 @@ If ALL is non-nil, deactivate in all open R buffers."
425431
(ess-eval-linewise (format command path))))
426432

427433
(defun ess-developer--init-process-local-vars (name path)
428-
(let ((pbuffer (process-buffer (ess-get-process ess-current-process-name))))
429-
(with-current-buffer pbuffer
430-
(setq-local ess-developer-local-package (cons name path)))))
434+
(with-ess-process-buffer nil
435+
(setq-local ess-developer-local-package (cons name path))))
431436

432437
(defun ess-developer-load-package ()
433438
"Interface to load_all() function from devtools package.

0 commit comments

Comments
 (0)