[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Subprojects in project.el
From: |
João Távora |
Subject: |
Re: Subprojects in project.el |
Date: |
Tue, 29 Nov 2022 22:52:22 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Dmitry Gutov <dgutov@yandex.ru> writes:
> What do you mean, without breaking compatibility? Adding a new
> required argument means it will break any Lisp code that calls this
> function.
The example I gave you was for a function explicitly marked "interactive
only", so it's not a problem. In fact all these functions should be
"interactive only". But in other cases, make that argument optional.
> And it's probably not that big a deal if we had no other choice, but
> we do. Update the commands to call a different new function.
As I explain below, you'll be littering the code with non-idiomatic
Elisp.
> That will actually require *fewer* changes, as you might have noticed
> now.
Not sure about that.
> diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
> index c1245704bcc..9e5fcfe0b06 100644
> --- a/lisp/progmodes/project.el
> +++ b/lisp/progmodes/project.el
> @@ -1139,6 +1139,19 @@ project-prefixed-buffer-name
> (downcase mode)
> "*"))
>
> +(defun project-parent (project)
> + (project-current nil (file-name-as-directory
> + (file-name-directory
> + (directory-file-name (project-root project))))))
> +
> +(defun project-current-or-parent (lookup-parent)
> + (let ((project (project-current t)))
> + (when lookup-parent
> + (setq project (project-parent project)))
> + (unless project
> + (user-error "No parent project"))
> + project))
> +
> (defcustom project-compilation-buffer-name-function nil
> "Function to compute the name of a project compilation buffer.
> If non-nil, it overrides `compilation-buffer-name-function' for
> @@ -1155,7 +1168,8 @@ project-compile
> "Run `compile' in the project root."
> (declare (interactive-only compile))
> (interactive)
> - (let ((default-directory (project-root (project-current t)))
> + (let ((default-directory (project-root (project-current-or-parent
> + (eq current-prefix-arg '-))))
> (compilation-buffer-name-function
> (or project-compilation-buffer-name-function
> compilation-buffer-name-function)))
Sounds more complicated that it needs to be, and no reason why
project-current-or-parent shouldn't be just project-current, with
another optional argument at most.
Anyway my idea to add PROJECT is nothing exotic: it's the standard
idiomatic Elisp solution used in such basic functionality as M-x
display-buffer, find-file, etc. There's no reason to stray from that.
João
- Re: Subprojects in project.el, (continued)
- Re: Subprojects in project.el, Dmitry Gutov, 2022/11/25
- Re: Subprojects in project.el, João Távora, 2022/11/25
- Re: Subprojects in project.el, Dmitry Gutov, 2022/11/25
- Re: Subprojects in project.el, João Távora, 2022/11/25
- Re: Subprojects in project.el, Dmitry Gutov, 2022/11/25
- Re: Subprojects in project.el, João Távora, 2022/11/26
- Re: Subprojects in project.el, Dmitry Gutov, 2022/11/26
- Re: Subprojects in project.el, João Távora, 2022/11/29
- Re: Subprojects in project.el, João Távora, 2022/11/29
- Re: Subprojects in project.el, Dmitry Gutov, 2022/11/29
- Re: Subprojects in project.el,
João Távora <=
- Re: Subprojects in project.el, Dmitry Gutov, 2022/11/29
- Re: Subprojects in project.el, Juri Linkov, 2022/11/27
- Re: Subprojects in project.el, Dmitry Gutov, 2022/11/27
- Re: Subprojects in project.el (Was: Eglot, project.el, and python virtual environments), Tim Cross, 2022/11/24
- Re: Subprojects in project.el (Was: Eglot, project.el, and python virtual environments), Dmitry Gutov, 2022/11/24
- Re: Subprojects in project.el (Was: Eglot, project.el, and python virtual environments), Bozhidar Batsov, 2022/11/25
- Re: Subprojects in project.el, Stefan Monnier, 2022/11/25
- Re: Subprojects in project.el, Dmitry Gutov, 2022/11/25
- Re: Subprojects in project.el, Stefan Monnier, 2022/11/25
- Re: Subprojects in project.el, Dmitry Gutov, 2022/11/26