Mercurial > utils
annotate emacs/e.bat @ 623:285855784c5a
Make possible to start Cygwin Emacsw32 if it is not yet started.
author  Oleksandr Gavenko <gavenkoa@gmail.com> 

date  Mon, 23 Jan 2017 02:30:10 +0200 
parents  ccd62d24ac73 
children  d7536d442db1 
rev  line source 

2
06536c9e15d4
Added file from bin/path.
Oleksandr Gavenko <gavenko@bifit.com.ua>
parents:
diff
changeset

1 @echo off 
211  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  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  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 `Cx #'. `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 
622
ccd62d24ac73
Simplify search for executable in PATH.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
621
diff
changeset

13 for %%X in (emacsclientw32.exe) do (set FOUND=%%~$PATH:X) 
ccd62d24ac73
Simplify search for executable in PATH.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
621
diff
changeset

14 if defined FOUND ( 
ccd62d24ac73
Simplify search for executable in PATH.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
621
diff
changeset

15 rem Cygwin Emacsw32. 
623
285855784c5a
Make possible to start Cygwin Emacsw32 if it is not yet started.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
622
diff
changeset

16 set RUNEMACSARG=a emacsw32 
285855784c5a
Make possible to start Cygwin Emacsw32 if it is not yet started.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
622
diff
changeset

17 set EMACSCLIENT=run emacsclientw32 
622
ccd62d24ac73
Simplify search for executable in PATH.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
621
diff
changeset

18 ) else ( 
621
631acaba551f
Switched to use Cygwin Emacsw32 instead of native.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
603
diff
changeset

19 rem Native Emacs. 
631acaba551f
Switched to use Cygwin Emacsw32 instead of native.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
603
diff
changeset

20 set RUNEMACSARG=a runemacs 
631acaba551f
Switched to use Cygwin Emacsw32 instead of native.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
603
diff
changeset

21 set EMACSCLIENT=emacsclientw 
631acaba551f
Switched to use Cygwin Emacsw32 instead of native.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
603
diff
changeset

22 ) 
631acaba551f
Switched to use Cygwin Emacsw32 instead of native.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
603
diff
changeset

23 
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

24 if x%1 == xh 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

25 if x%1 == xhelp 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

26 if x%1 == xhelp 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 
602
29d5e6e64da8
Port ew/ec/et commands to Windows batch file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
388
diff
changeset

28 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

29 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

30 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

31 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

32 
29d5e6e64da8
Port ew/ec/et commands to Windows batch file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
388
diff
changeset

33 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

34 exit 1 
29d5e6e64da8
Port ew/ec/et commands to Windows batch file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
388
diff
changeset

35 
29d5e6e64da8
Port ew/ec/et commands to Windows batch file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
388
diff
changeset

36 :cmd_e 
621
631acaba551f
Switched to use Cygwin Emacsw32 instead of native.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
603
diff
changeset

37 set args=n 
602
29d5e6e64da8
Port ew/ec/et commands to Windows batch file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
388
diff
changeset

38 goto invoke 
29d5e6e64da8
Port ew/ec/et commands to Windows batch file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
388
diff
changeset

39 :cmd_ew 
621
631acaba551f
Switched to use Cygwin Emacsw32 instead of native.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
603
diff
changeset

40 set args= 
602
29d5e6e64da8
Port ew/ec/et commands to Windows batch file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
388
diff
changeset

41 goto invoke 
29d5e6e64da8
Port ew/ec/et commands to Windows batch file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
388
diff
changeset

42 :cmd_ec 
621
631acaba551f
Switched to use Cygwin Emacsw32 instead of native.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
603
diff
changeset

43 set args=c 
602
29d5e6e64da8
Port ew/ec/et commands to Windows batch file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
388
diff
changeset

44 goto invoke 
29d5e6e64da8
Port ew/ec/et commands to Windows batch file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
388
diff
changeset

45 :cmd_et 
621
631acaba551f
Switched to use Cygwin Emacsw32 instead of native.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
603
diff
changeset

46 set args=t 
602
29d5e6e64da8
Port ew/ec/et commands to Windows batch file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
388
diff
changeset

47 goto invoke 
29d5e6e64da8
Port ew/ec/et commands to Windows batch file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
388
diff
changeset

48 
29d5e6e64da8
Port ew/ec/et commands to Windows batch file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
388
diff
changeset

49 :invoke 
29d5e6e64da8
Port ew/ec/et commands to Windows batch file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
388
diff
changeset

50 if x%1 == x ( 
621
631acaba551f
Switched to use Cygwin Emacsw32 instead of native.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
603
diff
changeset

51 %EMACSCLIENT% %RUNEMACSARG% %args% . 
602
29d5e6e64da8
Port ew/ec/et commands to Windows batch file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
388
diff
changeset

52 ) else ( 
621
631acaba551f
Switched to use Cygwin Emacsw32 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 ) 
246
f9b1f51b8ac4
Use builtin :eol label to exit.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
245
diff
changeset

55 goto :eof 
2
06536c9e15d4
Added file from bin/path.
Oleksandr Gavenko <gavenko@bifit.com.ua>
parents:
diff
changeset

56 
06536c9e15d4
Added file from bin/path.
Oleksandr Gavenko <gavenko@bifit.com.ua>
parents:
diff
changeset

57 :usage 
621
631acaba551f
Switched to use Cygwin Emacsw32 instead of native.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
603
diff
changeset

58 @echo Shortcut for %EMACSCLIENT% for busy people. 
247
98e3b92920c7
Make better description in help.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
246
diff
changeset

59 @echo Usage: 
388  60 @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

61 goto :eof 