Package: hotedit
hoteditA simple library for opening your user's favorite text editorThehotedit()API looks at a few places in the shell environment for
a useful text editor, invokes it with your text, and finally returns
the edited result to your program (or raises an exception if an error
occurred invoking the editor).InstallpipinstallhoteditInstallation for maintainersAfter checking out github source, work with it usingPoetry.Installpoetry:curl -sSL https://install.python-poetry.org | python3 -Activate your poetry shell in the git repo you checked out, and install dependencies:poetry shell
...

poetry install -E testRun tests:make testUse# Get a string from the Internet so we can edit it:importrequestsURL="https://pastebin.com/raw/Df9NAmYc"response=requests.get(URL)"""Call `hotedit()` to launch the text editor to edit what was in the pastebindocument.The first argument `initial` is the string to be shown in your editing buffer.This creates a temp file, later deleted.Other useful arguments:- validate_unchanged (default False): When True, raise `Unchanged` exception whenthe user did not make any edits.- delete_temp (default True): When False, doesn't delete the temp file (fortroubleshooting).- find_editor (default `hotedit.editor.determine_editor`): a zero-argumentcallable that returns the path to an editor executable (see below)"""fromhoteditimporthoteditedited=hotedit(response.text)# `edited` is the string returned from editing.print("Your edited text:")forlineinedited.splitlines():print(f">{line}")# At this point we might upload the new string back to pastebin.How it determines your editorHotedit looks at your shell environment to determine which editor you're using.It follows some very simple rules.Check the following in order for a useful editor:git config core.editorEDITORenvironment variableVISUALenvironment variableIf one of these is a string, that string is returned as the path to an editor.hotedit()itself will raise an exception if the path returned is not an
editor executable, but it does not keep trying other options if this happens.This means ifcore.editoris unset,$EDITORis set to a path that's missing,
and$VISUALis set to a valid path to an editor,hoteditwill use$EDITORand fail, without checking$VISUAL.Overriding editor search withfind_editorIf you don't like hotedit's search order, you can pass your ownfind_editorfunction. Commonly, you want to try a different location first, then try the
default options. Here's an implementation of that:importosimporthotedit,hotedit.editordefmy_find_editor():ifos.environ.get("MY_APP_TEXT_EDITOR"):returnos.environ["MY_APP_TEXT_EDITOR"]returnhotedit.editor.determine_editor()edited=hotedit.hotedit("[MY_APP config]...",find_editor=my_find_editor)...Suggestions for setting your editorMany editor valuesjust work, especially if they are commonly used in the
terminal. For example, you can just setEDITOR=nanoorEDITOR=vim.Editors that open in their own window, or make use of an already-open window,
almost always provide a command-line option for exactly the use cases
hotedit is used for. For example, try the following:(Open a new gvim window, or open a tab in an existing gvim window, respectively):EDITOR="gvim -f"  # or
EDITOR="gvim --remote-tab-wait"(Open a tab in VS Code):EDITOR="code -w"If your users are likely to be using git, the best experience for them is usually
to invoke an editor the same way git would invoke one to ask for a commit
message. While it's not up to thehoteditlibrary to tell you how to live your
life, here's how you would do that:# VS code, for example
git config core.editor "code -w"Maintainer section: releasingTo cut a release of this software, automated tests must pass. Check underActionsfor the latest commit.Create an RC branch and testWe use the Gitflow process. For a release, this means that you should have a v1.2.3-rc branch under your
develop branch. Like this:main  
  └── develop  
      └── v1.2.3-rcUpdatethis file.Confirm that the docs make sense for the current release.Check links!Update the Changelog section at the bottom.Perform whatever tests are necessary.Tag and cut the release with Github ActionsOnce you have tested in this branch, create a tag in the v1.2.3-rc branch:git tag -a -m v1.2.3 v1.2.3
git push --tagsNavigate tohttps://github.com/corydodt/hotedit/actionsand run the action labeled... release.You will be asked to choose a branch. Choose your rc branch, e.g.v1.2.3-rcIf you run this action without creating a tag on v1.2.3-rc first, the action will fail with an error and nothing will happen.If you have correctly tagged a commit and chosen the right branch, this will run and create a new release on theReleases page.Edit the release on that pageMerge upFinish up by merging your-rcbranch intomainand thendevelop.Changelog(About: Keep-a-Changelog text format)The format is based onKeep a Changelog, and this project adheres toSemantic
Versioning.versions0.9.1.post2Initial public release.Automated builds, automated tests.