[Gllug] Emacs Problem

Nix nix at esperi.org.uk
Sat Mar 27 14:33:54 UTC 2004


On Wed, 24 Mar 2004, Mick Farmer said:
> There is an irritating problem when I use emacs for editing
> mark-up documents.  For example, I bind the following to a
> function key in order to emphasis text.
> 
> (define-skeleton html-em
>   "HTML emphasis element"
>   nil
>   "<em>" _ "</em>")
> 
> This works fine if I hit the function key at the point where
> I'm typing.  However, if I highlight some text and then hit
> the function key, a newline is added after the "</em>".

This is because once `skeleton-insert' has inserted the skeleton, hooks
defined in `skeleton-end-hook' are called. From the docstring of that
hook:

,----
| Hook called at end of skeleton but before going to point of interest.
| By default this moves out anything following to next line.
`----

To fix it, (setq skeleton-end-hook nil) --- obviously, if you add your
own stuff to the end hook, do this *first* :)

(Pedant point: Emacs has no concept of `highlighting', just the concept
of the `region', a region bounded by your cursor (`point') at one end
and `the mark' at the other. Some of us old fogies turn the highlighting
off, which keeps the region active all the time, so you can drop the
mark and then five minutes later do something with it, or use `C-x C-x'
as a purely navigational command without having to worry about it
highlighting the world.)

-- 
`The game proceeds with people picking up cards in turn, and every so
 often this is punctuated with a church council when everyone goes mad
 and starts yelling and playing cards at each other and persecuting and
 making deals.' --- Jo Walton on _Credo_
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list