Skip to content

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

Closed

Description

@krader1961

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.

Activity

  1. krader1961 commented on Feb 28, 2021

    @krader1961
    ContributorAuthor

    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)
    }
    
  2. uranusjr commented on Feb 28, 2021

    @uranusjr

    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.)

  3. krader1961 commented on Feb 28, 2021

    @krader1961
    ContributorAuthor

    @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.

  4. added a commit that references this issue on Apr 25, 2021
    bc37099
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions