diff options
| author | kobarity | 2026-01-31 23:11:04 +0900 |
|---|---|---|
| committer | Eli Zaretskii | 2026-02-07 14:41:48 +0200 |
| commit | 482748592f61abed6f675e7b62b2d56e4e18a146 (patch) | |
| tree | c80dbdd7bb8c8b303e39e75e07dabe94bb23ce8e /lisp/progmodes/python.el | |
| parent | 3d7e78b810b11b71b95a87ffabf2995dd8fe2fe9 (diff) | |
| download | emacs-482748592f61abed6f675e7b62b2d56e4e18a146.tar.gz emacs-482748592f61abed6f675e7b62b2d56e4e18a146.zip | |
Use 'project-name-cached' in 'python-shell-get-process-name'
* lisp/progmodes/python.el
(python-shell-get-project-name): New function.
(python-shell-get-process-name): Use it. (Bug#80045)
Co-authored-by: Liu Hui <liuhui1610@gmail.com>
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 9fa2b1aaf19..39ec97e1b86 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -3366,6 +3366,16 @@ from `python-shell-prompt-regexp', | |||
| 3366 | python-shell--prompt-calculated-output-regexp | 3366 | python-shell--prompt-calculated-output-regexp |
| 3367 | (funcall build-regexp output-prompts))))) | 3367 | (funcall build-regexp output-prompts))))) |
| 3368 | 3368 | ||
| 3369 | (defun python-shell-get-project-name () | ||
| 3370 | "Return the project name for the current buffer. | ||
| 3371 | Use `project-name-cached' if available." | ||
| 3372 | (when (featurep 'project) | ||
| 3373 | (if (fboundp 'project-name-cached) | ||
| 3374 | (project-name-cached default-directory) | ||
| 3375 | (when-let* ((proj (project-current))) | ||
| 3376 | (file-name-nondirectory | ||
| 3377 | (directory-file-name (project-root proj))))))) | ||
| 3378 | |||
| 3369 | (defun python-shell-get-process-name (dedicated) | 3379 | (defun python-shell-get-process-name (dedicated) |
| 3370 | "Calculate the appropriate process name for inferior Python process. | 3380 | "Calculate the appropriate process name for inferior Python process. |
| 3371 | If DEDICATED is nil, this is simply `python-shell-buffer-name'. | 3381 | If DEDICATED is nil, this is simply `python-shell-buffer-name'. |
| @@ -3374,11 +3384,8 @@ name respectively the current project name." | |||
| 3374 | (pcase dedicated | 3384 | (pcase dedicated |
| 3375 | ('nil python-shell-buffer-name) | 3385 | ('nil python-shell-buffer-name) |
| 3376 | ('project | 3386 | ('project |
| 3377 | (if-let* ((proj (and (featurep 'project) | 3387 | (if-let* ((proj-name (python-shell-get-project-name))) |
| 3378 | (project-current)))) | 3388 | (format "%s[%s]" python-shell-buffer-name proj-name) |
| 3379 | (format "%s[%s]" python-shell-buffer-name (file-name-nondirectory | ||
| 3380 | (directory-file-name | ||
| 3381 | (project-root proj)))) | ||
| 3382 | python-shell-buffer-name)) | 3389 | python-shell-buffer-name)) |
| 3383 | (_ (format "%s[%s]" python-shell-buffer-name (buffer-name))))) | 3390 | (_ (format "%s[%s]" python-shell-buffer-name (buffer-name))))) |
| 3384 | 3391 | ||