summaryrefslogtreecommitdiff
path: root/lisp/dabbrev.el
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>2004-04-21 19:22:52 +0000
committerRichard M. Stallman <rms@gnu.org>2004-04-21 19:22:52 +0000
commite921af9e6c8a773f472719a754344ee6bc453d05 (patch)
tree79f9ec086d4d8298b312f955bbcf433fd6fa2d97 /lisp/dabbrev.el
parent0ce7de922c194ac869a90b55d3d187b6365c444d (diff)
downloademacs-e921af9e6c8a773f472719a754344ee6bc453d05.tar.gz
(dabbrev--substitute-expansion): Fix a bug which lead
to loss of case of letters when performing case-insensitive expansions on certain abbreviations.
Diffstat (limited to 'lisp/dabbrev.el')
-rw-r--r--lisp/dabbrev.el29
1 files changed, 17 insertions, 12 deletions
diff --git a/lisp/dabbrev.el b/lisp/dabbrev.el
index 3763f2ccab8..47ffba9873d 100644
--- a/lisp/dabbrev.el
+++ b/lisp/dabbrev.el
@@ -888,23 +888,28 @@ to record whether we upcased the expansion, downcased it, or did neither."
;; matches the start of the expansion,
;; copy the expansion's case
;; instead of downcasing all the rest.
- ;; Treat a one-capital-letter abbrev as "not all upper case",
- ;; so as to force preservation of the expansion's pattern
- ;; if the expansion starts with a capital letter.
- (let ((expansion-rest (substring expansion 1)))
- (if (and (not (and (or (string= expansion-rest (downcase expansion-rest))
- (string= expansion-rest (upcase expansion-rest)))
- (or (string= abbrev (downcase abbrev))
- (and (string= abbrev (upcase abbrev))
- (> (length abbrev) 1)))))
- (string= abbrev
- (substring expansion 0 (length abbrev))))
+ ;;
+ ;; Treat a one-capital-letter (possibly with preceding non-letter
+ ;; characters) abbrev as "not all upper case", so as to force
+ ;; preservation of the expansion's pattern if the expansion starts
+ ;; with a capital letter.
+ (let ((expansion-rest (substring expansion 1))
+ (first-letter-position (string-match "[[:alpha:]]" abbrev)))
+ (if (or (null first-letter-position)
+ (and (not (and (or (string= expansion-rest (downcase expansion-rest))
+ (string= expansion-rest (upcase expansion-rest)))
+ (or (string= abbrev (downcase abbrev))
+ (and (string= abbrev (upcase abbrev))
+ (> (- (length abbrev) first-letter-position)
+ 1)))))
+ (string= abbrev
+ (substring expansion 0 (length abbrev)))))
(setq use-case-replace nil)))
;; If the abbrev and the expansion are both all-lower-case
;; then don't do any conversion. The conversion would be a no-op
;; for this replacement, but it would carry forward to subsequent words.
- ;; The goal of this is to preven that carrying forward.
+ ;; The goal of this is to prevent that carrying forward.
(if (and (string= expansion (downcase expansion))
(string= abbrev (downcase abbrev)))
(setq use-case-replace nil))