Mercurial > utils
changeset 581:84907c43794d
Get rid of code duplication.
author | Oleksandr Gavenko <gavenkoa@gmail.com> |
---|---|
date | Wed, 07 Jan 2015 23:58:18 +0200 |
parents | b72d9da93de6 |
children | db39585c4eaf |
files | emacs/Makefile emacs/e emacs/ew emacs/ew.bat |
diffstat | 4 files changed, 12 insertions(+), 59 deletions(-) [+] |
line wrap: on
line diff
--- a/emacs/Makefile Wed Jan 07 23:47:06 2015 +0200 +++ b/emacs/Makefile Wed Jan 07 23:58:18 2015 +0200 @@ -29,9 +29,9 @@ endif ifeq 'windows' '$(host_os)' - SRC_FILES = e ew e.bat ew.bat + SRC_FILES = e e.bat else - SRC_FILES = e ew + SRC_FILES = e endif MAN1_FILES = $(wildcard *.1) @@ -49,6 +49,7 @@ for file in $(SRC_FILES); do \ install -m 755 $$file $(bindir); \ done + ln -s $(bindir)/e $(bindir)/ew for file in $(MAN1_FILES); do \ install -m 644 $$file $(man1dir); \ done @@ -58,6 +59,7 @@ for file in $(SRC_FILES); do \ rm -f $(bindir)/$$file; \ done + rm -f $(bindir)/ew for file in $(MAN1_FILES); do \ rm -f $(man1dir)/$$file; \ done
--- a/emacs/e Wed Jan 07 23:47:06 2015 +0200 +++ b/emacs/e Wed Jan 07 23:58:18 2015 +0200 @@ -17,14 +17,19 @@ ;; esac +case ${0##*/} in + ew) ERAGS="-a emacs" ;; + *) ERAGS="-a emacs -n" ;; +esac + if [ -n "$COMSPEC" ]; then # We probably under Windows like OS. I like native Emacs over Cygwin. - exec emacsclientw -a emacs -n -- "$@" + exec emacsclientw $ERAGS -- "$@" fi f=`readlink -f "$1"` if [ -e "$f" -a `stat -c %U "$f"` != $USER ] || [ -e "${f%/*}" -a `stat -c %U "${f%/*}"` != $USER ]; then shift - exec emacsclient -a emacs -n -- "/sudo::$f" "$@" + exec emacsclient $ERAGS -- "/sudo::$f" "$@" fi -exec emacsclient -a emacs -n -- "$@" +exec emacsclient $ERAGS -- "$@"
--- a/emacs/ew Wed Jan 07 23:47:06 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -#!/bin/sh -# Written by Oleksandr Gavenko <gavenkoa@gmail.com>, 2008. - -usage() { - echo "Shortcut for emacsclient. See ew(1) man page." - echo "Usage:" - echo " ew file..." - -} - -case "$1" in - -h|-help|--help) - usage - exit 0 - ;; - "") - printf "What file do you want to open?\n\n" - usage - exit 1 - ;; -esac - -if [ -n "$COMSPEC" ]; then - # We probably under Windows like OS. - exec emacsclientw -a emacs -- "$@" -else - exec emacsclient -a emacs -- "$@" -fi
--- a/emacs/ew.bat Wed Jan 07 23:47:06 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ -@echo off - -REM Written by Oleksandr Gavenko <gavenkoa@gmail.com>, 2009. -REM File placed by author in public domain. - -REM Wait for end of editing file in emacs buffer using emacsclientw. -REM If emacs not already running, run it. -REM Put this file in your PATH. -REM Name `ew' because `edit and wait for C-x #'. - -REM If path to file contain spaces it must be inclosed into quotes. - -REM Enclose %1 into quotes is danger because if %1 equal to "a b" result -REM expression ""a b"" has two words, not one enclosed into quotes! - -if x%1 == x-h goto usage -if x%1 == x-help goto usage -if x%1 == x--help goto usage - -emacsclientw -a runemacs %1 -goto :eof - -:usage -@echo Alias for emacsclient with waiting for editing ending. -@echo Usage: -@echo e [-h^|--help] ^<edit-files^>