|
A flag icon shows that page is written in:
|
I believe
Emacs
is the base environment of
GNU's operating system
,
which has not however been realized yet
due to their too much strict sense of free software
.
XEmacs used to be a good competitor for its powerful image display and modern graphical user interface components, although Emacs 21 and the later version pushed them behind already.
環境としての Emacs は自分で構築していくものですが、
少なくとも
テキストエディタとしての Emacs
は、大抵の Linux ディストリビューションなら
標準で入っていますし、
入ってなくても簡単にダウンロードしてくれます。
入れかた (Xandros)
。
Free Software Foundation
の代表的なフリーソフトとして有名です
Emacs
も。
Richard Stallman
という人が作りました。すべてのソフトウェアはフリーであるべきだ。
彼は言った。
Unix コマンドラインから
$ emacs fileA &
でいきなり起動します。 emacs の後に編集したいファイル名を入れなくても構いません。 & を入れないとバックグラウンドで走らないだけです。
Emacs は補助キーを良く使うので記法を覚えてください。
とりあえず終了のしかたは C-x C-c です。 しかし環境としては始めに一度立ち上げたらそのまま立ち上げっぱなしで 使いましょう。終了すると起動に時間がかかります。
移動はカーソルキーでもできます (古いのは許していない) けど、 Emacs の伝統としては C-p = previous line, C-n = next line, C-b = backward, C-f = forward です。 C-a で行頭、C-e で行末にジャンプ。 C-v で一ページ進む、M-v で一ページ戻る。C-l でカーソルのある位置が 画面の中央にきます。
少し高度な (操作な) のですが M-< でバッファの先頭、 M-> でバッファの最後にいきます。
あるファイルを参照しながら別のファイルを編集したいなどのように、 ウィンドウを 2 つに分けるには C-x 2 です。 ウィンドウ間の移動は C-x o です。 ウィンドウを閉じるのは、C-x 0 (ゼロ) です。
ファイルは C-x C-f でオープン、C-x C-s で編集してるバッファをセーブ、 C-x C-w で名前を変えてセーブしてくれます。 C-x k でバッファをクローズします。 C-x C-c で終了するってことは既に書きましたけど 終了しなくていいです。
さぁ切った貼ったー。カット & ペースト (キル & ヤンク) はもちろん、 n 回繰り返してペーストも次の C-u と組み合わせてできます。 C-k で一行キル (削除) します。C-y でヤンク (復活)。 C-Space でマーク開始、カーソル移動で選択した範囲を C-w キルか M-w コピー、そして C-y ヤンクします。
C-u で直後のコマンドに引数を与えられます。 ただの文字や単純なコマンドだと回数を意味します。 C-u 7 9 = とすると、横に長い 2 重線を ("=" を 79 文字分) 引きます。
===============================================================================
こんな感じ。
There are two flavors of Emacs in Mac, one is GNU official Carbon Emacs and the other is AquaMacs.
I believe Carbon can directly be installed through Fink.
Fink is a distribution of Unix Open Source software for Mac OS X and Darwin. It brings a wide range of free command-line and graphical software developed for Linux and similar operating systems to your Mac.
dselect is a program that lets you browse the list of available binary packages and select which ones you want installed.
$ sudo dselect
The fink tool will allow you to install packages that are not yet available in the binary distribution. To get a list of packages that are available for installation from source,
$ fink list
You could define your key mappings as you like. shrink-window enlarges the other window opening another buffer, for example. It is not assigned to any key by default.
; ; Key mappings ; (define-key global-map "\C-x ^" 'enlarge-window) (define-key global-map "\C-x -" 'shrink-window)
Dired Mode
:
Emacs にはキーボード操作主体のエクスプローラ (ファイラーみたいなもの)
が中に組み込まれています。この機能は
Dired mode
とよく言われます。DOS 時代だった頃の HF なんかに比べると
見た目も見劣りするし
機能不十分な感じですが、同じ環境からコピーとかファイル操作が楽にできます。
Mew : メールクライアントになるマクロ。添付ファイルの解読処理とかを きちんとやってくれる。信頼性も評価も高いのが得られていると 思います。
w3m
and Emacs bridge
:
w3m
is a web browser that works in a terminal emulator window.
w3m-el
bridges Emacs and w3m nicely.
$ sudo aptitude install w3m-el w3m-img
AngeFtp
:
実は個人的にブログとか静的 html じゃない CMS とかは好きとは言えないたちで、
HTML やプログラムを自由にリモート環境からカチャカチャいじりたくて、
エディタで HTML やプログラムを書いて
ファイル転送をいまだにしょっちゅう使っている人。
そうじゃない人でさえ、
Emacs で FTP 先のファイルを自動で扱える環境に憧れるのはわかります。
そんな、高度な、望みを、容易に叶えてくれるマクロが
AngeFtp
です。
Register all your Java source files with etags command :
$ etags src/sh/run/Runftp/*.java
After that, you can apply function search within all those files.
M-.
: Find the tag entered. (find-tag)
M-*
: Pop back to the previous tag. (pop-tag-mark)
M-x tags-search
: Apply full-text search in the files
registered in the TAGS file.
M-,
finds the next match.
Java Devolopment Environment for Emacs is a powerful environment where you can rely on templates, automatic abbreviation expansion, in-place compilation and debugging, an N80BASIC-like command interpreter called beanshell, source code browser, etc. Be sure to have Java Development Kit installed proper way :
$ sudo aptitude install jde
This takes time as elisps (for Emacs and XEmacs) like cedet and elib that jde depends on will also be installed, byte-compiled and configured.
To manually install JDEE and the packages required by it, set up your Mac so you can use a decent Emacsen like GNU Emacs or Aquamacs.
Download the recent versions of cedet which also comes with Eric Ludlam's speedbar, eieio, and semantic bovinator packages and install them on your system.
Always use the lately version, which is in my experience 1.0pre4 working fine at the time of writing, as I encountered problems with older versions with other packages.
Typically you just need to unarchive the tarball into Emacs
site-lisp
directory such as :
$ tar zxvf cedet-1.0pre4.tar.gz $ sudo mv cedet-1.0pre4/* /usr/share/emacs/site-lisp
Sure you can byte-compile the elisps for faster operation, applying the Makefile with make command that can be download from Apple's Xcode page.
$ cd /usr/share/emacs/site-lisp $ sudo make $ sudo rm Makefile INSTALL
If you use different kinds of Emacs at the same time, you should specify the one you want to compile for :
$ sudo make EMACS=/Users/ryu/Desktop/Emacs.app/Contents/MacOS/Emacs
Also install the Emacs Lisp library package called elib
using the Makefile that come with the package.
Here is a typical modification of Makefile :
prefix = /usr/share # datadir = $(prefix) locallisppath = $(prefix)/emacs/site-lisp ELIBDIR = $(locallisppath)/elib infodir = $(prefix)/info
Usually ou just need to do make install
in the
package's directory
and everything is copied into the specified lisp directory,
but if you experience the error message :
install-info(elib.info): unable to determine description for `dir' entry - giving up
the compilation is failed.
If compilation failure happens in a special environment
such as MacOSX, copy everything to the target
elib
directory and make every elc yourself
:
$ sudo cp * /usr/share/emacs/site-lisp/elib/ $ cd /usr/share/emacs/site-lisp/elib $ sudo make
Now, get the JDEE body and unarchive the tarball again under
site-lisp
directory.
$ sudo tar zxvf jde-2.3.5.1.tar.gz -C /usr/share/emacs/site-lisp $ cd /usr/share/emacs/site-lisp $ sudo chmod -R go+r jde (in case strange permissions created especially in Mac) $ sudo ln -s jde-2.3.5.1 jde
In MacOSX, you might need to change the Classes/classes.jar
in jde/lisp/jde.el/jde-get-tools.jar
to
/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Classes/classes.jar
like the following.
In MacOSX, you should edit
/usr/share/emacs/site-lisp/jde/jde.el
to change the tools variable definition in the defun block
of jde-get-tools-jar
.
(let ((tools
(expand-file-name
(if (eq system-type 'darwin)
"/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Classes/classes.jar"
)
(jde-get-jdk-dir))))
....
Then you will want to byte-compile the elisps in JDEE using make. Some packages, in particular, cc-mode, run correctly only when compiled. Although many packages run fine without compiling, it is usually safest to compile.
Here's how to do it :
$ cd /usr/share/emacs/site-lisp/jde/lisp $ sudo make CEDET=../..
After installation you must verify the permissions of
particularly library files under
/usr/share/emacs/site-lisp/jde/java/lib
:
$ ls -l /usr/share/emacs/site-lisp/jde/java/lib $ sudo chmod 644 /usr/share/emacs/site-lisp/jde/java/lib/*
In addition to the required packages, I highly recommend that you also install the Emacs Code Browser (ECB) to make it look like a true integrated development environment.
ECB greatly facilitates the JDEE's use in developing applications that comprise many classes.
$ sudo aptitude install ecb
Currently ECB 2.32 works best with working CEDET pre4.
(2.40 did not go well.)
In MacOSX, you will need to install ECB from the source
(typically just copying, or byte-compiling)
and you might sometimes need to modify the permissions
under the ecb
file structure correctly :
$ cd /usr/share/emacs/site-lisp/ecb/
$ sudo chmod -R 644 *
$ sudo find . -type d -exec chmod a+x {} \;
Anyway, you must tell Emacs where the JDEE and its required packages live and turn on cedet as well by editing the startup file '~/.emacs'.
(add-to-list 'load-path "/usr/share/emacs/site-lisp/jde/lisp") (add-to-list 'load-path "/usr/share/emacs/site-lisp/cedet-common") (add-to-list 'load-path "/usr/share/emacs/site-lisp/speedbar") (add-to-list 'load-path "/usr/share/emacs/site-lisp/eieio") (add-to-list 'load-path "/usr/share/emacs/site-lisp/ede") (add-to-list 'load-path "/usr/share/emacs/site-lisp/cogre") (add-to-list 'load-path "/usr/share/emacs/site-lisp/semantic") (add-to-list 'load-path "/usr/share/emacs/site-lisp/cedet-contrib") (add-to-list 'load-path "/usr/share/emacs/site-lisp/elib") (add-to-list 'load-path "/usr/share/emacs/site-lisp/ecb") (setq semantic-load-turn-useful-things-on t) (load "cedet")
Tell JDEE where JDK resides and its version in ~/.emacs
:
(setq jde-compiler '("javac server" "")) ;; Use javac server
(setq jde-jdk '("Sun Java6 1.6.0.12"))
(setq jde-jdk-registry '(("Sun Java6 1.6.0.12" . "/usr/lib/jvm/java-6-sun/")))
(setq jde-debugger '("JDEbug")) ;; Use JDEbug
In MacOSX, also set class path for Java :
(setq jde-global-classpath
(list
"."
"/usr/share/java/*"
"/System/Library/Frameworks/JavaVM.framework/Classes/classes.jar"
"/usr/share/emacs/site-lisp/jde/java/lib/bsh.jar"
"/usr/share/emacs/site-lisp/jde/java/lib/jde.jar"
))
You could invoke the environment with M-x jde-mode
or require
it at startup of Emacs, however I'd use autoload for loading on demand.
;; open jde-mode automatically for java source
(autoload 'jde-mode "jde" "Java Development Environment for Emacs." t)
(setq auto-mode-alist (cons '("\.java$" . jde-mode) auto-mode-alist))
;; ECB autoloads
(require 'ecb-autoloads)
Other useful settings are listed below :
;; Comment field setting
(setq user-full-name "Lewske Wada")
(setq user-mail-address "ryu@run.sh")
(setq compilation-window-height 10)
;; java document setting
(custom-set-variables
'(jde-help-docsets (quote (
("JDK API" "/usr/share/doc/openjdk-6-jre/api/index.html" nil))))
'(jde-jdk-doc-url "http://java.sun.com/javase/6/docs/"))
(custom-set-faces)
I think indentation is very important to make your coding smooth and without stumbling.
;; indentation
(add-hook 'jde-mode-hook
'(lambda ()
(c-set-offset 'inline-open 0)
(c-set-offset 'statement-block-intro '+)
(c-set-offset 'knr-argdecl-intro 5)
(c-set-offset 'substatement-open '+)
(c-set-offset 'label 0)
(c-set-offset 'statement-case-open '+)
(c-set-offset 'statement-cont '+)
(c-set-offset 'access-label 0)
(c-set-offset 'inher-cont 'c-lineup-java-inher)
(c-set-offset 'func-decl-cont 'c-lineup-java-throws)
(c-set-offset 'arglist-intro '+)
(c-set-offset 'arglist-close 0)
(c-set-offset 'topmost-intro-cont 0)
(setq c-basic-offset 4)
(setq indent-tabs-mode nil)
)
)
; Indent a new line like previous non-blank line.
(global-set-key "\C-m" 'newline-and-indent)
(setq indent-line-function 'indent-relative-maybe)
Set these variables as well in your .profile
.
bsh.jar
implements beanshell
which is the key component of JDEE.
Alternatively you can
just copy the jar files into /usr/share/java
.
$ sudo cp bsh.jar /usr/share/java (alternatively) $ sudo cp jde.jar /usr/share/java (alternatively)
Set the class path accordingly anyways.
CLASSPATH=$CLASSPATH:/usr/share/emacs/site-lisp/jde/java/lib/bsh.jar CLASSPATH=$CLASSPATH:/usr/share/emacs/site-lisp/jde/java/lib/jde.jar export CLASSPATH JAVA_HOME=/usr/lib/jvm/java-6-sun export JAVA_HOME
Make sure M-x bsh-run
works as it is the key for
JDEE to run properly.
If it says like
Cannot find the BeanShell jar file at ....
,
check the permissions and the paths of the above jar files.
This is the path setting for use with Android SDK.
PATH=$PATH:$HOME/opt/android-sdk-linux_86/tools
You can travel through source codes with the top menu groups
Buffers
and Classes
as well as utilizing
M-x speedbar
.
The easiest way to compile the files is to use the JDEE command jde-compile-jde.
The JDEE's lisp directory contains a makefile that compiles the JDE Lisp files. The makefile assumes that you are using GNU Emacs and that the packages required by the JDEE are installed in the same directory as the JDEE package itself, i.e., the makefile assumes a directory structure similar to the following:
site
jde
speedbar
semantic
elib
eieio
Autocompletion works in basically two ways.
C-c C-v C-..
M-/.
The JDE → Code Generation → Import → All
( jde-import-all, C-c C-v z
)
imports all the classes that need to be imported into the current buffer.
ECB presents analyzed views of classes, fields and methods that are
focused synchronously with cursor movement.
To activate the IDE, run it with M-x ecb-activate
.
C-c . l t: Toggle the layout
C-c . l w: Toggle visibility of the ECB layout
Read the ECB manual, too : M-x ecb-show-help
To enable building projects with ant
,
you should also add these to your .emacs
.
;; Ant (setenv "ANT_HOME" "/usr/share/ant") (setq jde-ant-enable-find t) (setq jde-ant-program "/usr/bin/ant") (setq jde-ant-read-target t) (setq jde-build-function (quote (jde-ant-build)))
Type in emacs :
C-c C-v C-b, and then specify build target such as
debug
With Android mode, you can also logcat and run GUI helpers like DDMS and the emulator from Emacs.
$ git clone git://github.com/remvee/android-mode.git $ sudo cp -R android-mode /usr/share/emacs/site-lisp
;; android-mode (add-to-list 'load-path "/usr/share/emacs/site-lisp/android-mode") (require 'android-mode) (setq android-mode-sdk-dir "/opt/android-sdk")
M-x android-logcat
M-x android-start-emulator
M-x android-start-ddms
;; Auto indentation
(add-hook 'c-mode-common-hook
'(lambda ()
(c-set-style "gnu")
(setq c-basic-offset 4) ;; Change indentation offset to 4
;; Don't indent comment-only line
(setq c-comment-only-line-offset . (0 . 0))
))
For the details, read these pages on: