Do not insert equal sign if one already

Deniz Dogan deniz.a.m.dogan at gmail.com
Wed Nov 3 19:19:23 EDT 2010


2010/11/2 Johan Andersson <johan.rejeep at gmail.com>:
> Or maybe this is better so you can be anywhere in a line without inserting
> the equal sign:
> (unless (string-match "=" (buffer-substring-no-properties
> (line-beginning-position) (line-end-position)))
>     (insert "= "))

Consider this example:

foo a | a == 1 = 2
  | a == 2 *

Note that the second line needs indentation and you want to both
indent the line and insert "=". With your latest suggestion, it would
not insert the character.

I think your first idea with looking-back is the better way to go,
even though I wonder why you use this command if you already have an
equals sign.

-- 
Deniz Dogan



More information about the Haskellmode-emacs mailing list