view emacs/e.bat @ 628:d7536d442db1

Prevent exposing variables.
author Oleksandr Gavenko <gavenkoa@gmail.com>
date Tue, 14 Feb 2017 22:42:52 +0200
parents 285855784c5a
children 815567721a82
line wrap: on
line source

@echo off

REM Written by Oleksandr Gavenko <gavenkoa@gmail.com>, 2008, 2015.
REM File placed by author in public domain.

REM View files in emacs buffer using emacsclientw.
REM If emacs not already running, run it.
REM Put this file (e.bat) in your PATH.
REM Name `e' because `edit'. `ew' wait to `C-x #'. `ec' create new frame.

REM If path to file contain spaces it must be inclosed into quotes.

setlocal

for %%X in (emacsclient-w32.exe) do (set FOUND=%%~$PATH:X)
if defined FOUND (
  rem Cygwin Emacs-w32.
  set RUNEMACSARG=-a emacs-w32
  set EMACSCLIENT=run emacsclient-w32
) else (
  rem Native Emacs.
  set RUNEMACSARG=-a runemacs
  set EMACSCLIENT=emacsclientw
)

if x%1 == x-h     goto usage
if x%1 == x-help  goto usage
if x%1 == x--help goto usage

if %~n0 == e goto cmd_e
if %~n0 == ew goto cmd_ew
if %~n0 == ec goto cmd_ec
if %~n0 == et goto cmd_et

echo Unknown command flavor: %~n0, use one of e/ew/ec/et.
exit 1

:cmd_e
set args=-n
goto invoke
:cmd_ew
set args=
goto invoke
:cmd_ec
set args=-c
goto invoke
:cmd_et
set args=-t
goto invoke

:invoke
if x%1 == x (
  %EMACSCLIENT% %RUNEMACSARG% %args% .
) else (
  %EMACSCLIENT% %RUNEMACSARG% %args% %*
)
goto :eof

:usage
@echo Shortcut for %EMACSCLIENT% for busy people.
@echo Usage:
@echo   e [-h^|--help] file...
goto :eof