From: "damien.thiriet77" <damien.thiriet77@laposte.net>
To: help-gnu-emacs@gnu.org
Subject: conditionnal-abbrev-expand
Date: Mon, 04 Feb 2013 19:59:22 +0100 [thread overview]
Message-ID: <1409032162.446172.1360004362602.JavaMail.www@wwinf8229> (raw)
In-Reply-To: <mailman.205.1359997276.6922.help-gnu-emacs@gnu.org>
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
parent reply other threads:[~2013-02-04 18:59 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <mailman.205.1359997276.6922.help-gnu-emacs@gnu.org>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1409032162.446172.1360004362602.JavaMail.www@wwinf8229 \
--to=damien.thiriet77@laposte.net \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.