Skip to content

Commit

Permalink
[Fix #1187] Allow ess-startup-directory to be a symbol
Browse files Browse the repository at this point in the history
  .. and make it to take precedence over ess-startup-directory-function.

  Document the usage.
  • Loading branch information
vspinu committed Feb 13, 2022
1 parent 55d968f commit 347d3b4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
22 changes: 11 additions & 11 deletions lisp/ess-custom.el
Original file line number Diff line number Diff line change
Expand Up @@ -314,22 +314,22 @@ buffer.")
(defvaralias 'ess-directory-function 'ess-startup-directory-function)
(defcustom ess-startup-directory-function nil
"Function to return the directory that ESS is run from.
If nil or if the function returns nil then you get `ess-startup-directory'."
:group 'ess
:type '(choice (const nil) function))

(defcustom ess-setup-directory-function nil
"Function to setup the directory that ESS is run from.
This function can be called to set environment variables or to create
a workspace."
Value of `ess-startup-directory' has precedence over this function."
:group 'ess
:type '(choice (const nil) function))

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

Expand Down
11 changes: 7 additions & 4 deletions lisp/ess-inf.el
Original file line number Diff line number Diff line change
Expand Up @@ -622,11 +622,14 @@ process-less buffer because it was created with
;;*;; Requester functions called at startup
(defun inferior-ess--get-startup-directory ()
"Return a startup directory."
(let ((dir (or (and ess-directory-function
(funcall ess-directory-function))
(let ((dir (or (when (boundp 'ess-startup-directory)
(if (symbolp ess-startup-directory)
(symbol-value ess-startup-directory)
ess-startup-directory))
(and ess-startup-directory-function
(funcall ess-startup-directory-function))
(when-let ((proj (project-current)))
(ess--project-root proj))
ess-startup-directory
default-directory)))
(directory-file-name dir)))

Expand Down Expand Up @@ -2429,7 +2432,7 @@ START-ARGS gets passed to the dialect-specific
;; Make sure we don't ask for directory again
;; Use current working directory as default
(let ((project-find-functions nil)
(ess-directory-function nil)
(ess-startup-directory-function nil)
(ess-startup-directory (ess-get-process-variable 'default-directory))
(ess-ask-for-ess-directory nil))
(ess-quit 'no-save)
Expand Down
6 changes: 4 additions & 2 deletions lisp/ess-r-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,10 @@ will be prompted to enter arguments interactively."
"\n(R): ess-dialect=%s, buf=%s, start-arg=%s\n current-prefix-arg=%s\n"
ess-dialect (current-buffer) start-args current-prefix-arg))
(unless (or (file-remote-p default-directory)
(and ess-startup-directory
(file-remote-p ess-startup-directory))
(when ess-startup-directory
(file-remote-p (if (symbolp ess-startup-directory)
(symbol-value ess-startup-directory)
ess-startup-directory)))
;; TODO: Once we drop Emacs 26 support, can probably
;; just use the REMOTE argument of `executable-find'.
(executable-find inferior-ess-r-program))
Expand Down
3 changes: 1 addition & 2 deletions lisp/ess-sp6-d.el
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@
(inferior-ess-help-command . "help(\"%s\", pager=\"slynx -dump\", window=FALSE)\n")
(inferior-ess-search-list-command . "searchPaths()\n")

(ess-directory-function . S+-directory-function)
(ess-setup-directory-function . S+-setup-directory-function)
(ess-startup-directory-function . S+-directory-function)
(ess-STERM . "iESS"))
S+common-cust-alist)

Expand Down

0 comments on commit 347d3b4

Please sign in to comment.