File: marsden.html

package info (click to toggle)
lg-issue25 4-2
  • links: PTS
  • area: main
  • in suites: potato
  • size: 1,552 kB
  • ctags: 68
  • sloc: tcl: 69; makefile: 37; sh: 4
file content (147 lines) | stat: -rw-r--r-- 5,860 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<!--startcut ==========================================================-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<title>EMACSulation LG #25</title>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#A000A0"
ALINK="#FF0000">
<!--endcut ============================================================-->

<H4>
"Linux Gazette...<I>making Linux just a little more fun!</I>"
</H4>

<P> <HR> <P> 
<!--===================================================================-->

<center>
<h1>EMACSulation</h1>
<h4>By 
<a href="mailto:emarsden@mail.dotcom.fr">Eric Marsden</a></h4>
</center>
<p><hr>


<img align="left" src="./gx/marsden/EMACSulation.gif">

   This column is devoted to making the best use of Emacs, text editor
   extraordinaire. Each issue I plan to present an Emacs extension
   which can improve your productivity, make the sun shine more
   brightly and the grass greener.
<P> <HR> 

<p> <b>Jka-compr</b> is a package written by Jay K. Adams which allows
    Emacs to handle compressed files transparently. When you open a
    compressed file, Emacs will automatically decompress it before
    displaying it. If you make changes and save the file, it will be
    compressed transparently before being written to the disk. To
    enable jka-compr, just add the following line to your emacs
    configuration file (normally called <tt>~/.emacs</tt>) :

<pre>
    (require 'jka-compr)
</pre>

<p> jka-compr works by looking at the filename extension, and in its
    default configuration recognizes <tt>.gz</tt> (gzip), and
    <tt>.Z</tt> (compress) files. It also recognizes the extension
    <tt>.tgz</tt> and unzips tarballs before passing them to tar-mode,
    which lets you look inside tar files. If you use other compression
    programs you can tell Emacs about them too, for example to use
    Julian Seward's <a href="http://www.muraroa.demon.co.uk/">bzip2</a>
    (faster and slightly better compression than gzip, under GPL) you
    could add the following to your <tt>.emacs</tt> (<em>before</em>
    loading jka-compr)

<pre>
    (setq jka-compr-compression-info-list
      '(["\\.Z\\(~\\|\\.~[0-9]+~\\)?\\'"
         "compressing"    "compress"     ("-c")
         "uncompressing"  "uncompress"   ("-c")
         nil t]
        ["\\.tgz\\'"
         "zipping"        "gzip"         ("-c" "-q")
         "unzipping"      "gzip"         ("-c" "-q" "-d")
         t nil]
        ["\\.gz\\(~\\|\\.~[0-9]+~\\)?\\'"
         "zipping"        "gzip"         ("-c" "-q")
         "unzipping"      "gzip"         ("-c" "-q" "-d")
         t t]
         ["\\.bz2\\(~\\|\\.~[0-9]+~\\)?\\'"
          "bzipping"      "bzip2"        ()
          "bunzipping"    "bzip2"        ("-d")
          nil t]))
</pre>


<h3>How does it work?</h3>

<p> Packages like jka-compr are written in Emacs Lisp; you can read
    the source code in the directory
    <tt>/usr/local/lib/emacs/${VERSION}/lisp/jka-compr.el</tt> for GNU
    Emacs, or
    <tt>/usr/local/lib/xemacs-${VERSION}/lisp/packages/jka-compr.el</tt>
    for XEmacs users (if you are using a Red Hat Linux distribution,
    you need to install the emacs-el package to see the source
    files). How can they change the behaviour of Emacs at such a low
    level as reading and writing files? The answer comes from the
    concept of <em>hooks</em>.

<p> Most of Emacs' low-level functions (which are written in C) have
    an associated hook, to which user-level functions (written in
    Emacs Lisp) can be attached. Hooks are fundamental to the
    customizability of Emacs, allowing users to override default
    behaviour in ways that its developers could not have imagined.
    Hooks are explained in the Emacs and Elisp manuals, which are
    available online from within Emacs by typing <code>C-h i</code>
    (or from the Help menubar or (blech!) the XEmacs toolbar).

<p> As an example of using a hook, the <code>after-init-hook</code> is
    run right after Emacs is lauched and has loaded your
    initialization file. Let's say you want Emacs to tell your fortune
    each time you start it. Just add the following lines to your
    <tt>.emacs</tt> :

<pre>    
   (add-hook 'after-init-hook
      (function
       (lambda ()
         (pop-to-buffer (get-buffer-create " *Fortune*"))
         (shell-command "fortune -a" t))))
</pre>


<h3>Next time ...</h3>

<p> In the next issue I'll discuss <b>ange-ftp</b>, which lets Emacs
    see the Internet as a huge virtual filesystem. Please contact me
    at <tt>&lt;emarsden@mail.dotcom.fr&gt;</tt> with comments,
    corrections or suggestions. <code>C-u 1000 M-x hail-emacs</code> !

<p> <b>PS</b>: Emacs isn't in any way limited to Linux, since
    implementations exist for many other operating systems. However,
    as one of the leading bits of free software, one of the most
    powerful, complex and customizable, I feel it has its place in the
    <i>Linux Gazette</i>. Don't forget, <b>E</b>macs <b>m</b>akes
    <b>a</b>ll <b>c</b>omputing <b>s</b>imple :-)

<!--===================================================================-->
<P> <hr> <P> 
<center><h5>Copyright &copy; 1998, Eric Marsden<br>
Published in Issue 25 of <i>Linux Gazette</i>, February 1998</H5></center>

<!--===================================================================-->
<P> <hr> <P> 
<A HREF="./lg_toc25.html"><IMG ALIGN=BOTTOM SRC="../gx/indexnew.gif" 
ALT="[ TABLE OF CONTENTS ]"></A>
<A HREF="../lg_frontpage.html"><IMG ALIGN=BOTTOM SRC="../gx/homenew.gif"
ALT="[ FRONT PAGE ]"></A>
<A HREF="./pavlicek.html"><IMG SRC="../gx/back2.gif"
ALT=" Back "></A>
<A HREF="./appleton.html"><IMG SRC="../gx/fwd.gif" ALT=" Next "></A>
<P> <hr> <P> 
<!--startcut ==========================================================-->
</BODY>
</HTML>
<!--endcut ============================================================-->