Skip to content

Commit f3c196d

Browse files
committed
[Fix #1187] Allow ess-startup-directory to be a symbol
.. and make it to take precedence over ess-startup-directory-function. Document the usage.
1 parent 55d968f commit f3c196d

File tree

4 files changed

+24
-20
lines changed

4 files changed

+24
-20
lines changed

lisp/ess-custom.el

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -314,24 +314,24 @@ buffer.")
314314
(defvaralias 'ess-directory-function 'ess-startup-directory-function)
315315
(defcustom ess-startup-directory-function nil
316316
"Function to return the directory that ESS is run from.
317-
If nil or if the function returns nil then you get `ess-startup-directory'."
318-
:group 'ess
319-
:type '(choice (const nil) function))
320-
321-
(defcustom ess-setup-directory-function nil
322-
"Function to setup the directory that ESS is run from.
323-
This function can be called to set environment variables or to create
324-
a workspace."
317+
Value of `ess-startup-directory' has precedence over this function."
325318
:group 'ess
326319
:type '(choice (const nil) function))
327320

328321
(defvaralias 'ess-directory 'ess-startup-directory)
329322
(defcustom ess-startup-directory nil
330-
"The directory ESS is run from. It must end in a slash.
331-
Provided as a default if `ess-ask-for-ess-directory' is non-nil.
332-
A nil value means use the current buffer's default directory."
323+
"The directory ESS is run from (string or a symbol).
324+
Provided a default (especially useful if
325+
`ess-ask-for-ess-directory' is non-nil). A nil value means use
326+
the value returned by `ess-startup-directory-function'. If nil,
327+
use current project directory, otherwise use to the
328+
`default-directory'.
329+
330+
When this variable is a symbol, use its value. Set this variable
331+
to `'default-directory' in order to always start in the current
332+
directory."
333333
:group 'ess
334-
:type '(choice (const nil) directory))
334+
:type '(choice (const nil) directory symbol))
335335

336336

337337
(defcustom ess-history-directory nil

lisp/ess-inf.el

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -622,11 +622,14 @@ process-less buffer because it was created with
622622
;;*;; Requester functions called at startup
623623
(defun inferior-ess--get-startup-directory ()
624624
"Return a startup directory."
625-
(let ((dir (or (and ess-directory-function
626-
(funcall ess-directory-function))
625+
(let ((dir (or (when (boundp 'ess-startup-directory)
626+
(if (symbolp ess-startup-directory)
627+
(symbol-value ess-startup-directory)
628+
ess-startup-directory))
629+
(and ess-startup-directory-function
630+
(funcall ess-startup-directory-function))
627631
(when-let ((proj (project-current)))
628632
(ess--project-root proj))
629-
ess-startup-directory
630633
default-directory)))
631634
(directory-file-name dir)))
632635

@@ -2429,7 +2432,7 @@ START-ARGS gets passed to the dialect-specific
24292432
;; Make sure we don't ask for directory again
24302433
;; Use current working directory as default
24312434
(let ((project-find-functions nil)
2432-
(ess-directory-function nil)
2435+
(ess-startup-directory-function nil)
24332436
(ess-startup-directory (ess-get-process-variable 'default-directory))
24342437
(ess-ask-for-ess-directory nil))
24352438
(ess-quit 'no-save)

lisp/ess-r-mode.el

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,8 +558,10 @@ will be prompted to enter arguments interactively."
558558
"\n(R): ess-dialect=%s, buf=%s, start-arg=%s\n current-prefix-arg=%s\n"
559559
ess-dialect (current-buffer) start-args current-prefix-arg))
560560
(unless (or (file-remote-p default-directory)
561-
(and ess-startup-directory
562-
(file-remote-p ess-startup-directory))
561+
(when ess-startup-directory
562+
(file-remote-p (if (symbolp ess-startup-directory)
563+
(symbol-value ess-startup-directory)
564+
ess-startup-directory)))
563565
;; TODO: Once we drop Emacs 26 support, can probably
564566
;; just use the REMOTE argument of `executable-find'.
565567
(executable-find inferior-ess-r-program))

lisp/ess-sp6-d.el

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@
7676
(inferior-ess-help-command . "help(\"%s\", pager=\"slynx -dump\", window=FALSE)\n")
7777
(inferior-ess-search-list-command . "searchPaths()\n")
7878

79-
(ess-directory-function . S+-directory-function)
80-
(ess-setup-directory-function . S+-setup-directory-function)
79+
(ess-startup-directory-function . S+-directory-function)
8180
(ess-STERM . "iESS"))
8281
S+common-cust-alist)
8382

0 commit comments

Comments
 (0)