annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
06536c9e15d4 Added file from bin/path.
Oleksandr Gavenko <gavenko@bifit.com.ua>
parents:
diff changeset
1 @echo off
211
ea15eb62b804 Update copyright.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 209
diff changeset
2
603
83f25a2581e3 Update usage and date.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 602
diff changeset
3 REM Written by Oleksandr Gavenko <gavenkoa@gmail.com>, 2008, 2015.
211
ea15eb62b804 Update copyright.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 209
diff changeset
4 REM File placed by author in public domain.
2
06536c9e15d4 Added file from bin/path.
Oleksandr Gavenko <gavenko@bifit.com.ua>
parents:
diff changeset
5
387
83d9a15e3614 Fix doc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 386
diff changeset
6 REM View files in emacs buffer using emacsclientw.
7
2f3ca206301b If emacs not already running, run it.
Oleksander Gavenko <gavenko_a@3g.ua>
parents: 6
diff changeset
7 REM If emacs not already running, run it.
5
7c6b58c4f138 Added r.bat. Added copyright notice.
Oleksander Gavenko <gavenko_a@3g.ua>
parents: 3
diff changeset
8 REM Put this file (e.bat) in your PATH.
603
83f25a2581e3 Update usage and date.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 602
diff changeset
9 REM Name `e' because `edit'. `ew' wait to `C-x #'. `ec' create new frame.
5
7c6b58c4f138 Added r.bat. Added copyright notice.
Oleksander Gavenko <gavenko_a@3g.ua>
parents: 3
diff changeset
10
245
8d4828549738 Enclose %1 into quotes is danger because if %1 equal to "a b" result expression ""a b"" has two words, not one enclosed into quotes!
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 211
diff changeset
11 REM If path to file contain spaces it must be inclosed into quotes.
8d4828549738 Enclose %1 into quotes is danger because if %1 equal to "a b" result expression ""a b"" has two words, not one enclosed into quotes!
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 211
diff changeset
12
628
d7536d442db1 Prevent exposing variables.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 623
diff changeset
13 setlocal
d7536d442db1 Prevent exposing variables.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 623
diff changeset
14
622
ccd62d24ac73 Simplify search for executable in PATH.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 621
diff changeset
15 for %%X in (emacsclient-w32.exe) do (set FOUND=%%~$PATH:X)
ccd62d24ac73 Simplify search for executable in PATH.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 621
diff changeset
16 if defined FOUND (
ccd62d24ac73 Simplify search for executable in PATH.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 621
diff changeset
17 rem Cygwin Emacs-w32.
623
285855784c5a Make possible to start Cygwin Emacs-w32 if it is not yet started.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 622
diff changeset
18 set RUNEMACSARG=-a emacs-w32
285855784c5a Make possible to start Cygwin Emacs-w32 if it is not yet started.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 622
diff changeset
19 set EMACSCLIENT=run emacsclient-w32
622
ccd62d24ac73 Simplify search for executable in PATH.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 621
diff changeset
20 ) else (
621
631acaba551f Switched to use Cygwin Emacs-w32 instead of native.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 603
diff changeset
21 rem Native Emacs.
631acaba551f Switched to use Cygwin Emacs-w32 instead of native.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 603
diff changeset
22 set RUNEMACSARG=-a runemacs
631acaba551f Switched to use Cygwin Emacs-w32 instead of native.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 603
diff changeset
23 set EMACSCLIENT=emacsclientw
631acaba551f Switched to use Cygwin Emacs-w32 instead of native.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 603
diff changeset
24 )
631acaba551f Switched to use Cygwin Emacs-w32 instead of native.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 603
diff changeset
25
245
8d4828549738 Enclose %1 into quotes is danger because if %1 equal to "a b" result expression ""a b"" has two words, not one enclosed into quotes!
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 211
diff changeset
26 if x%1 == x-h goto usage
8d4828549738 Enclose %1 into quotes is danger because if %1 equal to "a b" result expression ""a b"" has two words, not one enclosed into quotes!
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 211
diff changeset
27 if x%1 == x-help goto usage
8d4828549738 Enclose %1 into quotes is danger because if %1 equal to "a b" result expression ""a b"" has two words, not one enclosed into quotes!
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 211
diff changeset
28 if x%1 == x--help goto usage
8d4828549738 Enclose %1 into quotes is danger because if %1 equal to "a b" result expression ""a b"" has two words, not one enclosed into quotes!
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 211
diff changeset
29
602
29d5e6e64da8 Port ew/ec/et commands to Windows batch file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 388
diff changeset
30 if %~n0 == e goto cmd_e
29d5e6e64da8 Port ew/ec/et commands to Windows batch file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 388
diff changeset
31 if %~n0 == ew goto cmd_ew
29d5e6e64da8 Port ew/ec/et commands to Windows batch file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 388
diff changeset
32 if %~n0 == ec goto cmd_ec
29d5e6e64da8 Port ew/ec/et commands to Windows batch file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 388
diff changeset
33 if %~n0 == et goto cmd_et
29d5e6e64da8 Port ew/ec/et commands to Windows batch file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 388
diff changeset
34
29d5e6e64da8 Port ew/ec/et commands to Windows batch file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 388
diff changeset
35 echo Unknown command flavor: %~n0, use one of e/ew/ec/et.
29d5e6e64da8 Port ew/ec/et commands to Windows batch file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 388
diff changeset
36 exit 1
29d5e6e64da8 Port ew/ec/et commands to Windows batch file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 388
diff changeset
37
29d5e6e64da8 Port ew/ec/et commands to Windows batch file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 388
diff changeset
38 :cmd_e
621
631acaba551f Switched to use Cygwin Emacs-w32 instead of native.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 603
diff changeset
39 set args=-n
602
29d5e6e64da8 Port ew/ec/et commands to Windows batch file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 388
diff changeset
40 goto invoke
29d5e6e64da8 Port ew/ec/et commands to Windows batch file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 388
diff changeset
41 :cmd_ew
621
631acaba551f Switched to use Cygwin Emacs-w32 instead of native.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 603
diff changeset
42 set args=
602
29d5e6e64da8 Port ew/ec/et commands to Windows batch file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 388
diff changeset
43 goto invoke
29d5e6e64da8 Port ew/ec/et commands to Windows batch file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 388
diff changeset
44 :cmd_ec
621
631acaba551f Switched to use Cygwin Emacs-w32 instead of native.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 603
diff changeset
45 set args=-c
602
29d5e6e64da8 Port ew/ec/et commands to Windows batch file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 388
diff changeset
46 goto invoke
29d5e6e64da8 Port ew/ec/et commands to Windows batch file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 388
diff changeset
47 :cmd_et
621
631acaba551f Switched to use Cygwin Emacs-w32 instead of native.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 603
diff changeset
48 set args=-t
602
29d5e6e64da8 Port ew/ec/et commands to Windows batch file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 388
diff changeset
49 goto invoke
29d5e6e64da8 Port ew/ec/et commands to Windows batch file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 388
diff changeset
50
29d5e6e64da8 Port ew/ec/et commands to Windows batch file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 388
diff changeset
51 :invoke
29d5e6e64da8 Port ew/ec/et commands to Windows batch file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 388
diff changeset
52 if x%1 == x (
621
631acaba551f Switched to use Cygwin Emacs-w32 instead of native.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 603
diff changeset
53 %EMACSCLIENT% %RUNEMACSARG% %args% .
602
29d5e6e64da8 Port ew/ec/et commands to Windows batch file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 388
diff changeset
54 ) else (
621
631acaba551f Switched to use Cygwin Emacs-w32 instead of native.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 603
diff changeset
55 %EMACSCLIENT% %RUNEMACSARG% %args% %*
602
29d5e6e64da8 Port ew/ec/et commands to Windows batch file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 388
diff changeset
56 )
246
f9b1f51b8ac4 Use built-in :eol label to exit.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 245
diff changeset
57 goto :eof
2
06536c9e15d4 Added file from bin/path.
Oleksandr Gavenko <gavenko@bifit.com.ua>
parents:
diff changeset
58
06536c9e15d4 Added file from bin/path.
Oleksandr Gavenko <gavenko@bifit.com.ua>
parents:
diff changeset
59 :usage
621
631acaba551f Switched to use Cygwin Emacs-w32 instead of native.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 603
diff changeset
60 @echo Shortcut for %EMACSCLIENT% for busy people.
247
98e3b92920c7 Make better description in help.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 246
diff changeset
61 @echo Usage:
388
12e37fe91d89 Fix usage docs.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 387
diff changeset
62 @echo e [-h^|--help] file...
602
29d5e6e64da8 Port ew/ec/et commands to Windows batch file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 388
diff changeset
63 goto :eof