From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id iLfuNXvuLmQwPQEASxT56A (envelope-from ) for ; Thu, 06 Apr 2023 18:08:27 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id 0M/oNXvuLmQtZwEA9RJhRA (envelope-from ) for ; Thu, 06 Apr 2023 18:08:27 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 9B8E137E82 for ; Thu, 6 Apr 2023 18:08:27 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pkS9L-0007ku-V0; Thu, 06 Apr 2023 12:07:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pjP1a-0003En-99 for emacs-orgmode@gnu.org; Mon, 03 Apr 2023 14:35:26 -0400 Received: from mxout6.mail.janestreet.com ([64.215.233.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pjP1Y-0001gG-Lc for emacs-orgmode@gnu.org; Mon, 03 Apr 2023 14:35:26 -0400 From: Aaron Zeng To: emacs-orgmode@gnu.org Cc: app-emacs-dev@janestreet.com Subject: [PATCH] Fix bug in orgtbl-self-insert-command when used with evil-escape Date: Mon, 03 Apr 2023 14:35:23 -0400 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=64.215.233.21; envelope-from=azeng@janestreet.com; helo=mxout6.mail.janestreet.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 06 Apr 2023 12:07:46 -0400 X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1680797307; a=rsa-sha256; cv=none; b=KILZpAuoembfdc8hB8XXP8bFPchAMvz8pfW8YKCq78Fe/Ygt8SYi6snJEnNFyaVz1rnAWG k/Pcrupank4hHlc0BrF/EluOgttTiqW7X8AoVrT8mlpejVxaMJMnRH3Ht4Cmo4d4EVnBon YCmJX/fydQvp8+oqD/Us6XsPzrYzymFYIEUMCQRfgAHK8X44BJuCSp7mABN52iU76Qygq8 QSNW40jsVwvVlxFUMOAot0k307mhGEwAwR3OTryxOkc5gJTQTAKRmx7cml0ansxmEtKF2Z EYh64B1aGQnOG8ZArAdXGWom3WDF3m+Sk/aSbDmDjAEIQc+49Y29sylo+NekbA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=janestreet.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1680797307; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=stcjAyPhQJD5o3dFEGpgjeoXouNwRoLY7ft3y5SbedA=; b=cFp6lAYiYKWBPKE8QK05Vr5UMp0NLtNHU0qE4mMEbaWxpKlx1mKIabdXpAcjzgqOP8oywI JK6/DW8isx98VBMtJhsMu7n7fqHETiPVA5PP/u4aF58V/kTQQa1sVfQXBaBclI9Ufu4yyS Au12gy5Q2Dhj1RrGOjELu+jWPm9rsViJbDrPFmTWT8ByhPJ+FUcC5s/Yi19EmU+YiwkY74 naaODEjLmCfGn2MF4UDO8i8E4t3OnTQL8qRkwy8iwIKBxdbdgiBHvhIpCGN6FRAVOWyl8z WobyhpLn1G3nBtmf5IC5gjmhhnpDF4cBriXJgvtK0GeDNRyniZuNaXiKpJ09fw== X-Migadu-Spam-Score: 2.98 X-Migadu-Scanner: scn1.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=janestreet.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Spam-Score: 2.98 X-Migadu-Queue-Id: 9B8E137E82 X-TUID: Op8a6BM6lalO --=-=-= Content-Type: text/plain There appears to be a bug in orgtbl-self-insert-command, which uses last-input-event instead of last-command-event. self-insert-command itself uses the latter variable. Reproduction steps: 1. Enable evil-mode and evil-escape-mode 2. Set `evil-escape-key-sequence' to "fd" (the default) 3. In an empty text-mode buffer with orgtbl-mode enabled: a. Press `f RET' slowly; this inserts f and then a newline b. Press `f RET` quickly; this inserts just two newlines After step 3b, view-lossage contains: f ;; orgtbl-self-insert-command ;; orgtbl-hijacker-command-100 With the patch, the above steps correctly insert f and then a newline. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-org-table-Refactor-away-unnecessary-variable.patch >From 8ae98a51a15bdd4d4c2014e7870ab36afd03562d Mon Sep 17 00:00:00 2001 From: "Aaron L. Zeng" Date: Mon, 3 Apr 2023 13:46:26 -0400 Subject: [PATCH 1/2] org-table: Refactor away unnecessary variable * org-table.el (orgtbl-self-insert-command): Remove unnecessary intermediate variable. `(cdr nil)` is nil. TINYCHANGE --- lisp/org-table.el | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lisp/org-table.el b/lisp/org-table.el index 97120fffd..f477d74a0 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -5408,11 +5408,9 @@ overwritten, and the table is not marked as requiring realignment." (self-insert-command N)) (setq org-table-may-need-update t) (let* (orgtbl-mode - a (cmd (or (key-binding (or (and (listp function-key-map) - (setq a (assoc last-input-event function-key-map)) - (cdr a)) + (cdr (assoc last-input-event function-key-map))) (vector last-input-event))) 'self-insert-command))) (call-interactively cmd) -- 2.30.2 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0002-org-table-Fix-incorrect-input-when-used-with-evil-es.patch >From 4ca188a09c2f628a03b5731b1725bd603620227a Mon Sep 17 00:00:00 2001 From: "Aaron L. Zeng" Date: Mon, 3 Apr 2023 13:53:57 -0400 Subject: [PATCH 2/2] org-table: Fix incorrect input when used with evil-escape * org-table.el (org-self-insert-command): Use `last-command-event' instead of `last-input-event'. Using `last-input-event' causes problems in the presence of `evil-escape'. Consider a buffer that has `orgtbl-mode' enabled while evil-escape is in use. Assume the evil-escape sequence is "fd". Typing "f RET" will instead insert "RET RET" into the buffer, since `last-input-event' is "RET", but `last-command-event' is "f". TINYCHANGE --- lisp/org-table.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/org-table.el b/lisp/org-table.el index f477d74a0..e0cc84ed6 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -5410,8 +5410,8 @@ overwritten, and the table is not marked as requiring realignment." (let* (orgtbl-mode (cmd (or (key-binding (or (and (listp function-key-map) - (cdr (assoc last-input-event function-key-map))) - (vector last-input-event))) + (cdr (assoc last-command-event function-key-map))) + (vector last-command-event))) 'self-insert-command))) (call-interactively cmd) (if (and org-self-insert-cluster-for-undo -- 2.30.2 --=-=-=--