From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Third Newsgroups: gmane.emacs.bugs Subject: 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 1454115742 18430 80.91.229.3 (30 Jan 2016 01:02:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 30 Jan 2016 01:02:22 +0000 (UTC) Cc: Peter Tury To: 1948@debbugs.gnu.org, emacs-devel@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jan 30 02:02:12 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1aPJvY-0000t3-4r for geb-bug-gnu-emacs@m.gmane.org; Sat, 30 Jan 2016 02:02:12 +0100 Original-Received: from localhost ([::1]:37179 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aPJvX-0004FL-IB for geb-bug-gnu-emacs@m.gmane.org; Fri, 29 Jan 2016 20:02:11 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53999) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aPJvT-0004E0-7E for bug-gnu-emacs@gnu.org; Fri, 29 Jan 2016 20:02:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aPJvO-0007A2-Pd for bug-gnu-emacs@gnu.org; Fri, 29 Jan 2016 20:02:07 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:52661) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aPJvO-00079u-Mh for bug-gnu-emacs@gnu.org; Fri, 29 Jan 2016 20:02:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1aPJvO-0004dB-Hj for bug-gnu-emacs@gnu.org; Fri, 29 Jan 2016 20:02:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Third Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 30 Jan 2016 01:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 1948 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Original-Received: via spool by 1948-submit@debbugs.gnu.org id=B1948.145411570717779 (code B ref 1948); Sat, 30 Jan 2016 01:02:02 +0000 Original-Received: (at 1948) by debbugs.gnu.org; 30 Jan 2016 01:01:47 +0000 Original-Received: from localhost ([127.0.0.1]:40881 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aPJv9-0004ch-7V for submit@debbugs.gnu.org; Fri, 29 Jan 2016 20:01:47 -0500 Original-Received: from mail-wm0-f51.google.com ([74.125.82.51]:36265) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aPJv7-0004cP-9W for 1948@debbugs.gnu.org; Fri, 29 Jan 2016 20:01:45 -0500 Original-Received: by mail-wm0-f51.google.com with SMTP id p63so1844896wmp.1 for <1948@debbugs.gnu.org>; Fri, 29 Jan 2016 17:01:45 -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=IlyGbxyWbhLdPp8zu9MoF3smtmAtMKWepC/s0BAttNhgxBzXqB03611MKwoVm65+ml y3y8s76kOFQsZKBK13KnbMKqEitziyKkwIcMXC2csOMkNvYG02MkvIDbLSPBkGAukhm1 xxMQ5//vKSeHYP9x61Kmvvc/j1tVpJq4WSLJaAkaiLJt55VuKB8uu6GS4puvQ3VncwU/ Uf62x5GqWap1JHxv17/OJhhJdrAeCQYbmSauRyh3UjDT0ul1luxXdLHG5N6lVHxsMztT Q+uRFBrOg9jVtFfAMcBPhNEzkSHgwJCefFGIFVuOn6b/5UUItA7aIKa2MBFOvDdDF6UR TNDw== X-Gm-Message-State: AG10YOTbQb0/kfyQWyJq6pSRSWlh7OrplQy+ZcVl//JlBmbuNGhVZzDS2jeuyk7EGuu6ew== 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:112092 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 --=-=-=--