Difference between revisions of "Talk:Emacs"

From Apertium
Jump to navigation Jump to search
Line 1: Line 1:
== Quickstart for non-emacs users, emacs version 22 or lower ==
If you just want to get emacs set up for dix editing with the minimum of hassle, here is a howto. Assuming you have emacs installed, first execute (paste) the following commands in your terminal:

mkdir ~/.elisp
cd ~/.elisp
wget http://www.thaiopensource.com/download/nxml-mode-20041004.tar.gz
tar xzvf nxml-mode-20041004.tar.gz
rm -f nxml-mode-20041004.tar.gz
wget http://apertium.svn.sourceforge.net/viewvc/apertium/trunk/apertium-tools/dix.el
cd ..
touch ~/.emacs

Then open the file ~/.emacs in an editor (like vi) and enter the following:

<pre>
; Start of nxml-mode setup
(load "~/.elisp/nxml-mode-20041004/rng-auto.el") ; path to the _file_ you extracted

; Start of dix-mode setup
(add-to-list 'load-path "~/.elisp") ; path to the folder where you have dix.el
(autoload 'dix-mode "dix"
"dix-mode is a minor mode for editing Apertium XML dictionary files." t)

(add-to-list 'auto-mode-alist '("\\.dix\\'" . nxml-mode)) ; turn on nxml-mode for dix-files
(add-hook 'nxml-mode-hook ; turn on dix-mode for dix-files after nxml-mode
(lambda () (and buffer-file-name
(string-match "\\.dix$" buffer-file-name)
(dix-mode 1))))

; Start of CUA mode setup - to make Emacs behave like other editors - see http://www.emacswiki.org/CuaMode
(cua-mode t)
(setq cua-auto-tabify-rectangles nil) ; Don't tabify after rectangle commands
(transient-mark-mode 1) ; No region when it is not highlighted
(setq cua-keep-region-after-copy t) ; Standard Windows behaviour
</pre>



=== On Debian/Ubuntu ===

sudo apt-get install emacs nxml-mode
mkdir ~/.elisp
cd ~/.elisp
wget http://apertium.svn.sourceforge.net/viewvc/apertium/trunk/apertium-tools/dix.el
cd ..
touch ~/.emacs

Then open the file ~/.emacs in an editor (like vi) and enter the following:

<pre>
; (nxml-mode should be setup for all users by apt-get)

; Start of dix-mode setup
(add-to-list 'load-path "~/.elisp") ; path to the folder where you have dix.el
(autoload 'dix-mode "dix"
"dix-mode is a minor mode for editing Apertium XML dictionary files." t)

(add-to-list 'auto-mode-alist '("\\.dix\\'" . nxml-mode)) ; turn on nxml-mode for dix-files
(add-hook 'nxml-mode-hook ; turn on dix-mode for dix-files after nxml-mode
(lambda () (and buffer-file-name
(string-match "\\.dix$" buffer-file-name)
(dix-mode 1))))

; Start of CUA mode setup - to make Emacs behave like other editors - see http://www.emacswiki.org/CuaMode
(cua-mode t)
(setq cua-auto-tabify-rectangles nil) ; Don't tabify after rectangle commands
(transient-mark-mode 1) ; No region when it is not highlighted
(setq cua-keep-region-after-copy t) ; Standard Windows behaviour
</pre>



==Zen Coding for dix?==
==Zen Coding for dix?==
I think the Zen Coding syntax is more useful for XML types where
I think the Zen Coding syntax is more useful for XML types where

Revision as of 07:38, 18 May 2010

Quickstart for non-emacs users, emacs version 22 or lower

If you just want to get emacs set up for dix editing with the minimum of hassle, here is a howto. Assuming you have emacs installed, first execute (paste) the following commands in your terminal:

mkdir ~/.elisp
cd ~/.elisp
wget http://www.thaiopensource.com/download/nxml-mode-20041004.tar.gz
tar xzvf nxml-mode-20041004.tar.gz
rm -f nxml-mode-20041004.tar.gz
wget http://apertium.svn.sourceforge.net/viewvc/apertium/trunk/apertium-tools/dix.el
cd ..
touch ~/.emacs

Then open the file ~/.emacs in an editor (like vi) and enter the following:

 ; Start of nxml-mode setup
(load "~/.elisp/nxml-mode-20041004/rng-auto.el") ; path to the _file_ you extracted

 ; Start of dix-mode setup
(add-to-list 'load-path "~/.elisp") ; path to the folder where you have dix.el
(autoload 'dix-mode "dix" 
   "dix-mode is a minor mode for editing Apertium XML dictionary files."  t)

(add-to-list 'auto-mode-alist '("\\.dix\\'" . nxml-mode)) ; turn on nxml-mode for dix-files
(add-hook 'nxml-mode-hook               ; turn on dix-mode for dix-files after nxml-mode
 	  (lambda () (and buffer-file-name
 			  (string-match "\\.dix$" buffer-file-name)
 			  (dix-mode 1))))

 ; Start of CUA mode setup - to make Emacs behave like other editors - see http://www.emacswiki.org/CuaMode
(cua-mode t)
(setq cua-auto-tabify-rectangles nil) ; Don't tabify after rectangle commands
(transient-mark-mode 1) ; No region when it is not highlighted
(setq cua-keep-region-after-copy t) ; Standard Windows behaviour


On Debian/Ubuntu

sudo apt-get install emacs nxml-mode
mkdir ~/.elisp
cd ~/.elisp
wget http://apertium.svn.sourceforge.net/viewvc/apertium/trunk/apertium-tools/dix.el
cd ..
touch ~/.emacs

Then open the file ~/.emacs in an editor (like vi) and enter the following:

 ; (nxml-mode should be setup for all users by apt-get)

 ; Start of dix-mode setup
(add-to-list 'load-path "~/.elisp") ; path to the folder where you have dix.el
(autoload 'dix-mode "dix" 
   "dix-mode is a minor mode for editing Apertium XML dictionary files."  t)

(add-to-list 'auto-mode-alist '("\\.dix\\'" . nxml-mode)) ; turn on nxml-mode for dix-files
(add-hook 'nxml-mode-hook               ; turn on dix-mode for dix-files after nxml-mode
 	  (lambda () (and buffer-file-name
 			  (string-match "\\.dix$" buffer-file-name)
 			  (dix-mode 1))))

 ; Start of CUA mode setup - to make Emacs behave like other editors - see http://www.emacswiki.org/CuaMode
(cua-mode t)
(setq cua-auto-tabify-rectangles nil) ; Don't tabify after rectangle commands
(transient-mark-mode 1) ; No region when it is not highlighted
(setq cua-keep-region-after-copy t) ; Standard Windows behaviour 


Zen Coding for dix?

I think the Zen Coding syntax is more useful for XML types where you can have nesting, and where the structure changes more than the content; in eg. a bidix you'd probably find more use for a simple YASnippet that let you tab through these places:

<e><p><l>$1<s n="$2"/></l><r>$3<s n="$4"/></r></p></e>


Alternatively, it'd be fun to make a very compact dix expansion syntax…

i dag+adv=today+adv

<e>       <p><l>i<b/>dag<s n="adv"/></l><r>today<s n="adv"/></r></p></e>
 
driv.op/en__adj

<e lm="driven">          <i>driv</i><par n="op/en__adj"/></e>
 
irsk=Irish.__n_adj

<e>       <p><l>irsk</l><r>Irish</r></p><par n="__n_adj"/></e>

.iI.rsk=rish.__n_adj

<e>       <par n="iI"/><p><l>irsk</l><r>Irish</r></p><par n="__n_adj"/></e>
 
>ombudskvinne+n+f=ombudsman+n

<e r="LR"><p><l>ombudskvinne<s n="n"/><s n="f"/></l><r>ombudsman<s
n="n"/></r></p></e>

<skulde( på)+vblex=blame+vblex

<e r="RL"><p><l>skulde<g><b/>på</g><s
n="vblex"/></l><r>blame</g><s n="vblex"/></r></p></e>

\.

<e>       <i>.</i></e>

(basically, the "." switches between adding pardefs and adding i's, a "=" turns an <i> into <p><l></l><r></r></p>, a "+" adds s'es and an initial < or > adds restrictions to e)