[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Problems with the capitalization in Word Abbreviation Mode
From: |
Andreas Politz |
Subject: |
Re: Problems with the capitalization in Word Abbreviation Mode |
Date: |
Mon, 06 Oct 2008 15:12:14 +0200 |
User-agent: |
Mozilla-Thunderbird 2.0.0.16 (X11/20080724) |
Hans-Christian Mick wrote:
Hello,
I'm writing a paper in German and trying to automaticalliy fix some of
my usual typos by using the Word Abbreviation mode (and I have to
admit that I'm rather new to Emacs...).
I'm having a problem with the capitalization in those abbreviations.
A typo that happens to me rather often is that for example I'm typing
"DAs" instead of "Das" at the beginning of a sentence.
I have tried to define a global abbreviation for that, but now I'm
getting every "das" in the middle of a sentence turned into "Das",
which is not what I wanted of course.
Looking into my abbrev.defs-file, I did not find the abbreviation
"DAs" that I originally had defined, but only a lowercase "das" and I
couldn't change it even by modifying the file directly (I wrote "DAs"
into the file, but then it didn't work anymore at all).
Seems as if I'm always getting a lowercase abbreviation, no matter how
I'm defining my abbreviations.
Could anyone please give me any hint on how to change this behaviour?
Thanks a lot in advance!
I think that's just how abbrevs work. But `define-abbrev' permits a
function to handle abnormal expansions:
(defmacro define-literal-abbrev (table name expansion &optional count
system-flag)
`(define-abbrev ,table ,(downcase name) 'literal-abbrev
(lambda ()
(let (case-fold-search
(start (- (point) ,(length name))))
(when (looking-back (regexp-quote ,name) start)
(delete-region start (point))
(insert ,expansion))))
,count ,system-flag))
(define-literal-abbrev global-abbrev-table "DAs" "Das")
...and save the abbrev-table.
-ap