From unknown Sun Jun 15 08:46:31 2025 X-Loop: help-debbugs@gnu.org Subject: bug#9038: 24.0.50; limit expand-abbrev in viper mode state change 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: Sat, 09 Jul 2011 17:11:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 9038 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 9038@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.131023140620225 (code B ref -1); Sat, 09 Jul 2011 17:11:01 +0000 Received: (at submit) by debbugs.gnu.org; 9 Jul 2011 17:10:06 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Qfb2b-0005G9-T5 for submit@debbugs.gnu.org; Sat, 09 Jul 2011 13:10:06 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Qfb2Y-0005Fd-RD for submit@debbugs.gnu.org; Sat, 09 Jul 2011 13:10:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qfb2R-0000yC-Oi for submit@debbugs.gnu.org; Sat, 09 Jul 2011 13:09:57 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, T_DKIM_INVALID, T_TO_NO_BRKTS_FREEMAIL autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([140.186.70.17]:40449) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qfb2R-0000y8-Lb for submit@debbugs.gnu.org; Sat, 09 Jul 2011 13:09:55 -0400 Received: from eggs.gnu.org ([140.186.70.92]:34457) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qfb2Q-0005K7-AM for bug-gnu-emacs@gnu.org; Sat, 09 Jul 2011 13:09:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qfb2O-0000xd-T9 for bug-gnu-emacs@gnu.org; Sat, 09 Jul 2011 13:09:54 -0400 Received: from mail-vw0-f41.google.com ([209.85.212.41]:56115) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qfb2O-0000xY-QN for bug-gnu-emacs@gnu.org; Sat, 09 Jul 2011 13:09:52 -0400 Received: by vws4 with SMTP id 4so2552705vws.0 for ; Sat, 09 Jul 2011 10:09:52 -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=fXX1oqxxqpBTDkvymrW8EFr2tdOUGXj4aU+wiwdW0UA=; b=h1RgUoS4pHdNcqhpt0yp6qexnXvpuPIv5psADe2ikU8HboGIswNxF2MbLHdY7f+U61 lDyHeYnt6qCxodEdh+A6jHS7o/aizI0drMjJtCn7tsbyS2vfl2CT5rl4EYLvIzU7/rH5 IaG4O722RfR58Ba/+gvtigDs2O8GN7yjLk6Ns= MIME-Version: 1.0 Received: by 10.52.22.39 with SMTP id a7mr3697063vdf.73.1310231392118; Sat, 09 Jul 2011 10:09:52 -0700 (PDT) Received: by 10.52.184.34 with HTTP; Sat, 9 Jul 2011 10:09:52 -0700 (PDT) Date: Sat, 9 Jul 2011 11:09:52 -0600 Message-ID: From: Bob Nnamtrop Content-Type: text/plain; charset=ISO-8859-1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.17 X-Spam-Score: -4.9 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.9 (----) Changing from viper insert state to vi state (called "changing state" below for brevity) causes expand-abbrev to run if abbrev's are turned on. This is good but I think the rule for if an abbrev is expanded should agree with the rule in self-insert-command when in insert mode. Thus "changing state" should only attempt to expand abbrev if and only if the previous char has word syntax. This is easily achieved with the following patch (against trunk): === modified file 'lisp/emulation/viper-cmd.el' --- lisp/emulation/viper-cmd.el 2011-05-23 17:57:17 +0000 +++ lisp/emulation/viper-cmd.el 2011-07-09 16:20:55 +0000 @@ -617,7 +617,8 @@ (or (viper-overlay-p viper-replace-overlay) (viper-set-replace-overlay (point-min) (point-min))) (viper-hide-replace-overlay) - (if abbrev-mode (expand-abbrev)) + (if (and abbrev-mode (eq (char-syntax (preceding-char)) ?w)) + (expand-abbrev)) (if (and auto-fill-function (> (current-column) fill-column)) (funcall auto-fill-function)) ;; don't leave whitespace lines around More detail: The reason I want this is because with the present behavior abbrev's often get run multiple times which can be very annoying. For example, in idlwave mode if I type in an "if ... endif" block, when I hit return after the endif the endif is caught as a abbrev which causes its hook to run (which moves the point to the corresponding begin and back). Now if I hit escape to change state the abbrev is caught again and the hook runs again. This occurs even though typing a non-word char would NOT have caused expand-abbrev to run. If I go back to insert mode and type any number of non-word char (including returns) and go back to vi mode this will happen again. Very annoying behavior. As stated, the "changing state" behavior will run expand-abbrev even if the point is many lines below the line with the abbrev. In emacs 23.1 and before, "changing state" would only run expand-abbrev if the abbrev was on the same line. This behavior changed in revision 98777 on 2009-11-25 which changed abbrev--before-point (and thus expand-abbrev) and made it jump up arbitrary number of lines to find a abbrev (note that if the abbrev-table has a re for the abbrev the behavior is the same as the old behavior of staying on one line). The doc-string for expand-abbrev says "Expand the abbrev before point, if there is an abbrev there". The "before point" is a bit ambiguous but to me it implies directly before point and not 10 lines up! I mention this because the "changing state" behavior got much more annoying after this revision since expand-abbrev was no longer bound to the line that point was on. Thanks, Bob From unknown Sun Jun 15 08:46:31 2025 X-Loop: help-debbugs@gnu.org Subject: bug#9038: 24.0.50; limit expand-abbrev in viper mode state change Resent-From: Chong Yidong Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 09 Jul 2011 19:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 9038 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Bob Nnamtrop Cc: 9038@debbugs.gnu.org Received: via spool by 9038-submit@debbugs.gnu.org id=B9038.131023997511033 (code B ref 9038); Sat, 09 Jul 2011 19:33:02 +0000 Received: (at 9038) by debbugs.gnu.org; 9 Jul 2011 19:32:55 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QfdGo-0002ru-JS for submit@debbugs.gnu.org; Sat, 09 Jul 2011 15:32:54 -0400 Received: from vm-emlprdomr-05.its.yale.edu ([130.132.50.146]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QfdGm-0002rh-Un for 9038@debbugs.gnu.org; Sat, 09 Jul 2011 15:32:53 -0400 Received: from furball ([64.134.100.161]) (authenticated bits=0) by vm-emlprdomr-05.its.yale.edu (8.14.4/8.14.4) with ESMTP id p69JWkAA006583 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Sat, 9 Jul 2011 15:32:47 -0400 From: Chong Yidong References: Date: Sat, 09 Jul 2011 15:32:46 -0400 In-Reply-To: (Bob Nnamtrop's message of "Sat, 9 Jul 2011 11:09:52 -0600") Message-ID: <87r55zw8pt.fsf@stupidchicken.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.71 on 130.132.50.146 X-Spam-Score: -2.6 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) Bob Nnamtrop writes: > Changing from viper insert state to vi state (called "changing state" > below for brevity) causes expand-abbrev to run if abbrev's are turned > on. This is good but I think the rule for if an abbrev is expanded > should agree with the rule in self-insert-command when in insert mode. > Thus "changing state" should only attempt to expand abbrev if and only > if the previous char has word syntax. This is easily achieved with the > following patch (against trunk): Looks reasonable; checked into trunk. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 09 15:33:05 2011 Received: (at control) by debbugs.gnu.org; 9 Jul 2011 19:33:06 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QfdGy-0002sc-S7 for submit@debbugs.gnu.org; Sat, 09 Jul 2011 15:33:05 -0400 Received: from vm-emlprdomr-05.its.yale.edu ([130.132.50.146]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QfdGx-0002s4-HZ for control@debbugs.gnu.org; Sat, 09 Jul 2011 15:33:03 -0400 Received: from furball ([64.134.100.161]) (authenticated bits=0) by vm-emlprdomr-05.its.yale.edu (8.14.4/8.14.4) with ESMTP id p69JWvw2006636 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT) for ; Sat, 9 Jul 2011 15:32:58 -0400 From: Chong Yidong To: control@debbugs.gnu.org Subject: close 9038 Date: Sat, 09 Jul 2011 15:32:57 -0400 Message-ID: <878vs7jlli.fsf@stupidchicken.com> MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.71 on 130.132.50.146 X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) close 9038 thanks