mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-06-29 22:16:13 +02:00
Allow custom extensions when editing (for easier syntax highlighting) (#1139)
* Create tests and steps for temporary filename suffix * Have temporary filename suffix be -{template_filename} or .jrnl * Finalize extension_editor_file * Make suffix local variable in get_text_from_editor
This commit is contained in:
parent
c47c1e209e
commit
e9fd5cdc0e
5 changed files with 42 additions and 1 deletions
|
@ -5,6 +5,7 @@ import subprocess
|
|||
import sys
|
||||
import tempfile
|
||||
import textwrap
|
||||
from pathlib import Path
|
||||
|
||||
from .color import ERROR_COLOR
|
||||
from .color import RESET_COLOR
|
||||
|
@ -12,7 +13,11 @@ from .os_compat import on_windows
|
|||
|
||||
|
||||
def get_text_from_editor(config, template=""):
|
||||
filehandle, tmpfile = tempfile.mkstemp(prefix="jrnl", text=True, suffix=".txt")
|
||||
suffix = ".jrnl"
|
||||
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)
|
||||
|
||||
with open(tmpfile, "w", encoding="utf-8") as f:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue