discussion and development of piem
 help / color / mirror / code / Atom feed
* [PATCH] piem-inbox-coderepo-maybe-read: Include current projectile project
@ 2020-08-16 16:54 Kyle Meyer
  2020-08-16 18:42 ` Kyle Meyer
  0 siblings, 1 reply; 6+ messages in thread
From: Kyle Meyer @ 2020-08-16 16:54 UTC (permalink / raw)
  To: piem

When piem-inbox-coderepo-maybe-read is called from within a project,
the current project isn't included in the collection because
projectile-relevant-known-projects excludes it when
projectile-current-project-on-switch is at its default value.  That's
undesirable in this context; if there's a current project, it's likely
the one of interest (e.g., calling piem-b4-am-ready-from-mbox from a
project's directory).

Add the current project to the collection and make it the default.
Also, don't bother going down the projectile branch if there are no
known projects.
---
 piem.el | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/piem.el b/piem.el
index 6a3c2b3..941b7d7 100644
--- a/piem.el
+++ b/piem.el
@@ -293,10 +293,13 @@ (defun piem-inbox-url ()
 (defun piem-inbox-coderepo-maybe-read ()
   "Like `piem-inbox-coderepo', but fall back to reading the repo."
   (or (piem-inbox-coderepo)
-      (and (fboundp 'projectile-relevant-known-projects)
+      (and (bound-and-true-p projectile-known-projects)
            (completing-read
             "Project: "
-            (projectile-relevant-known-projects)))
+            projectile-known-projects nil t nil nil
+            (when-let ((current (and (fboundp 'projectile-project-root)
+                                     (projectile-project-root))))
+              (abbreviate-file-name current))))
       (and piem-use-magit
            (fboundp 'magit-read-repository)
            (magit-read-repository))

base-commit: ff3b7724a75427c8d73a9b80f9ee5057250479cd
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] piem-inbox-coderepo-maybe-read: Include current projectile project
  2020-08-16 16:54 [PATCH] piem-inbox-coderepo-maybe-read: Include current projectile project Kyle Meyer
@ 2020-08-16 18:42 ` Kyle Meyer
  2020-08-16 18:51   ` [PATCH v2 1/4] piem-inbox-coderepo-maybe-read: Reject invalid empty-string inbox Kyle Meyer
                     ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Kyle Meyer @ 2020-08-16 18:42 UTC (permalink / raw)
  To: piem

Kyle Meyer writes:

> diff --git a/piem.el b/piem.el
> index 6a3c2b3..941b7d7 100644
> --- a/piem.el
> +++ b/piem.el
> @@ -293,10 +293,13 @@ (defun piem-inbox-url ()
>  (defun piem-inbox-coderepo-maybe-read ()
>    "Like `piem-inbox-coderepo', but fall back to reading the repo."
>    (or (piem-inbox-coderepo)
> -      (and (fboundp 'projectile-relevant-known-projects)
> +      (and (bound-and-true-p projectile-known-projects)
>             (completing-read
>              "Project: "
> -            (projectile-relevant-known-projects)))
> +            projectile-known-projects nil t nil nil

This is sneaking in a 'nil => t' change for DEFAULT.  I think that makes
sense, but it should be done separately.

And looking at this again, there are a few other aspects of
piem-inbox-coderepo-maybe-read that can be improved...

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/4] piem-inbox-coderepo-maybe-read: Reject invalid empty-string inbox
  2020-08-16 18:42 ` Kyle Meyer
@ 2020-08-16 18:51   ` Kyle Meyer
  2020-08-16 18:51   ` [PATCH v2 2/4] piem-inbox-coderepo-maybe-read: Require projectile project match Kyle Meyer
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Kyle Meyer @ 2020-08-16 18:51 UTC (permalink / raw)
  To: piem

---
 piem.el | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/piem.el b/piem.el
index 6a3c2b3..55915f6 100644
--- a/piem.el
+++ b/piem.el
@@ -292,15 +292,19 @@ (defun piem-inbox-url ()
 
 (defun piem-inbox-coderepo-maybe-read ()
   "Like `piem-inbox-coderepo', but fall back to reading the repo."
-  (or (piem-inbox-coderepo)
-      (and (fboundp 'projectile-relevant-known-projects)
-           (completing-read
-            "Project: "
-            (projectile-relevant-known-projects)))
-      (and piem-use-magit
-           (fboundp 'magit-read-repository)
-           (magit-read-repository))
-      (read-directory-name "Git repository: ")))
+  (let ((inbox
+         (or (piem-inbox-coderepo)
+             (and (fboundp 'projectile-relevant-known-projects)
+                  (completing-read
+                   "Project: "
+                   (projectile-relevant-known-projects)))
+             (and piem-use-magit
+                  (fboundp 'magit-read-repository)
+                  (magit-read-repository))
+             (read-directory-name "Git repository: "))))
+    (if (equal inbox "")
+        (user-error "No inbox specified")
+      inbox)))
 
 (defun piem-mid ()
   "Return the current buffer's message ID."
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/4] piem-inbox-coderepo-maybe-read: Require projectile project match
  2020-08-16 18:42 ` Kyle Meyer
  2020-08-16 18:51   ` [PATCH v2 1/4] piem-inbox-coderepo-maybe-read: Reject invalid empty-string inbox Kyle Meyer
@ 2020-08-16 18:51   ` Kyle Meyer
  2020-08-16 18:51   ` [PATCH v2 3/4] piem-inbox-coderepo-maybe-read: Include current projectile project Kyle Meyer
  2020-08-16 18:51   ` [PATCH v2 4/4] piem-inbox-coderepo-maybe-read: Expand paths from projectile Kyle Meyer
  3 siblings, 0 replies; 6+ messages in thread
From: Kyle Meyer @ 2020-08-16 18:51 UTC (permalink / raw)
  To: piem

While it's possible that the caller wants to specify a path for a repo
that isn't yet registered as a project, it should be quite rare, and
disabling it decreases the chances of invalid input.
---
 piem.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/piem.el b/piem.el
index 55915f6..de298a1 100644
--- a/piem.el
+++ b/piem.el
@@ -297,7 +297,8 @@ (defun piem-inbox-coderepo-maybe-read ()
              (and (fboundp 'projectile-relevant-known-projects)
                   (completing-read
                    "Project: "
-                   (projectile-relevant-known-projects)))
+                   (projectile-relevant-known-projects)
+                   nil t))
              (and piem-use-magit
                   (fboundp 'magit-read-repository)
                   (magit-read-repository))
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 3/4] piem-inbox-coderepo-maybe-read: Include current projectile project
  2020-08-16 18:42 ` Kyle Meyer
  2020-08-16 18:51   ` [PATCH v2 1/4] piem-inbox-coderepo-maybe-read: Reject invalid empty-string inbox Kyle Meyer
  2020-08-16 18:51   ` [PATCH v2 2/4] piem-inbox-coderepo-maybe-read: Require projectile project match Kyle Meyer
@ 2020-08-16 18:51   ` Kyle Meyer
  2020-08-16 18:51   ` [PATCH v2 4/4] piem-inbox-coderepo-maybe-read: Expand paths from projectile Kyle Meyer
  3 siblings, 0 replies; 6+ messages in thread
From: Kyle Meyer @ 2020-08-16 18:51 UTC (permalink / raw)
  To: piem

When piem-inbox-coderepo-maybe-read is called from within a project,
the current project isn't included in the collection because
projectile-relevant-known-projects excludes it when
projectile-current-project-on-switch is at its default value.  That's
undesirable in this context; if there's a current project, it's likely
the one of interest (e.g., calling piem-b4-am-ready-from-mbox from a
project's directory).

Add the current project to the collection and make it the default.
Also, don't bother going down the projectile branch if there are no
known projects.
---
 piem.el | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/piem.el b/piem.el
index de298a1..f4ba96b 100644
--- a/piem.el
+++ b/piem.el
@@ -294,11 +294,14 @@ (defun piem-inbox-coderepo-maybe-read ()
   "Like `piem-inbox-coderepo', but fall back to reading the repo."
   (let ((inbox
          (or (piem-inbox-coderepo)
-             (and (fboundp 'projectile-relevant-known-projects)
+             (and (bound-and-true-p projectile-known-projects)
                   (completing-read
                    "Project: "
-                   (projectile-relevant-known-projects)
-                   nil t))
+                   projectile-known-projects nil t nil nil
+                   (when-let ((current (and (fboundp 'projectile-project-root)
+                                            (projectile-project-root))))
+                     (abbreviate-file-name current))))
+
              (and piem-use-magit
                   (fboundp 'magit-read-repository)
                   (magit-read-repository))
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 4/4] piem-inbox-coderepo-maybe-read: Expand paths from projectile
  2020-08-16 18:42 ` Kyle Meyer
                     ` (2 preceding siblings ...)
  2020-08-16 18:51   ` [PATCH v2 3/4] piem-inbox-coderepo-maybe-read: Include current projectile project Kyle Meyer
@ 2020-08-16 18:51   ` Kyle Meyer
  3 siblings, 0 replies; 6+ messages in thread
From: Kyle Meyer @ 2020-08-16 18:51 UTC (permalink / raw)
  To: piem

The other methods return expanded absolute paths.  Do the same here.
---
 piem.el | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/piem.el b/piem.el
index f4ba96b..e958ada 100644
--- a/piem.el
+++ b/piem.el
@@ -295,13 +295,13 @@ (defun piem-inbox-coderepo-maybe-read ()
   (let ((inbox
          (or (piem-inbox-coderepo)
              (and (bound-and-true-p projectile-known-projects)
-                  (completing-read
-                   "Project: "
-                   projectile-known-projects nil t nil nil
-                   (when-let ((current (and (fboundp 'projectile-project-root)
-                                            (projectile-project-root))))
-                     (abbreviate-file-name current))))
-
+                  (expand-file-name
+                   (completing-read
+                    "Project: "
+                    projectile-known-projects nil t nil nil
+                    (when-let ((current (and (fboundp 'projectile-project-root)
+                                             (projectile-project-root))))
+                      (abbreviate-file-name current)))))
              (and piem-use-magit
                   (fboundp 'magit-read-repository)
                   (magit-read-repository))
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-08-16 18:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-16 16:54 [PATCH] piem-inbox-coderepo-maybe-read: Include current projectile project Kyle Meyer
2020-08-16 18:42 ` Kyle Meyer
2020-08-16 18:51   ` [PATCH v2 1/4] piem-inbox-coderepo-maybe-read: Reject invalid empty-string inbox Kyle Meyer
2020-08-16 18:51   ` [PATCH v2 2/4] piem-inbox-coderepo-maybe-read: Require projectile project match Kyle Meyer
2020-08-16 18:51   ` [PATCH v2 3/4] piem-inbox-coderepo-maybe-read: Include current projectile project Kyle Meyer
2020-08-16 18:51   ` [PATCH v2 4/4] piem-inbox-coderepo-maybe-read: Expand paths from projectile Kyle Meyer

Code repositories for project(s) associated with this public inbox

	https://git.kyleam.com/piem/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).