changeset 602:29d5e6e64da8

Port ew/ec/et commands to Windows batch file.
author Oleksandr Gavenko <gavenkoa@gmail.com>
date Wed, 16 Dec 2015 00:04:39 +0200
parents ea6a5dc5893b
children 83f25a2581e3
files emacs/Makefile emacs/e.bat
diffstat 2 files changed, 69 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/emacs/Makefile	Tue Dec 15 23:14:14 2015 +0200
+++ b/emacs/Makefile	Wed Dec 16 00:04:39 2015 +0200
@@ -11,6 +11,22 @@
 # Default target.
 .DEFAULT_GOAL = all
 
+################################################################
+# Arch definitions.
+
+host_os = unix
+ifneq '' '$(COMSPEC)'
+  host_os = windows
+endif
+
+install-win :=
+ifeq 'windows' '$(host_os)'
+  install-win := install-win
+endif
+
+################################################################
+# Path/file definitions.
+
 ifeq '' '$(prefix)'
   ifneq '' '$(HOME)'
     prefix = $(HOME)/usr
@@ -23,32 +39,24 @@
 mandir = $(prefix)/share/man
 man1dir = $(mandir)/man1
 
-host_os = unix
-ifneq '' '$(COMSPEC)'
-  host_os = windows
-endif
+MAN1_FILES := $(wildcard e*.1)
+BIN_FILES := e ew ec et
 
-ifeq 'windows' '$(host_os)'
-  SRC_FILES = e e.bat
-else
-  SRC_FILES = e
-endif
-
-MAN1_FILES = $(wildcard e*.1)
+################################################################
+# Build definitions.
 
 .PHONY: all
-all:
+all: help
 
 .PHONY: check
 check:
 
 .PHONY: install
-install:
-	[ -d $(bindir) ] || mkdir -p $(bindir)
-	[ -d $(man1dir) ] || mkdir -p $(man1dir)
-	for file in $(SRC_FILES); do \
-		install -m 755 $$file $(bindir); \
-	done
+install: install-unix $(install-win)
+
+.PHONY: install-unix
+install-unix: install-init
+	install -m 755 e $(bindir)
 	ln -s -f $(bindir)/e $(bindir)/ew
 	ln -s -f $(bindir)/e $(bindir)/ec
 	ln -s -f $(bindir)/e $(bindir)/et
@@ -56,16 +64,23 @@
 		install -m 644 $$file $(man1dir); \
 	done
 
+.PHONY: install-win
+install-win: install-init
+	\
+for f in $(BIN_FILES); do \
+  install -m 755 e.bat $(bindir)/$$f.bat; \
+done
+
+.PHONY: install-init
+install-init:
+	[ -d $(bindir) ] || mkdir -p $(bindir)
+	[ -d $(man1dir) ] || mkdir -p $(man1dir)
+
 .PHONY: uninstall
 uninstall:
-	for file in $(SRC_FILES); do \
-		rm -f $(bindir)/$$file; \
-	done
-	rm -f $(bindir)/ew
-	rm -f $(bindir)/ec
-	rm -f $(bindir)/et
-	for file in $(MAN1_FILES); do \
-		rm -f $(man1dir)/$$file; \
+	rm -f $(patsubst %,$(bindir)/%,$(BIN_FILES)) $(patsubst %,$(bindir)/%.bat,$(BIN_FILES))
+	for f in $(MAN1_FILES); do \
+		rm -f $(man1dir)/$$f; \
 	done
 
 .PHONY: distclean
--- a/emacs/e.bat	Tue Dec 15 23:14:14 2015 +0200
+++ b/emacs/e.bat	Wed Dec 16 00:04:39 2015 +0200
@@ -14,13 +14,37 @@
 if x%1 == x-help  goto usage
 if x%1 == x--help goto usage
 
-:loop
-emacsclientw -a runemacs -n %1
-shift
-if not x%1 == x goto loop
+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=-a runemacs -n
+goto invoke
+:cmd_ew
+set args=-a runemacs
+goto invoke
+:cmd_ec
+set args=-a runemacs -c
+goto invoke
+:cmd_et
+set args=-a runemacs -t
+goto invoke
+
+:invoke
+if x%1 == x (
+  emacsclientw %args% .
+) else (
+  emacsclientw %args% %*
+)
 goto :eof
 
 :usage
 @echo Shortcut for emacsclientw for busy people.
 @echo Usage:
 @echo   e [-h^|--help] file...
+goto :eof