local computer

Setup Windows 7 for a scientist
Hiroshi Kitagawa (February 3, 2015)
Last modified: c:/Users/dream/orochi-devel/documentation/OrochiSetupWin7/report.tex
on 2015-02-03 19:44
Abstract
This document summarizes a setup procedure of Windows 7 for a scientist.
Contents
1
INTRODUCTION
1
2
CYGWIN
1
3
OKAYAMA SPECIFIC
2
4
SCIENTIFIC TOOLS
3
5
GNU Emacs
5.1 Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.2 Customization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4
4
6
Appendix 1
Windows
7
Appendix 2
Macintosh
7
1
INTRODUCTION
Target of this document is a Japanese scientist who makes plots by R and matlab, and reads/writes reports
using LATEX in English/Japanese. The scientist has to deal files by Microsoft Word, Excel, and PowerPoint,
and run instruments that can only talk to Microsoft Windows. Although he prefers Unixy system, he has to
stick to Windows. A core environment for him is GNU Emacs. How to set up a working environment on
Windows 7 is described on this document.
There are two possible Emacs, that are official build for Windows that also is referred as NT-Emacs, and
one for Cygwin. Emacs relies on many external programs, and we consider Cygwin to be a primary source.
Installation of Emacs itself, external programs, and configuration, are described.
2
CYGWIN
Launch Windows’ command prompt (hereafter referred as cmd.exe) and set an environmental variable
HOME by following command.
1
DOS > setx HOME % USERPROFILE %
Make sure if HOME is set properly as below. To access environmental variables, right-click computer, then click
properties, advanced settings, and environment variables.
1
C:\ Users \ hkitagawa
Install Cygwin1 without additional packages for the first round. Then add packages listed on Table 2. If you
cannot tell which one to be installed, install all except for “Publishing”2 .
1
Install by “setup-x86.exe” or “setup-x64.exe” but into to c:/cygwin/ instead of c:/cygwin64/. If you launched Cygwin
Terminal without setting HOME properly, a directory c:/cygwin/home/hkitagawa would be created. To avoid confusion, delete
it.
2
Sometimes “Publishing” packages gives problems for unknown reasons as of January 31, 2015.
1
3
OKAYAMA SPECIFIC
Odnet An Orochi client is supposed to connect to Wi-Fi odnet provided by Okayama Univ. On a principle,
authorization is required for each connection. It is recommended to register MAC address. At its registration,
check option to have constant IP address.
A MAC address is world-wide-unique 6-byte ID for network device. It is often expressed in a form
as 7c:c3:a1:9f:91:5d. On Mac, find it at “About This Mac / Network / Wi-Fi”. On Windows, type
ipconfig/all in command prompt.
Visit https://iasap.cc.okayama-u.ac.jp/saibed/ as of October 29, 2014 and follow links and
select menu “change role / role-name: research-NW-Mac-registration” then click “OK”. Select menu “ODobject organize / registration”. Set VLAN info as “VLAN3617 – ISEI”, fill the MAC address, select “static
IP”, “object”, and “cue”. Then click “register”. Choose “VLAN3617 – ISEI” for server and “VLAN3618 –
ISEI” for clients.
Subversion and Git Orochi-related files are maintained on version controlled repositories. To check out
repositories under Subversion, issue following commands.
1
2
3
4
cygwin$
cygwin$
cygwin$
cygwin$
svn
svn
svn
svn
checkout
checkout
checkout
checkout
http :// multimed . misasa .okayama -u.ac.jp/ repository /bin
http :// multimed . misasa .okayama -u.ac.jp/ repository / templates
http :// multimed . misasa .okayama -u.ac.jp/ repository / texmf
http :// multimed . misasa .okayama -u.ac.jp/ repository / xtreeml
Since Windows cannot recognize symbolic link made on Cygwin, additionally check out Emacs configuration
files as below.
1
cygwin$ svn checkout http :// multimed . misasa .okayama -u.ac.jp/ repository /bin/dot. emacs .d . emacs .d
To check out repositories under Git, you need a SSH public key of your computer. Even %HOME% is set to
c:/Users/hkitagawa, ssh-keygen creates a key in Cygwin’s default home c:/cygwin/home/hkitagawa/.ssh
as of January 5, 2015. Issue following commands. No passphrase input is required on creation of the key.
1
2
3
4
5
6
cygwin$
cygwin$
cygwin$
cygwin$
cygwin$
cygwin$
cd
mkdir -p /home/ hkitagawa
ssh - keygen -t rsa
ln -s /home/ hkitagawa /. ssh .ssh
cat ˜/. ssh/ id_rsa .pub
cat ˜/. ssh/ id_rsa .pub > /dev/ clipboard
Log-in Git server by appropriate user such like hominidae. Add your public key on ˜/.ssh/id_rsa.pub to
Git server. Then issue following to check out.
1
2
3
cygwin$ cd
cygwin$ mkdir -p orochi - devel ; cd orochi - devel
cygwin$ git clone git@devel . misasa .okayama -u.ac.jp: orochi / documentation .git
Environmental variables and configuration files To set environmental variables up, run SETUP_ENV.BAT
on command prompt, as shown below
1
2
DOS > cd xtreeml
DOS > SETUP_ENV .BAT
or issue following commands.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
@echo off
set HOME =% USERPROFILE %
set EMACS_DIR ="C:\ emacs -24.3 "
setx PROMPT
"DOS > "
setx TZ
JST -9
setx USER
% USERNAME %
setx HOME
%HOME%
setx BIBINPUTS
%HOME %\ texmf \ bibtex \\
setx EMACS_DIR
% EMACS_DIR %
setx ALTERNATE_EDITOR % EMACS_DIR %\ bin\ runemacs
setx EMACSCLIENT
% EMACS_DIR %\ bin\ emacsclientw
setx XTREEML
%HOME %\ xtreeml
setx PATH_CYGWIN
C:\ cygwin \bin;C:\ cygwin \user\bin;C:\ cygwin \user\sbin;C:\ cygwin \usr\ local \bin
setx PATH
%% PATH_CYGWIN %%
2
To copy configuration files such as .bashrc, issue following command,
1
˜/ bin/dot.cp
or issue individual commands.
1
2
3
4
5
6
7
8
9
10
11
12
#!/ bin/sh
cp -f ˜/ bin/dot. bashrc
cp -f ˜/ bin/dot. bash_profile
cp -f ˜/ bin/dot. latexmkrc
cp -f ˜/ bin/dot. gitconfig
cp -f ˜/ bin/dot. vimrc
cp -f ˜/ bin/dot. screenrc
cp -i ˜/ bin/dot. emacs .d/dot.emacs -w3m
cp -i ˜/ bin/dot. emacs .d/dot.mew.el
cp -i ˜/ bin/dot. emacs .d/dot.gnus
cp -i ˜/ bin/dot. emacs .d/dot. authinfo
cp -i ˜/ xtreeml / orochi /dot. orochirc
˜/. bashrc
˜/. bash_profile
˜/. latexmkrc
˜/. gitconfig
˜/. vimrc
˜/. screenrc
˜/. emacs -w3m
˜/. mew.el
˜/. gnus.el
˜/. authinfo
˜/. orochirc
Dropbox Install and log-in with appropriate account. Orochi-related utilities are stored in ˜/Dropbox/
Documents/Emacs/.
4
SCIENTIFIC TOOLS
Programs should be launch-able from cmd.exe (to be called from Emacs). Append path to a program (such
as C:\Program Files\R\R-3.1.2\bin\x64) on each installation, to system’s environmental variable PATH
(hereafter referred as %PATH%)3 .
MiKTEX NT-Emacs prefers LATEX by MiKTEX than one by Cygwin. Choose x86 or 64 version. Set “install
missing packages on-the-fly” to “yes”. To handle Japanese by pdfLATEX, install cjk related files. Using
Package Manager (Admin), install a package bxcjkjatype.
To let MiKTEX recognize user-definition files located in C:\Users\hkitagawa\texmf, launch a configuration program by clicking Start, MiKTeX 2.9, Maintenance (Admin), and settings (admin). In roots tab, add
the directory. Occasionally update database by clicking Refresh FNDB 4 .
MiKTEX is not with Japanese pLATEX. If you need it, install it on Cygwin5 . It is a hard work to invoke
Japanese pLATEX from NT-Emacs. First of all, there is another platex.exe with MiKTEX, which is not
pLATEX. It is recommended to rename it to something else. Also, since C:/cygwin/usr/bin/platex is
a symbolic link to C:/cygwin/usr/bin/eptex.exe, NT-Emacs cannot invoke platex. You can barely
invoke pLATEX by calling a batch file with following lines.
1
2
@echo off
eptex -progname = platex %*
To utilize a Perl script latexmk comes with MiKTEX , have a configuration file ˜/.latexmkrc as shown
as below.
1
2
3
$pdflatex = ’pdflatex %O %S’;
$latex
= ’eptex -kanji =utf8 -progname = platex %O %S’;
$dvipdf
= ’dvipdfmx %O -o %D %S’;
PDF viewer Install SumatraPDF and set inverse search command-line in Settings/options, as below.
1
C:\ emacs -24.3\ bin\ emacsclientw .exe --no -wait +%l "%f"
To bind key Esc to close a window and use tab-browsing, select “Advanced Options...” from menu and set
EscToExit and ReuseInstance to true. Set SumatraPDF as default PDF application for Windows.
3
Also append paths C:/cygwin/bin, C:/cygwin/usr/bin,C:/cygwin/usr/local/bin.
You have to click this when you append a personal bib file.
5
As a consequence, you have two LATEX systems with or without Japanese pLATEX.
4
3
R
1
2
3
Install R for Windows. After installation launch R.exe and install popular packages as shown below.
R> install . packages ("klaR")
R> install . packages (" ggplot2 ")
R> install . packages (" ellipse ")
Matlab
mand.
1
Let Matlab recognize user-definition files at C:\Users\hkitagawa\matlab by following com-
matlab > userpath ( fullfile ( getenv (’HOME ’),’matlab ’))
Firefox
5
Install plugin KeySnail.xpi to have Emacs key-bind. To setup sync using certain account is useful.
GNU Emacs
5.1
Installation
Main program Emacs on Cygwin works on own file system. For example, a directory C:\Program Files
is regarded as /cygdrive/c/Program Files. It does not go well with Windows’ native programs. Number
of users is small and you will encounter inconvenience often. We have reached to conclusion that a combination of NT-Emacs (official build for Windows) and external programs mainly provided by Cygwin to be the
best6 .
Download official build for Windows and copy to c:/emacs-24.3. Only if you want to see images
in Emacs, download and locate image libraries. Read documentation carefully and locate *.dll files to
c:/emacs-24.3/bin7 .
Run c:/emacs-24.3/bin/addpm.exe to make a shortcut in start menu. From now on you launch Emacs
from start menu. For convenience, set working directory of the shortcut to %HOME%. An example of user’s
environment variables is shown in Table 1.
To open files by Emacs on double click at Windows’ Explorer, correlate *.tex with emacsclientw.exe
(instead of runemacs.exe). If you want to open a file by a new window, correlate with a batch file c:
/emacs-24.3/bin/emacsclientw.bat with following lines.
1
2
@echo off
"%˜ dp0emacsclientw .exe" --create - frame -no -wait --alternate - editor ="%˜ dp0runemacs .exe" %1
Table 1: An example of user’s environment variables
variable
TZ
USER
HOME
BIBINPUTS
EMACS_DIR
ALTERNATE_EDITOR
EMACSCLIENT
PATH
value
JST-9
hkitagawa
C:\Users\hkitagawa
C:\Users\hkitagawa\texmf\bibtex\\
C:\emacs-24.3
C:\emacs-24.3\bin\runemacs
C:\emacs-24.3\bin\emacsclientw
C:\Users\hkitagawa\bin;C:\cygwin\bin;C:\cygwin\user\bin;
C:\cygwin\user\sbin;C:\cygwin\usr\local\bin
External programs Install external programs as listed in Table 2. When Emacs is launched, commandsearch list exec-path is constructed from system’s %PATH%, user’s %PATH%, and certain directories such as
c:/emacs-24.3/bin or c:/emacs-24.4/libexec/emacs/24.4/i686-pc-mingw32/. Possible locations
for external programs are shown in Table 3.
6
After a while, you want to build Emacs by yourself. Then consider MinGW instead of Cygwin.
Since it is hustle to look around, Orochi keeps a copy with libraries in ˜/Dropbox/Documents/Emacs/emacs-24.3. Copy
the directory to c:/emacs-24.3.
7
4
Table 2: External programs required for Emacs: yourself means that you build
aspell
grep
find
git
subversion
stunnel
perl
w3m
cmigemo
nkf
LATEX
PDF viewer
R
ssh
search
ruby
Windows
Cygwin
ezwinports
Cygwin
Cygwin
Cygwin
Cygwin
Cygwin
Cygwin
yourself
yourself
MiKTEX
SumatraPDF
R for Windows
PuTTY
Everything
RubyInstaller
Macintosh
MacPorts
built-in
built-in
built-in
MacPorts
MacPorts
built-in
MacPorts
yourself
MacPorts
MacPorts
Skim
R for Mac
built-in
built-in
built-in
remark
spell checker
search letters
required by Mew
required by Mew
Japanese utility
required by cmigemo
search files
Note that Emacs cannot follow symbolic link made in Cygwin. Also, because Unixy shell scripts and
Windows batch files have different syntax for how they invoke commands, you cannot invoke shell script
on Cygwin command such like gnuzip. Create a bat file name gnuzip with following lines, and locate on
somewhere earlier than Cygwin on exec-path.
1
2
@echo off
gzip -d %*
Table 3: Typical locations for external programs
c:/emacs-24.3/bin
c:/emacs-24.4/libexec/emacs/24.4/i686-pc-mingw32
˜/bin
c:/cygwin
c:/MinGW/bin
c:/Program Files
c:/Program Files (x86)
Aspell There is Win32 port of Aspell; however, it saves dictionary with CR+LF, which is inconsistent with
Unixy system. We recommend one by Cygwin.
Grep and Find Find is file-name-search program. There are completely different ones by GNU and Microsoft8 . Emacs wants to invoke one by GNU. Locate the find-program to let Emacs find it earlier. Or set a
variable by S-expression like below.
1
(setq find - program "C:\\ cygwin \\ bin \\ find.exe")
Grep is important context-search program. There are ones by GnuWin32 (GNU grep 2.5.4, 2009), Ezwinports (GNU grep 2.10, 2012), and Cygwin (GNU grep 2.21, 2015) that accept --exclude-dir option. We
recommend one by GnuWin32 or Ezwinports because of backslash treatment9 .
Everything search Everything corresponds to Spotlight in Macintosh and lets you find a file quickly from
Emacs with a certain setup. With default installation, it will be launched on system startup. You do not have to
append a path to %PATH%. To invoke Everything from Emacs, you need to locate an interface program named
es to somewhere that Emacs can find.
8
Typically it is located as c:/Windows/System32/find.exe.
One by Cygwin (GNU grep 2.21, 2014) gives annoying warning as reported in http://lists.gnu.org/archive/html/
bug-gnu-emacs/2014-12/msg00013.html.
9
5
Migemo Migemo is a tool to allow incremental search of Kanji by Romaji. You build it by yourself. You
need development tools including a compiler. Install packages listed as “devel” on Cygwin.
How to build Migemo is detailed in cmigemo-master/doc/README_j.txt but summarized in below.
Install Kanji-character converter nkf in advance. Turn Migemo on by key combo Alt-m while on isearchmode.
1
2
3
4
5
6
7
8
9
cygwin$
cygwin$
cygwin$
cygwin$
cygwin$
cygwin$
cygwin$
cygwin$
cygwin$
cd nkf -2.1.3
make install
unzip cmigemo - maser .zip
cd cmigemo - master
./ configure
make cyg
make cyg -dict
make cyg - install
Mew Mew is a standard Japanese mailer. Mew 6.6 (as of January 31, 2015) does not support NT-Emacs
24.4. Download installer (Mew 6.6 for NT-Emacs 24.3) and edit mew.ini. Issue commands as shown below.
1
2
3
4
5
6
DOS > type mew.ini
BINDIR =c:\ emacs -24.4\ libexec \ emacs \24.4\ i686 -pc - mingw32
ELISPDIR =c:\ emacs -24.4\ share \ emacs \24.4\ site -lisp\mew
INFOPATH =c:\ emacs -24.4\ share \info
DOS > set emacs_dir =c:\ emacs -24.4
DOS > mew
5.2
Customization
Customization of Emacs is independent of platform. From this point you can look for book and web.
Emacs writes Japanese When you launch Emacs first time, type Ctrl + \ to initialize Japanese input
method ddskk.
Emacs browses WWW Web browser is used for HTML rendering. As of December 20 2014, emacs-w3m
serves as web browser using engine w3m. Have a configuration file ˜/.emacs-w3m as shown as below. Consider use built-in Eww.
1
2
3
4
5
6
7
8
(setq w3m -home -page "http :// dream . misasa .okayama -u.ac.jp/ documentation /")
(define -key w3m -mode -map (kbd "S-<SPC >") nil)
(define -key w3m -mode -map (kbd "w") ’w3m -delete - buffer )
(define -key w3m -mode -map (kbd "h") ’w3m -previous - buffer )
(define -key w3m -mode -map (kbd "l") ’w3m -next - buffer )
(define -key w3m -mode -map (kbd "f") ’w3m -view -this -url)
(define -key w3m -mode -map (kbd "o")
( lambda () ( interactive ) (sesami -open -file -or -url -at - point ’other - window )))
6
Appendix 1
Windows
Default setup of Windows system is sometime inconvenient. Here we show tips for useful setup.
remapkey.exe To let caps-lock key act as control key, use remapkey.exe that comes with Windows Resource Kit Tools by Microsoft. Run the application as administrator, drag control key to caps-lock key. Save
to registry and then restart Windows.
auto login To login without entering password, launch Windows command line; control userpasswords2;
checkout password.
aerosnap To prohibit automatic window expansion, control panel; Ease of Access Center; Make the mouse
easier to use; uncheck “prevent Windows from ...”.
show extension On Explorer, show extensions. Select Tools..., Folder options..., and ‘View’ tab. Uncheck
‘Hide extenstions for known file types’.
power setting Change power setting to “do not sleep when power supplied” from control panel; system and
security; power options; edit plan settings.
keyboard layout When Microsoft IME on with some system configuration you see “@” when you hit “[”.
You need to configure system for keyboard. Edit registry as below. See http://d.hatena.ne.jp/yohtani/
20091021/1256132743 for detail.
• launch regedit.exe
• open “Layout file” in
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layouts\00000411
• change KBDJPN.DLL to KBDUS.DLL then reboot the computer
change JP/EN There are three keyboard-input mode, EN, JP(A), JP(kana). To change A to kana in japanese
IME, add key-bind. Right-click language bar; settings; JP-Keyboard-IME; properties; edit action;
change; add key.
Table 4: Change input language
key
Alt + Shift
Ctrl + \
Ctrl + j
Appendix 2
mode
EN ↔ JP
JP(A) ↔ JP(kana)
JP(kana)
Macintosh
remap key Remap caps-lock as ctrl . Open System Preferences, Keyboard, then Modifier Keys. Change
shortcut for show Spotlight search field to be ctrl + tab .
symbolic links For convenience, issue following commands.
1
2
3
darwin$ cd
darwin$ ln -s bin/dot. emacs .d . emacs .d
darwin$ ln -s Library / texmf texmf
7
MacPorts and Xcode MacPorts is a package management system. To install MacPorts, Xcode is required.
It is available from App Store, Apple Developer (https://developer.apple.com/xcode/), or a DVD
media comes with 10.6.
External Programs To install external programs shown on Table 2 using MacPorts, issue following commands.
1
2
3
4
darwin$ sudo port install aspell aspell -dict -en
darwin$ sudo port install w3m subversion screen stunnel
darwin$ sudo port install texlive -lang -cjk texlive - basic texlive -bin texlive -bin - extra texlive -bibtex - extra
texlive - latex texlive -latex - extra texlive -latex - recommended texlive -fonts - recommended texlive -fonts - extra
texlive - pstricks texlive - publishers texlive - science
darwin$ sudo port install texlive -lang - japanese texlive - luatex texlive - pictures
Migemo See instruction for Windows for theory. How to build in Macintosh is described in below.
1
2
3
4
5
6
7
8
darwin$
darwin$
darwin$
darwin$
darwin$
darwin$
darwin$
darwin$
sudo port install nkf
unzip cmigemo - maser .zip
cd cmigemo - master
./ configure
make osx
make osx -dict
sudo make osx - install
PDF viewer Set Skim to default PDF application. Set preference to auto refresh on recompile and check
PDF-TEX sync-support with Emacs.
8