mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-20 04:58:32 +02:00
Have temporary filename suffix be -{template_filename} or .jrnl
This commit is contained in:
parent
4bbd2fe53b
commit
7405221a8a
1 changed files with 6 additions and 2 deletions
|
@ -5,14 +5,18 @@ import subprocess
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
import textwrap
|
import textwrap
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from .color import ERROR_COLOR
|
from .color import ERROR_COLOR
|
||||||
from .color import RESET_COLOR
|
from .color import RESET_COLOR
|
||||||
from .os_compat import on_windows
|
from .os_compat import on_windows
|
||||||
|
|
||||||
|
|
||||||
def get_text_from_editor(config, template=""):
|
def get_text_from_editor(config, template="", suffix=".jrnl"):
|
||||||
filehandle, tmpfile = tempfile.mkstemp(prefix="jrnl", text=True, suffix=".txt")
|
if config["template"]:
|
||||||
|
template_filename = Path(config["template"]).name
|
||||||
|
suffix = "-" + template_filename
|
||||||
|
filehandle, tmpfile = tempfile.mkstemp(prefix="jrnl", text=True, suffix=suffix)
|
||||||
os.close(filehandle)
|
os.close(filehandle)
|
||||||
|
|
||||||
with open(tmpfile, "w", encoding="utf-8") as f:
|
with open(tmpfile, "w", encoding="utf-8") as f:
|
||||||
|
|
Loading…
Add table
Reference in a new issue