emacsKiBi’s bloghttp://mraw.org/blog/tags/emacs/KiBi’s blogikiwiki2013-12-17T02:11:28ZMarkdown-mode uploadedhttp://mraw.org/blog/2007/08/10/Markdown-mode_uploaded/2013-12-17T02:11:28Z2007-08-09T22:00:00Z
<p><code>markdown-mode</code> has been included (<a href="http://bugs.debian.org/435631">Debian bug #435631</a>) in the <a href="http://packages.debian.org/emacs%2Dgoodies%2Del">emacs-goodies-el</a> package, in the <code>27.0-1</code> revision.</p>
Custom etags languagehttp://mraw.org/blog/2007/08/03/Custom_etags_language/2013-12-17T02:11:28Z2007-08-02T22:00:00Z
<p><a href="http://packages.debian.org/debootstrap">debootstrap</a> is written in shell, and the principal points of
interest, <code>debootstrap</code>, <code>functions</code>, and <code>scripts/debian/sid</code> are several
hundreds lines each, the last ones being sourced by the first one.</p>
<p>Emacs is supposed to be great, let's look at <code>etags</code>, the Emacs flavour of
<a href="http://ctags.sourceforge.net/">exuberant ctags</a>. It generates a <code>TAGS</code> file
which is then used by Emacs when <code>M-.</code> is pressed, to search for the current
word (at the point). <code>etags</code> supports many languages, but I first thought shell
was missing. Hopefully, it is possible to <a href="http://ctags.sourceforge.net/EXTENDING.html">add
support</a> for new languages, which
can be done using two methods: either pass some regexps to <code>etags</code>, or implement
a new parser and recompile <code>etags</code> after having added it to the Makefile.</p>
<p>The first method was sufficient here, since <code>debootstrap</code>'s code is quite well
indented, and at first glance, every function is declared using the following:
left-aligned, possibly followed by whitespaces, followed by (possibly spaced)
parentheses, possibly followed by whitespaces, possibly followed by an opening
brace. That is:</p>
<pre><code>'/^([a-zA-Z0-9_]+)[ \t]*[(][ \t]*[)][ \t]*[{]*[ \t]*/\1/'
</code></pre>
<p>One could have used two regexps (using <code>--regex-$LANG</code> twice) to accept only
the following, which would have been sufficient, given the current source
files:</p>
<pre><code>'/^([a-zA-Z0-9_]+) [(][)] [{]/\1/'
'/^([a-zA-Z0-9_]+)[(][)]/\1/'
</code></pre>
<p>Now, it is sufficient to add a <code>tags:</code> target to the Makefile, running <code>etags</code>
on the interesting files, defining a new language <code>kibishell</code> (so as to void
possible clash with future well-featured shell modes), forcing it for the
specified files (since they have no extension, it is not possible to use
<code>--langmap=kibishell:.sh</code>).</p>
<p>Added Makefile fragment:</p>
<pre><code>tags:
etags \
--totals \
--langdef=kibishell \
--regex-kibishell='/^([a-zA-Z0-9_]+)[ \t]*[(][ \t]*[)][ \t]*[{]*[ \t]*/\1/' \
--language-force=kibishell \
debootstrap functions scripts/debian/sid
</code></pre>
<p>Usage within Emacs:</p>
<ul>
<li><code>M-.</code>: search for a definition;</li>
<li><code>M-O M-.</code>: next definition;</li>
<li><code>M-*</code>: go back to the starting point;</li>
<li><code>M-x visit-tags-table</code>: change the reference file.</li>
</ul>
<p>Now that I can read that <code>sh</code> is supported, it is sufficient to drop <code>--langdef</code>
and <code>--regex-kibishell</code>, and to adjust <code>--language-force</code>. Here it is: not that
bad after all, only 6 symbols were missing, on a total of 63.</p>
<p>A last word on <code>etags</code>: it accepts <code>-x</code> so that a cross reference is written to
the standard output, in the <a href="http://www.gedanken.demon.co.uk/cxref/">cxref</a>
format.</p>
Markdown and other Emacs modehttp://mraw.org/blog/2007/08/02/Markdown_and_other_Emacs_mode/2013-12-17T02:11:28Z2007-08-01T23:00:00Z
<p>Hopefully there is a
<a href="http://jrblevin.freeshell.org/software/markdown-mode/">markdown-mode</a>
for Emacs, but it isn't packaged (yet). After a quick ITP (<a href="http://bugs.debian.org/435485">Debian bug #435485</a>), and having having asked around, it turned out that pushing
it into the <a href="http://packages.debian.org/emacs%2Dgoodies%2Del">emacs-goodies-el</a> package would be the right
thing.</p>
<p>It was sufficient to follow the instructions in <code>00AddingFiles</code> to get
an updated package, with a functional and documented (<code>README.Debian</code>,
<code>debian/control</code>, Texinfo manual) <code>markdown-mode</code> for at least both
<code>emacs21</code> and <code>emacs22</code>, hence the wishlist bug (<a href="http://bugs.debian.org/435631">Debian bug #435631</a>).</p>
<p>Having a look at the other wishlist bugs, some might be of some
interest, and a patch could be forged to make them available and ease
the packagers' workload:</p>
<ul>
<li><p><a href="http://www.emacswiki.org/cgi-bin/wiki/show-wspace.el">showspace.el</a>
(<a href="http://bugs.debian.org/422876">Debian bug #422876</a>): highlight various spaces, tabs, etc.</p></li>
<li><p><a href="http://users.skynet.be/ppareit/projects/graphviz-dot-mode/graphviz-dot-mode.html">graphviz-dot-mode.el</a>
(<a href="http://bugs.debian.org/428601">Debian bug #428601</a>): major mode for the graphviz dot format. Yay!</p></li>
</ul>
<p>Other wishlist bugs, which have to be inspected a bit:
<a href="http://bugs.debian.org/336398">Debian bug #336398</a>, <a href="http://bugs.debian.org/314664">Debian bug #314664</a>, <a href="http://bugs.debian.org/228550">Debian bug #228550</a>. (They might
have seen no answer in 2 years, or be waiting for an answer from
upstream, etc.)</p>
<p>Nice modes already included in <code>emacs-goodies-el</code>:</p>
<ul>
<li><code>color-select</code>: nice colors include <em>Arjen</em>, <em>Billw</em>, <em>Calm Forest</em>,
<em>Cheap Goldenrod</em>, <em>Clarity and Beauty</em>, <em>Comidia</em>, <em>Dark Laptop</em>,
<em>TTY Dark</em>, <em>White on Black</em>.</li>
</ul>
Emacs and Perlhttp://mraw.org/blog/2007/07/28/Emacs_and_Perl/2013-12-17T02:11:28Z2007-07-27T22:00:00Z
<p>Emacs is said to do The Right Thing, but it looks like that is not the case for
Perl. It defaults to <code>perl-mode</code>, which can be hopefully replaced by
<code>cperl-mode</code>, with some additional lines in the <code>~/.emacs</code> configuration file.</p>
<pre><code>;; We always prefer CPerl mode to Perl mode.
(fset 'perl-mode 'cperl-mode)
;; When starting load my hooks
(add-hook 'cperl-mode-hook 'my-cperl-mode-hook t)
;; Ensure we use PerlStyle
(defun my-cperl-mode-hook ()
(cperl-set-style "PerlStyle")
</code></pre>