emacs-devel
[Top][All Lists]
Advanced

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

[PATCH] Support for case sensitive abbrev expansion


From: Károly Lőrentey
Subject: [PATCH] Support for case sensitive abbrev expansion
Date: Thu, 25 Jul 2002 21:39:12 +0200
User-agent: Gnus/5.090007 (Oort Gnus v0.07) Emacs/21.3.50 (i686-pc-linux-gnu)

I use abbrevs while coding to expand control structure keywords to
whole statement templates.  abbrev-mode saves me huge amounts of
typing, IMHO it's an incredibly useful feature in Emacs.  But there is
one thing that has annoyed me ever since I defined my first source
code abbrev: the case-insensitivity (and, what's more,
case-preservation) of expansions.

Case-preserving is useful in text modes, but in most programming
languages, preserving the case of an abbrev expansion simply does not
make sense.  Even ignoring case differences can lead to unexpected
behavior: for example, JDE defines 'sw' as an abbrev of the Java
keyword 'switch'.  Currently this means that abbrev-mode expands all
of 'sw', 'Sw', 'sW' and 'SW', which is quite annoying while editing
source code written in a case-sensitive language.

This patch adds support for case-sensitive expansion of abbrevs.  A
new variable `abbrev-case-fold' is defined to let the user control
case behavior.  By default, case-sensitivity is inherited from
`case-fold-search'.

I implemented `abbrev-case-fold' as a new primitive buffer-local
variable.  (Buffer-locality is necessary, because IMHO most people
would want to keep the nifty case-preserving behavior in text
buffers.)  This required changes in buffer.c, buffer.h, cus-start.el
and elint.el, in addition to abbrev.c.  The patch includes
documentation updates and a NEWS entry.  If necessary, I am prepared
to sign a copyright assignment.

What do you think?  Is this the right way to do this?

-- Károly Lőrentey


2002-07-25  Károly Lőrentey <address@hidden>
          
        * buffer.h (struct buffer) <abbrev_case_fold>: New buffer-local
        variable.
        
        * buffer.c (Qcase_fold_search): New variable.
        (init_buffer_once): Initialize abbrev_case_fold.
        (syms_of_buffer): Initialize new vars.
        
        * abbrev.c (Qcase_fold_search): New variable.
        (Fdefine_global_abbrev, Fdefine_mode_abbrev): Do not downcase
        abbrev.
        (Fexpand_abbrev): Add support for case-sensitive expansion.
        (syms_of_abbrev): Initialize new vars.

2002-07-25  Károly Lőrentey <address@hidden>

        * cus-start.el: Added abbrev-case-fold.

        * emacs-lisp/elint.el (elint-standard-variables): Added
        abbrev-case-fold.

Attachment: abbrev.patch
Description: Support for case sensitive abbrev expansion


reply via email to

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