From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Bob Nnamtrop Newsgroups: gmane.emacs.bugs Subject: bug#5805: 23.3 abbrev-insert needs a limited save-excursion Date: Thu, 7 Jul 2011 08:48:36 -0600 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: dough.gmane.org 1310051786 29318 80.91.229.12 (7 Jul 2011 15:16:26 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 7 Jul 2011 15:16:26 +0000 (UTC) To: 5805@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jul 07 17:16:21 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QeqJQ-0004er-UM for geb-bug-gnu-emacs@m.gmane.org; Thu, 07 Jul 2011 17:16:21 +0200 Original-Received: from localhost ([::1]:50686 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QeqJP-0007gc-KX for geb-bug-gnu-emacs@m.gmane.org; Thu, 07 Jul 2011 11:16:19 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:52118) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qept4-0000Hw-90 for bug-gnu-emacs@gnu.org; Thu, 07 Jul 2011 10:49:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qept0-00082B-UK for bug-gnu-emacs@gnu.org; Thu, 07 Jul 2011 10:49:05 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:55551) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qept0-000822-M4 for bug-gnu-emacs@gnu.org; Thu, 07 Jul 2011 10:49:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1Qepsz-0006tA-QV; Thu, 07 Jul 2011 10:49:01 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: Bob Nnamtrop Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 07 Jul 2011 14:49:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 5805 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 5805-submit@debbugs.gnu.org id=B5805.131005012426457 (code B ref 5805); Thu, 07 Jul 2011 14:49:01 +0000 Original-Received: (at 5805) by debbugs.gnu.org; 7 Jul 2011 14:48:44 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Qepsh-0006sg-Mm for submit@debbugs.gnu.org; Thu, 07 Jul 2011 10:48:43 -0400 Original-Received: from mail-vx0-f172.google.com ([209.85.220.172]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Qepsg-0006sU-7p for 5805@debbugs.gnu.org; Thu, 07 Jul 2011 10:48:42 -0400 Original-Received: by vxi40 with SMTP id 40so728587vxi.3 for <5805@debbugs.gnu.org>; Thu, 07 Jul 2011 07:48:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; bh=7clhw2PgHRKhs2YedSir5K1E00+xw7gqjD0LdhZKUps=; b=O5Py+swzyoZm/uXQYcSZmbpb8cz7QtKogZC+/F2lbLheDBUFxnOP+z3QLsraYq6vQl E/ZOaOz3PSn8qr/2vazR38q+LVIRMtkDQTvJLYVNbFizldNlnKB/Bk3Ly9fiLvNqAnG8 LT4RpsKVDbcNZv3bMw1ROy8lFqQMFQXk9LAko= Original-Received: by 10.52.108.231 with SMTP id hn7mr1195458vdb.283.1310050116782; Thu, 07 Jul 2011 07:48:36 -0700 (PDT) Original-Received: by 10.52.184.34 with HTTP; Thu, 7 Jul 2011 07:48:36 -0700 (PDT) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Thu, 07 Jul 2011 10:49:01 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.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:48162 Archived-At: I agree with the original poster that a save-excursion is needed in abbrev-expand and by making its scope limited (see below) it will not interfere with abbrevs that want to change point. The reason I find it annoying the way it is now is that some modes (e.g., idlwave) use abbrev's extensively to change keywords (e.g. capitalize them). These are defined without the leading "\". So if I am any number of lines with only whitespace below a keyword defined in this way (e.g. endfor) and run expand-abbrev then the point moves even if no visible change takes place. This is a VERY common occurrence for me since in viper mode changing from insert to vi mode runs expand-abbrev! Placing the save-excursion just around the part of abbrev-insert that actually expands the abbrev fixes this problem and does not limit abbrev's from moving the point (idlwave does this extensively as well and I've tested that it is not impacted). Here is the diff against the abbrev.el in emacs 23.3 (note that whitespace not adjusted). Thanks much, Bob --- 23.3/abbrev.el 2011-07-07 08:16:16.000000000 -0600 +++ 23.3.fix/abbrev.el 2011-07-07 08:43:24.000000000 -0600 @@ -713,6 +713,7 @@ ;; If this abbrev has an expansion, delete the abbrev ;; and insert the expansion. (when (stringp (symbol-value abbrev)) + (save-excursion (goto-char wordstart) ;; Insert at beginning so that markers at the end (e.g. point) ;; are preserved. @@ -741,7 +742,7 @@ (skip-syntax-forward "^w" (1- end)) ;; Change just that. (upcase-initials-region (point) (1+ (point))) - (goto-char end)))))) + (goto-char end))))))) ;; Now point is at the end of the expansion and the beginning is ;; in last-abbrev-location. (when (symbol-function abbrev)