help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

conditionnal-abbrev-expand


From: damien.thiriet77
Subject: conditionnal-abbrev-expand
Date: Mon, 04 Feb 2013 19:59:22 +0100

Hi,

I wrote a small elisp function that is very convenient for people using emacs 
for writing articles, especially in flexible tongues as Polish. The idea is 
that rather than having 5 abbrev for polityczny, polityczna, politycznego, 
politycznym, politycznymi I will have one abbrev that will expand to 
'polityczn', and won't have to do a backspace after expansion. However, when 
expanded with any punctuation mark, the mark will be set normally, for example 
myverylonglongword. <+>. I use this at an individual abbrev level, so that 
Union Européenne will be expanded normally when hitting space, and 'européen' 
will be expanded so that I can add properly my 's' or 'nes' or so on.
Here is the function

(defun conditional-abbrev-expand ()
"Abbrev expand depends on last keystroke.
If it is a space, the abbrev is expanded without space
insertion. This allows to add suffixes. Punctation marks expand
abbrev and space are inserted."
;check that last stroke was a 'space'
(when (equal last-input-event ?\s)
;if last stroke was a space, move mark to the left
(char-left)))

Examples taken from my abbrev-tabble:

(define-abbrev global-abbrev-table "eurce" "Europe du Centre-Est")
(define-abbrev global-abbrev-table "euré" "européen" 'conditional-abbrev-expand)
(define-abbrev global-abbrev-table "eurp" "Europe")

Is works, it is very usefull, is it a clean function?

Une messagerie gratuite, garantie à vie et des services en plus, ça vous tente ?
Je crée ma boîte mail www.laposte.net



reply via email to

[Prev in Thread] Current Thread [Next in Thread]