diff options
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 | ||