local computer

Transcription

local computer
Setup Windows 7 for a scientist
H. Kitagawa (January 26, 2015)
Last modified: c:/Users/dream/orochi-devel/documentation/OrochiSetupWin7/report.tex
on 2015-01-25 22:21
Abstract
This document summarizes a setup procedure of Windows 7 for a scientist.
Contents
1
INTRODUCTION
1
2
CYGWIN
1
3
SCIENTIFIC TOOLS
2
4
OROCHI SPECIFIC
2
5
GNU Emacs
5.1 Main Emacs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.2 External programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.3 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4
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. Cygwin is considered as a primary source for utilities.
There are two possible Emacs, that are official build for Windows, that also is referred as NT-Emacs, and
one for Cygwin.
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 to environmental variables, right-click computer, click
properties, click advanced settings, then click environment variables.
1
C:\ Users \ hkitagawa
Install Cygwin1 without additional packages for the first around. 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, remove
it.
2
Sometimes “Publishing” packages gives problems for unknown reasons.
1
3
SCIENTIFIC TOOLS
External programs should be launch-able from cmd.exe to be called from Emacs. Append path to a
program (such like C:\Program Files\R\R-3.1.2\bin) each time you install it, 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 such 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 path. Occasionally update database by clicking Refresh FNDB .
MiKTEX does not come with Japanese pLATEX. If you need it, install it on Cygwin4 . It is a hard work to
invoke Japanese pLATEX from cmd.exe. First of all, there is another platex.exe provided by 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, cmd.exe 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
$latex
$dvipdf
= ’pdflatex %O %S’;
= ’eptex -kanji =utf8 -progname = platex %O %S’;
= ’dvipdfmx %O -o %D %S’;
PDF viewer Install SumatraPDF and set inverse search command-line in Settings/options, as below.
C:\ emacs -24.3\ bin\ emacsclientw .exe --no -wait +%l "%f"
1
To bind key Esc to close a window and use tab-browsing, select “Advanced Options...” from menu and set
EscToExit and ReuseInstance to true. Make SumatraPDF as default PDF application for MS Windows.
R
1
2
3
Install R for Windows. After installation launch “R.exe” and install additional packages as below.
R> install . packages ("klaR")
R> install . packages (" ggplot2 ")
R> install . packages (" ellipse ")
Matlab To let Matlab recognize user-definition files located such in C:\Users\hkitagawa\matlab, issue
following command.
1
matlab > userpath ( fullfile ( getenv (’HOME ’),’matlab ’))
Firefox
4
Install plugin KeySnail.xpi to have Emacs key-bind. To setup sync using certain account is useful.
OROCHI 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.
3
4
Also append path to utilities on Cygwin such like C:/cygwin/bin, C:/cygwin/usr/bin,C:/cygwin/usr/local/bin.
As a consequence, you have two LATEX systems with or without Japanese pLATEX.
2
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 DREAM-related files are maintained on version controlled repositories by Subversion
and Git.
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 on Unixy system, 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 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 as appropriate user such like hominidae. Add your public key on ˜/.ssh/id_rsa.pub to
Git server. Issue following command 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
Configuration To copy configuration files such as .bashrc, issue following command,
1
˜/ bin/dot.cp
or issue following commands.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/ 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
rm
˜/. aspell .en.pws
ln -s ˜/. emacs .d/dict/dot. aspell .en.pws
rm
˜/. screenrc
ln -s ˜/ 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
˜/. aspell .en.pws
˜/. screenrc
˜/. emacs -w3m
˜/. mew.el
˜/. gnus.el
˜/. authinfo
˜/. orochirc
To set environmental variables up, run SETUP_ENV.BAT on command prompt, as shown below
1
2
DOS > cd xtreeml
DOS > SETUP_ENV .BAT
3
or issue following commands.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
@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 XTREEML
%HOME %\ xtreeml
setx EMACS_DIR
% EMACS_DIR %
setx ALTERNATE_EDITOR % EMACS_DIR %\ bin\ runemacs
setx EMACSCLIENT
% EMACS_DIR %\ bin\ emacsclientw
setx PATH_OROCHI
%HOME %\ bin ;% XTREEML %\ perl ;% XTREEML %\ ruby ;% XTREEML %\ ruby\xml ;% XTREEML %\ orochi \bin ;%
XTREEML %\ vs\bin
setx PATH_VS
%HOME %\ vstool \bin
setx PATH_CYGWIN
C:\ cygwin \bin;C:\ cygwin \user\bin;C:\ cygwin \user\sbin;C:\ cygwin \usr\ local \bin
setx PATH_MINGW
C:\ MinGW \msys \1.0\ bin;C:\ MinGW \bin
setx PATH
%% PATH_CYGWIN %%;%% PATH_OROCHI %%;%% PATH_VS %%
Dropbox Install and log in with appropriate account. DREAM-related utilities are stored in ˜/Dropbox/
Documents/Emacs/.
5
GNU Emacs
Emacs relies on many external programs. On this section, installation of GNU Emacs itself, external
programs, and configuration, are described.
5.1
Main Emacs
Emacs on Cygwin works on their own file system. For example, a directory C:\Program Files is recognized
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 best5 .
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/bin/6 .
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, create and 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
5.2
External programs
Overview Install external programs as listed in Table 2.
When Emacs is launched, command-search 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-pcPossible locations for external programs are shown in Table 3.
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
5
After a while, you want to build Emacs by yourself. On this step, start to 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.
6
4
Table 1: An example of user’s environment variables for Windows
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:\MinGW\bin;C:\cygwin\bin;C:\cygwin\user\bin;
C:\cygwin\user\sbin;C:\cygwin\usr\local\bin
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
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 and inconsistent with other
system. We recommend one by Cygwin.
Aspell looks for ˜/.aspell.en.pws. If you want to locate the personal dictionary to somewhere else,
make a symbolic link on Cygwin.
Grep and Find 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. Orochi prefers one by GnuWin32 or Ezwinports because of backslash treatment7 . Locate the grepprogram to let Emacs find it first, considering order of paths in exec-path. Or set a variable by S-expression
like below.
1
(setq grep - program "C:\\ MinGW \\ bin \\ grep.exe")
7
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.
5
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 Sexpression like below.
1
(setq find - program "C:\\ cygwin \\ bin \\ find.exe")
Everything 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.
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$
5.3
cd nkf -2.1.3
make install
unzip cmigemo - maser .zip
cd cmigemo - master
./ configure
make cyg
make cyg -dict
make cyg - install
Configuration
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.
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 )))
Emacs reads email Check Orochi mailing-list occasionally. Have a configuration file ˜/.mew.el as shown
as below. To read a mail, type M-x mew.
1
$ cp ˜/ bin/dot. emacs .d/dot.mew.el
8
˜/. mew.el
Typically it is located as c:/Windows/System32/find.exe.
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 ...”.
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
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.
7
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