From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Third Newsgroups: gmane.emacs.devel Subject: Re: bug#1948: confusion and bug in dabbrev.el Date: Sat, 30 Jan 2016 01:01:37 +0000 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1454115710 18107 80.91.229.3 (30 Jan 2016 01:01:50 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 30 Jan 2016 01:01:50 +0000 (UTC) Cc: Peter Tury To: 1948@debbugs.gnu.org, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jan 30 02:01:50 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aPJvB-0000L4-Gs for ged-emacs-devel@m.gmane.org; Sat, 30 Jan 2016 02:01:49 +0100 Original-Received: from localhost ([::1]:37176 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aPJv7-0003oH-UB for ged-emacs-devel@m.gmane.org; Fri, 29 Jan 2016 20:01:45 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53554) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aPJv4-0003oA-Bl for emacs-devel@gnu.org; Fri, 29 Jan 2016 20:01:43 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aPJv3-0006ps-1N for emacs-devel@gnu.org; Fri, 29 Jan 2016 20:01:42 -0500 Original-Received: from mail-wm0-x236.google.com ([2a00:1450:400c:c09::236]:33671) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aPJv2-0006pU-Nm for emacs-devel@gnu.org; Fri, 29 Jan 2016 20:01:40 -0500 Original-Received: by mail-wm0-x236.google.com with SMTP id l66so3436133wml.0 for ; Fri, 29 Jan 2016 17:01:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=s9XhVmzp4CY3A+DDRI1ZXAr0eub4ybhwHwmrmqEl8wk=; b=M24XUxTKi1YAfzaY6D4Zofqh3kRvY8cSoa8+Dn7lbDMQJYYIH8Z1hCnFyZu7c5o+Gg JcMEDmSn13858bxIMClgvE2A7w6SgwXpzIUAKwvRSBZu82iW14zRt7HqbhAAs2VlzRXr bTw2+wF3HwEj95SdZh+TYlg0eLReQaeG89nshAU3oXmTSbm0HtNzjOtFuiQT9gMsHbwl RuM/51PmEXtbg473oBqCRNo2Er9vcVzCpLnW3u33YXfrtkyvlfpWG8fLNst4sMeT5daF ArsO1fse/muB24+PwH+lxvMANZmipF3NbY9sfNXoL2DHtWtR85IgqQtkZPeqYS/jIEYK v6ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version:content-type; bh=s9XhVmzp4CY3A+DDRI1ZXAr0eub4ybhwHwmrmqEl8wk=; b=jDbuTHVJpj2vF9xQmFGO7l1pjLHvFnLfQ/6slhs35OzbXoEAMGG1JpcoS8bBTczde1 cl/cOON/KiRsE9OM8qSkL9x9EvzG5IaqyxYErhAz+MMfdjvx/CQbpIksbHhLmjhREW1j mdl6ibvE+7MmnKMveUqdKM7LVdsR3/t2ltJljbEYOTJkeWXwey4bsGHIFn641fp5w9Gg MypwYyWwwZl8DTOy/5WGhn2OieZL3I9ogOg6UBrX7ONQO0TAQTm7RqNySnIgkjd/DYuY wAqar1on2kSODBRdN2a9vr6ZVxrXbE97+5HPneJ2bhxELJDRbc44vQwAdXFle4GIeZgj Ui8g== X-Gm-Message-State: AG10YOTGf9DI4MAvN4YDlXepZlQ+JmvBFmRg3w/p1Eci+plXy4Li01rMPYYid0oBVfAySQ== X-Received: by 10.28.156.198 with SMTP id f189mr257700wme.25.1454115699757; Fri, 29 Jan 2016 17:01:39 -0800 (PST) Original-Received: from galloway.idiocy.org (4.3.6.0.e.6.e.9.d.a.b.c.f.e.1.2.9.2.1.8.8.f.3.0.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:3f8:8129:21ef:cbad:9e6e:634]) by smtp.gmail.com with ESMTPSA id q129sm273411wmd.14.2016.01.29.17.01.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Jan 2016 17:01:38 -0800 (PST) In-Reply-To: (Alan J. Third's message of "Sun, 10 Jan 2016 13:41:38 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (darwin) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::236 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:199015 Archived-At: --=-=-= Content-Type: text/plain Peter Tury said: > However, the more serious problem is that it "forgets" such > eliminations when it searches for `old' expansion in case of repeated > calls of `dabbrev-expand' (i.e. when the check "(eq last-command > this-command)" in this function results t) what results in weird text > in some cases. I think I've got a fix for this. The problem is that dabbrev--substitute-expansion alters EXPANSION before using it in the substitution, but dabbrev-expand has no idea that it's done this, so it assumes the unaltered EXPANSION is still valid and saves it. The patch makes dabbrev--substitute-expansion return EXPANSION, and dabbrev-expand saves that version instead. I considered making a new function to remove the whitespace and using it in both dabbrev-expand and dabbrev--substitute-expansion, but returning the value actually used strikes me as safer, in case anything else is done to it. --=-=-= Content-Type: text/plain Content-Disposition: inline; filename=0001-Always-save-the-actual-expansion.patch Content-Description: save actual expansion >From 9ef22a911d58f772265bc1fde2608ea135a4dea2 Mon Sep 17 00:00:00 2001 From: Alan Third Date: Sat, 30 Jan 2016 00:38:32 +0000 Subject: [PATCH] Always save the actual expansion lisp/dabbrev.el (dabbrev--substitute-expansion): Return EXPANSION after any processing. lisp/dabbrev.el (dabbrev-expand): Set EXPANSION to the return value of DABBREV--SUBSTITUTE-EXPANSION. --- lisp/dabbrev.el | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lisp/dabbrev.el b/lisp/dabbrev.el index 3557041..d9f36b1 100644 --- a/lisp/dabbrev.el +++ b/lisp/dabbrev.el @@ -546,8 +546,8 @@ dabbrev-expand (copy-marker dabbrev--last-expansion-location))) ;; Success: stick it in and return. (setq buffer-undo-list (cons orig-point buffer-undo-list)) - (dabbrev--substitute-expansion old abbrev expansion - record-case-pattern) + (setq expansion (dabbrev--substitute-expansion old abbrev expansion + record-case-pattern)) ;; Save state for re-expand. (setq dabbrev--last-expansion expansion) @@ -902,7 +902,9 @@ dabbrev--substitute-expansion ;; and (2) the replacement itself is all lower case. (dabbrev--safe-replace-match expansion (not use-case-replace) - t))) + t)) + ;; Return the expansion actually used. + expansion) ;;;---------------------------------------------------------------- -- 2.5.4 (Apple Git-61) --=-=-= Content-Type: text/plain -- Alan Third --=-=-=--