From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Basil Contovounesios via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#63552: 29.0.91; M-x completion-predicate does not account for python-ts-mode Date: Wed, 17 May 2023 13:59:48 +0100 Message-ID: <87pm6z8663.fsf@tcd.ie> References: <87353vrx4f.fsf@tcd.ie> <83h6sbxhb0.fsf@gnu.org> Reply-To: Basil Contovounesios Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3958"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 63552@debbugs.gnu.org, arstoffel@gmail.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed May 17 15:00:22 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 1pzGlR-0000r2-PG for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 17 May 2023 15:00:21 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzGlH-0006ss-Ux; Wed, 17 May 2023 09:00:13 -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 1pzGl8-0006sJ-TN for bug-gnu-emacs@gnu.org; Wed, 17 May 2023 09:00: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 1pzGl8-00063w-HP for bug-gnu-emacs@gnu.org; Wed, 17 May 2023 09:00:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pzGl8-0005nP-CF for bug-gnu-emacs@gnu.org; Wed, 17 May 2023 09:00:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Basil Contovounesios Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 17 May 2023 13:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63552 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 63552-submit@debbugs.gnu.org id=B63552.168432839922244 (code B ref 63552); Wed, 17 May 2023 13:00:02 +0000 Original-Received: (at 63552) by debbugs.gnu.org; 17 May 2023 12:59:59 +0000 Original-Received: from localhost ([127.0.0.1]:49251 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pzGl4-0005mh-Tu for submit@debbugs.gnu.org; Wed, 17 May 2023 08:59:59 -0400 Original-Received: from mail-wr1-f50.google.com ([209.85.221.50]:46341) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pzGl2-0005mR-Je for 63552@debbugs.gnu.org; Wed, 17 May 2023 08:59:57 -0400 Original-Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-3075e802738so720764f8f.1 for <63552@debbugs.gnu.org>; Wed, 17 May 2023 05:59:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd.ie; s=google21; t=1684328391; x=1686920391; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=bnacFNd9rb9u4LIdjvzW89gIhlzgtW5DsPl53x6d2A0=; b=AHcpJ3oEXx6+uMEIxnTWkiO0DqHOwBd81rGgovZ8QMVqfKJWoZsmifU/QDCC7GwEfI hss4MBC7uONSQrfVQytwIIL/+8TMfxwbhDV5ArBGuDGJZSL2Y5+7EvHlAvZknKJ9QGIs M/xwtpd4NtQsl9iGk4cGnkCfCgDeReBXPt3blQEp+5/DnKpHTS+WDd24NDdJNW9q8MP4 GQWPkO6eFNxiVLkE4YprCJh7kiiU/sl+E3BD9AVcAwPt2f/uMO/I9GKc/IfMqHKq/vLa c7lQ+/QX5EBJcetghQrxbCEchfymh7Ksjb3jbtX3buI/e7GEeRHPodiXfbtLyiw/m+LL qZyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684328391; x=1686920391; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=bnacFNd9rb9u4LIdjvzW89gIhlzgtW5DsPl53x6d2A0=; b=D9yTP2fd0gIhQCO7h+SH8Y45XztuD38/9POWZ2byCXlhjkVTr55ssWVKcBJEdkxMXi Z0OCV29zKE7T4oF5abJ+g7sF6Gk1KnMbsV654opRtS3ZnVsgGoHujHetFjGsThu7yncy NLSfdFsO7Hwv9u4zNJmVq0+5NTLKkou++EQz5JMBwyOut4KlpC9oojMPozPSLQxaxdHs CPS4G8aptIY4wWWg7q7xNoq1FpZZGxcEQIPitGRCLM4iZ80oPiNtFWSgu4r74tOIslzT jYNjUIZAapbnGAbZ7/cJ+J8esGcSIOqIBTUGMSqnaIAGF5cyTscsUeYtAy3X5zmlvFlc UKRg== X-Gm-Message-State: AC+VfDwJB9NTxaCtgi/zWJIzd3Cz2az2PtjUOOOH5TsKTL2SiY7sWno8 JE040lzZohR52S0q1AMdCgiVDg== X-Google-Smtp-Source: ACHHUZ5Xri0xKHFHVXrlXKhVerxqizBkAFxK8hJMXClMFGIprfFkBCRMoFRddX4+LXOfGlX3VsQYRg== X-Received: by 2002:a05:6000:104b:b0:309:cb7:1935 with SMTP id c11-20020a056000104b00b003090cb71935mr702948wrx.25.1684328390665; Wed, 17 May 2023 05:59:50 -0700 (PDT) Original-Received: from localhost ([217.173.96.166]) by smtp.gmail.com with ESMTPSA id i15-20020a5d630f000000b003079ed1f0a0sm2663447wru.44.2023.05.17.05.59.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 May 2023 05:59:49 -0700 (PDT) In-Reply-To: <83h6sbxhb0.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 17 May 2023 15:40:03 +0300") 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:261846 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii [2023-05-17 15:40 +0300] wrote: > We need to fix tis on the emacs-29 branch, so I wonder whether the fix > can be simpler? After all, we just need to test one more major mode, > right? Right. How's this for emacs-29: --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Fix-M-x-completion-predicate-under-python-ts-mode.patch >From 07a1869671a7a7bd3a24bb3605f5b4bb88469405 Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Wed, 17 May 2023 13:48:09 +0100 Subject: [PATCH] Fix M-x completion-predicate under python-ts-mode * lisp/progmodes/python.el (python--completion-predicate) (python-shell--completion-predicate): Filter M-x completion based on python-base-mode instead of python-mode. This allows for python-ts-mode as well (bug#63552). --- lisp/progmodes/python.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index bbabce80b4d..f810f1e2164 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -4967,7 +4967,7 @@ 'python-mode-skeleton-abbrev-table (defun python--completion-predicate (_ buffer) (provided-mode-derived-p (buffer-local-value 'major-mode buffer) - 'python-mode)) + 'python-base-mode)) (defmacro python-skeleton-define (name doc &rest skel) "Define a `python-mode' skeleton using NAME DOC and SKEL. @@ -6791,7 +6791,7 @@ python-ts-mode (defun python-shell--completion-predicate (_ buffer) (provided-mode-derived-p (buffer-local-value 'major-mode buffer) - 'python-mode 'inferior-python-mode)) + 'python-base-mode 'inferior-python-mode)) ;; Commands that only make sense in the Python shell or when editing ;; Python code. -- 2.34.1 --=-=-= Content-Type: text/plain > If a simpler fix is less clean, we could install a simpler change on > emacs-29 and a cleaner one on master. And this for master, once the patch above is merged: --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Simplify-python.el-completion-predicate.patch >From 17519e4dbdc1b90c6fb9d02297a00e1e30e7c3b0 Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Wed, 17 May 2023 13:53:09 +0100 Subject: [PATCH] Simplify python.el completion-predicate * lisp/progmodes/python.el: (python-skeleton-define): Use command-modes as a shorthand for completion-predicate (bug#63552). (python--completion-predicate, python-shell--completion-predicate): Remove accordingly; no longer used. (python-define-auxiliary-skeleton): Prefer function-put over put. --- lisp/progmodes/python.el | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 0ddce92b21e..4f57eda3cfc 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -5029,11 +5029,6 @@ 'python-mode-skeleton-abbrev-table (not (python-syntax-comment-or-string-p)) python-skeleton-autoinsert))) -(defun python--completion-predicate (_ buffer) - (provided-mode-derived-p - (buffer-local-value 'major-mode buffer) - 'python-base-mode)) - (defmacro python-skeleton-define (name doc &rest skel) "Define a `python-mode' skeleton using NAME DOC and SKEL. The skeleton will be bound to python-skeleton-NAME and will @@ -5042,7 +5037,7 @@ python-skeleton-define (let* ((name (symbol-name name)) (function-name (intern (concat "python-skeleton-" name)))) `(progn - (put ',function-name 'completion-predicate #'python--completion-predicate) + (function-put ',function-name 'command-modes '(python-base-mode)) (define-abbrev python-mode-skeleton-abbrev-table ,name "" ',function-name :system t) (setq python-skeleton-available @@ -5069,7 +5064,7 @@ python-define-auxiliary-skeleton `(< ,(format "%s:" name) \n \n > _ \n))) `(progn - (put ',function-name 'completion-predicate #'ignore) + (function-put ',function-name 'completion-predicate #'ignore) (define-skeleton ,function-name ,(or doc (format "Auxiliary skeleton for %s statement." name)) @@ -6817,7 +6812,7 @@ python-ts-mode (add-to-list 'interpreter-mode-alist '("python[0-9.]*" . python-ts-mode)))) ;;; Completion predicates for M-x -;; Commands that only make sense when editing Python code +;; Commands that only make sense when editing Python code. (dolist (sym '(python-add-import python-check python-fill-paragraph @@ -6851,12 +6846,7 @@ python-ts-mode python-shell-send-defun python-shell-send-statement python-sort-imports)) - (put sym 'completion-predicate #'python--completion-predicate)) - -(defun python-shell--completion-predicate (_ buffer) - (provided-mode-derived-p - (buffer-local-value 'major-mode buffer) - 'python-base-mode 'inferior-python-mode)) + (function-put sym 'command-modes '(python-base-mode))) ;; Commands that only make sense in the Python shell or when editing ;; Python code. @@ -6871,8 +6861,8 @@ python-shell--completion-predicate python-shell-font-lock-turn-off python-shell-font-lock-turn-on python-shell-package-enable - python-shell-completion-complete-or-indent )) - (put sym 'completion-predicate #'python-shell--completion-predicate)) + python-shell-completion-complete-or-indent)) + (function-put sym 'command-modes '(python-base-mode inferior-python-mode))) (provide 'python) -- 2.34.1 --=-=-= Content-Type: text/plain Thanks, -- Basil --=-=-=--