all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* conditionnal-abbrev-expand
       [not found] <mailman.205.1359997276.6922.help-gnu-emacs@gnu.org>
@ 2013-02-04 18:59 ` damien.thiriet77
  0 siblings, 0 replies; only message in thread
From: damien.thiriet77 @ 2013-02-04 18:59 UTC (permalink / raw)
  To: help-gnu-emacs

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



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-02-04 18:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.205.1359997276.6922.help-gnu-emacs@gnu.org>
2013-02-04 18:59 ` conditionnal-abbrev-expand damien.thiriet77

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.