Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The path module should have something like a mktemp command #1255

Closed
krader1961 opened this issue Feb 28, 2021 · 3 comments · Fixed by #1260
Closed

The path module should have something like a mktemp command #1255

krader1961 opened this issue Feb 28, 2021 · 3 comments · Fixed by #1260

Comments

@krader1961
Copy link
Contributor

I was looking at my external_edit_command function and noticed I had hardcoded a /tmp/... path to avoid the pain of using the external mktemp command. The pain is due to the SysV, BSD, and Gnu implementations having different behavior. Not to mention creating a temp file on Windows. A path:mktemp command would be very useful. We don't necessarily want, or need, to mimic the existing external command but obviously do want options to create a unique directory versus a regular file and some sort of pattern mechanism to control the naming of the final component of the path.

@krader1961
Copy link
Contributor Author

BTW, My function that I bind to Alt-e (e for Emacs or edit) and Alt-v (v for Vim) to make it easy to use my preferred editor to edit a command:

fn external_edit_command {
  print $edit:current-command > /tmp/elvish-edit-command-$pid.elv
  $E:EDITOR /tmp/elvish-edit-command-$pid.elv </dev/tty >/dev/tty 2>&1
  edit:current-command = (slurp < /tmp/elvish-edit-command-$pid.elv)
}

@uranusjr
Copy link

I sometimes wonder if it’d be useful to provide a way to write Elvish modules in Go (like how Python can load third-party modules implemented in C), so this kind of things can be experiemented on more easily. (Although path:mktemp would be a useful addition regardless of such an extension API.)

@krader1961
Copy link
Contributor Author

@uranusjr, The Go plugin package would allow Elvish to load third-party modules written in Go. But it doesn't support Windows and it wouldn't make experimenting any easier. It's trivial to checkout the current Elvish code, create a new branch, and write code to implement a new feature. Using a plugin mechanism would almost certainly make the process harder, not easier.

krader1961 added a commit to krader1961/elvish that referenced this issue Mar 10, 2021
krader1961 added a commit to krader1961/elvish that referenced this issue Mar 10, 2021
krader1961 added a commit to krader1961/elvish that referenced this issue Mar 13, 2021
This is a stepping stone to implementing a `path:temp-file` command
which will need a means of fetching the file name from the os.File object
returned by fileutil.TempFile().

Related elves#1255
krader1961 added a commit to krader1961/elvish that referenced this issue Mar 13, 2021
This builds on previous commits to provide a mechanism for creating a
temporary file open for I/O but whose file name is available so the file
can be removed.

Resolves elves#1255
krader1961 added a commit to krader1961/elvish that referenced this issue Apr 5, 2021
krader1961 added a commit to krader1961/elvish that referenced this issue Apr 5, 2021
This is a stepping stone to implementing a `path:temp-file` command
which will need a means of fetching the file name from the os.File object
returned by fileutil.TempFile().

Related elves#1255
krader1961 added a commit to krader1961/elvish that referenced this issue Apr 5, 2021
This builds on previous commits to provide a mechanism for creating a
temporary file open for I/O but whose file name is available so the file
can be removed.

Resolves elves#1255
krader1961 added a commit to krader1961/elvish that referenced this issue Apr 8, 2021
This implements `path:temp-dir` and `path:temp-file`.

Resolves elves#1255
krader1961 added a commit to krader1961/elvish that referenced this issue Apr 9, 2021
This implements `path:temp-dir` and `path:temp-file`.

Resolves elves#1255
krader1961 added a commit to krader1961/elvish that referenced this issue Apr 9, 2021
This implements `path:temp-dir` and `path:temp-file`.

Resolves elves#1255
xiaq pushed a commit that referenced this issue Apr 25, 2021
This implements `path:temp-dir` and `path:temp-file`.

Resolves #1255
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants