Eduardo Cavazos <[email protected]> writes:

> Hello,
>
> I need to insert ':' in my Factor code so much, it's a pain to have it 
> be a shifted character. I've added this to my '.emacs' to make things 
> more convenient:
>
> (defun factor-semicolon-command ()
>    (interactive)
>    (if (bolp)
>        (insert ": ")
>      (insert ";\n\n")))
>
> (define-key factor-mode-map (kbd ";") 'factor-semicolon-command)
>
> So, if you press the ';' key and you're at the beginning of a line,
> ": " is inserted. Otherwise, the word is closed; i.e. ";" and a couple 
> of newlines are inserted.
>
> I say "modest" because this is far cry from the snippet style proposal I 
>   mentioned a while back which inserts the entire word template. I'm 
> still interested in experimenting with that approach.

An easy way to accomplish what you want is using snippet.el
(http://www.kazmier.com/computer/snippet.el). You just need to put it
in your load path, and then:

(defun factor-semicolon-command ()
   (interactive)
   (if (bolp)
       (snippet-insert ": $${word} ( $${in} -- $${out} ) $. ;")
     (insert ";\n\n")))

IIRC, this already implements your proposal, and there's many variations
you can play with that. For instance, snippets can work with
abbrev-mode, and you can trigger them automatically---i would, for
instance, link the word snippet to ";;", instead of modifiying the
binding for `;' in the mode keymap; but that's just me.

Would that work for you?

Cheers,
jao

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to