From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#62626: 29.0.60; describe-key errors on Edit =?UTF-8?Q?=E2=86=92?= Paste from Kill Ring =?UTF-8?Q?=E2=86=92?= [any item] Date: Thu, 06 Apr 2023 14:47:58 +0300 Message-ID: <83cz4hqljl.fsf@gnu.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13842"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 62626@debbugs.gnu.org To: Spencer Baugh , Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Apr 06 13:48:33 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pkO6T-0003NK-3i for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 06 Apr 2023 13:48:33 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pkO61-0003UG-4Y; Thu, 06 Apr 2023 07:48:05 -0400 Original-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 1pkO5z-0003Tf-6m for bug-gnu-emacs@gnu.org; Thu, 06 Apr 2023 07:48:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pkO5y-0005yZ-Tu for bug-gnu-emacs@gnu.org; Thu, 06 Apr 2023 07:48:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pkO5y-00075S-Kz for bug-gnu-emacs@gnu.org; Thu, 06 Apr 2023 07:48:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 06 Apr 2023 11:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62626 X-GNU-PR-Package: emacs Original-Received: via spool by 62626-submit@debbugs.gnu.org id=B62626.168078166227194 (code B ref 62626); Thu, 06 Apr 2023 11:48:02 +0000 Original-Received: (at 62626) by debbugs.gnu.org; 6 Apr 2023 11:47:42 +0000 Original-Received: from localhost ([127.0.0.1]:53597 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pkO5d-00074T-MG for submit@debbugs.gnu.org; Thu, 06 Apr 2023 07:47:42 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:41838) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pkO5b-000743-Lw for 62626@debbugs.gnu.org; Thu, 06 Apr 2023 07:47:40 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pkO5S-0005tr-LR; Thu, 06 Apr 2023 07:47:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=aK4IMesQ58nFdT6ouWiBRdn9o+1EeY2bcXfKubtRchs=; b=GcdJAN/o7GG/C44uNII9 iZ7OTDAO5JnrrKcDkICR4rcqYsFSjsijp6DL3EqtM+HEaakennrU7lpUykoaf92q6GRUd+ochJXEL FQrIECDQeoPrx9U2ryqQOw3cdRvzmW576GJ6uL9DDg3mLEH+Ya9ye5shvIglTtI4pNexcm7kM93Uz QJoG3kOx5P1Ta8FYNEfIbIc+OP72zakW1UO+VkhVwZQstxvDgrG05k1zSgDqI3A1A+axq4YymOOyM o6qawknWYptN4AJxTktBGtQbZaBbZ03hwbk/7WGJ9C+hxwp9hHpghepT4VGdMsq1EoQIbPPyvKXPp m8wlhmMf+FVXGQ==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pkO5R-0001ju-OX; Thu, 06 Apr 2023 07:47:30 -0400 In-Reply-To: (message from Spencer Baugh on Sun, 02 Apr 2023 14:49:41 -0400) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:259317 Archived-At: > From: Spencer Baugh > Date: Sun, 02 Apr 2023 14:49:41 -0400 > > > 1. emacs -Q > 2. C-h k and in the menu bar, click on "Edit", then "Paste from Kill > Menu", then "(any string)". > 3. See error printed in *Messages*: > event-basic-type: Wrong type argument: integer-or-marker-p, "(any string)" > 4. Type "foobar" and kill it > 5. C-h k and in the menu bar, click on "Edit", then "Paste from Kill > Menu", then "foobar". > 6. See error printed in *Messages*: > event-basic-type: Wrong type argument: integer-or-marker-p, #("foobar" 0 6 (fontified t)) > > This happens on both Emacs 28 and Emacs 29. AFAICT, this has been broken since Emacs 27. > It looks like this is happening because help--read-key-sequence calls > event-basic-type on the last element of the key sequence returned from > read-key-sequence, which in this case is a string. Yes. > The following patch fixes it (that is, makes describe-key complete > successfully and show appropriate help), but I'm not sure if it's right. > > diff --git a/lisp/help.el b/lisp/help.el > index 83be85b1ee4..73ac793f4aa 100644 > --- a/lisp/help.el > +++ b/lisp/help.el > @@ -1021,8 +1021,8 @@ help--read-key-sequence > (raw-seq (this-single-command-raw-keys)) > (keyn (when (> (length seq) 0) > (aref seq (1- (length seq))))) > - (base (event-basic-type keyn)) > - (modifiers (event-modifiers keyn))) > + (base (and (integer-or-marker-p keyn) (event-basic-type keyn))) > + (modifiers (and (integer-or-marker-p keyn) (event-modifiers keyn)))) > (cond > ((zerop (length seq))) ;FIXME: Can this happen? > ((and no-mouse-movement (eq base 'mouse-movement)) nil) Doesn't the above break "C-h c" and "C-h k" for mouse click events? They yield a symbol like down-mouse-1 as KEYN, so are rejected by your proposed condition. I suggest the below instead. I'm just not sure about what to do with RAW-SEQ (which is returned as the cdr of the cons cell value of this function). Emacs 26 returned nil there, so we are "bug-compatible" with it after applying the below. But since this is a general-purpose utility function, perhaps we should return the same value as SEQ there? I mean, what does "untranslated" mean for such "events"? An alternative solution for the original problem would be to teach event-basic-type and event-modifiers about "events" that happen to be strings. Stefan, any comments or better ideas? diff --git a/lisp/help.el b/lisp/help.el index 6eac037..299042f 100644 --- a/lisp/help.el +++ b/lisp/help.el @@ -1012,7 +1012,7 @@ help--read-key-sequence (unwind-protect (let (last-modifiers key-list) ;; If yank-menu is empty, populate it temporarily, so that - ;; "Select and Paste" menu can generate a complete event. + ;; "Paste from Kill Menu" menu can generate a complete event. (when (null (cdr yank-menu)) (setq saved-yank-menu (copy-sequence yank-menu)) (menu-bar-update-yank-menu "(any string)" nil)) @@ -1031,8 +1031,14 @@ help--read-key-sequence (raw-seq (this-single-command-raw-keys)) (keyn (when (> (length seq) 0) (aref seq (1- (length seq))))) - (base (event-basic-type keyn)) - (modifiers (event-modifiers keyn))) + ;; The "Paste from Kill Menu" menu-bar item has the + ;; text-to-yank, a string, as its last "event" + ;; component, and those are not supported by + ;; 'event-basic-type' and 'event-modifiers'. + (str-from-menu (stringp keyn)) + (base (and (not str-from-menu) (event-basic-type keyn))) + (modifiers (and (not str-from-menu) + (event-modifiers keyn)))) (cond ((zerop (length seq))) ;FIXME: Can this happen? ((and no-mouse-movement (eq base 'mouse-movement)) nil)