From: Basil Contovounesios via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 63552@debbugs.gnu.org, arstoffel@gmail.com
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 [thread overview]
Message-ID: <87pm6z8663.fsf@tcd.ie> (raw)
In-Reply-To: <83h6sbxhb0.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 17 May 2023 15:40:03 +0300")
[-- Attachment #1: Type: text/plain, Size: 236 bytes --]
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:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-M-x-completion-predicate-under-python-ts-mode.patch --]
[-- Type: text/x-diff, Size: 1392 bytes --]
From 07a1869671a7a7bd3a24bb3605f5b4bb88469405 Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <contovob@tcd.ie>
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
[-- Attachment #3: Type: text/plain, Size: 167 bytes --]
> 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:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0001-Simplify-python.el-completion-predicate.patch --]
[-- Type: text/x-diff, Size: 3579 bytes --]
From 17519e4dbdc1b90c6fb9d02297a00e1e30e7c3b0 Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <contovob@tcd.ie>
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
[-- Attachment #5: Type: text/plain, Size: 20 bytes --]
Thanks,
--
Basil
next prev parent reply other threads:[~2023-05-17 12:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-17 11:54 bug#63552: 29.0.91; M-x completion-predicate does not account for python-ts-mode Basil Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-17 12:40 ` Eli Zaretskii
2023-05-17 12:59 ` Basil Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-05-17 13:33 ` Eli Zaretskii
2023-05-17 14:16 ` Basil Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-18 11:55 ` Eli Zaretskii
2023-05-18 12:15 ` Basil Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87pm6z8663.fsf@tcd.ie \
--to=bug-gnu-emacs@gnu.org \
--cc=63552@debbugs.gnu.org \
--cc=arstoffel@gmail.com \
--cc=contovob@tcd.ie \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.