Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
390 views
in Technique[技术] by (71.8m points)

bash - Emacs on Windows opens emtpy buffer when started from script

Background

I'm rewriting my newNote script and I'm using the runemacs.exe Windows instead of calling the binary directly like I've done in the past. Previously I'd have the launching terminal hanging out in the background and I realized that runemacs.exe avoids that annoyance.

Issue:

The script works from a raw file point of view but when emacs launches I get an empty buffer where I expect to see a title and some TODO tags defined. If I open the .org file directly I see the contents match what I'm expecting. Any help would be appreciated!

#!/bin/bash
BASE_NOTES_DIR="${USER_DESKTOP}/Notes"
CURRENT_DATE=`date "+%Y_%m_%d_%s"`
TODO_OPTIONS='TODO InProgress(i) Rejected(R) | BackBurner(B) DONE(D) Cancelled(c)'

function spaceToUnderscore()
{
    RESULT="`echo "$@" | sed 's/ /_/g'`"
}


function getPromptResponseEscaped()
{
    read -p "$@" answer
    spaceToUnderscore $answer
}

getPromptResponseEscaped "Which Project is this for?: "
Project=$RESULT

read -p "What title for this new note?: " user_title
spaceToUnderscore $user_title
Title=$RESULT

Folder="${BASE_NOTES_DIR}/${Project}/${Title}"

if [ ! -d $Folder ]
then
    mkdir -p $Folder
fi

fileName="${CURRENT_DATE}_${Title}.org"
filePath="${Folder}/${fileName}"
touch $filePath && 
echo "#+TITLE: ${user_title}" >> $filePath && 
echo "#+TODO: ${TODO_OPTIONS}" >> $filePath && 
sync && 
"C:Program FilesEmacsx86_64in
unemacs.exe" "$fileName"

Notes:

Executing

USER_DESKTOP needs to be defined either as an env variable or as a new line before running this code.

Bash version

GNU bash, version 4.4.23(1)-release (x86_64-pc-msys)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...