* [patch] weird dabbrev expansion
@ 2003-09-08 19:36 Paul Pogonyshev
0 siblings, 0 replies; only message in thread
From: Paul Pogonyshev @ 2003-09-08 19:36 UTC (permalink / raw)
This patch fixes the following problem: when trying to expand say
"$_S" for "$_SERVER" in PHP, dabbrev expands to "$_server" instead.
The same can be seen when expanding "_M" for "_MATH_H" in C or
expanding "$" to "$_GET" in PHP - in all cases the case of letters is
lost.
After having written the patch i looked at `dabbrev-case-fold-search'
help and discovered that setting it to nil gives even better results.
But still this patch seems like a right thing to do. Some programming
languages are case-insensitive.
Paul Pogonyshev
2003-09-08 Paul Pogonyshev <pogonyshev@gmx.net>
* dabbrev.el (dabbrev--substitute-expansion): Fix a bug which lead
to loss of case of letters when performing case-insensitive
expansions on certain abbreviations.
--- dabbrev.el.~1.71.~ 2003-09-01 23:53:46.000000000 +0000
+++ dabbrev.el 2003-09-08 19:14:36.000000000 +0000
@@ -891,23 +891,28 @@ to record whether we upcased the expansi
;; 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))
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-09-08 19:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-09-08 19:36 [patch] weird dabbrev expansion Paul Pogonyshev
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.