unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Philip K." <philip@warpmail.net>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: "Basil L. Contovounesios" <contovob@tcd.ie>,
	"Simen Heggestøyl" <simenheg@runbox.com>,
	emacs-devel <emacs-devel@gnu.org>
Subject: Re: New feature in project.el: Remembering the previously used projects
Date: Fri, 29 May 2020 09:31:34 +0200	[thread overview]
Message-ID: <87eer3nqnd.fsf@warpmail.net> (raw)
In-Reply-To: <8834c5e9-90c7-a8ad-3dcd-b8fb95f99df5@yandex.ru> (Dmitry Gutov's message of "Fri, 29 May 2020 02:29:35 +0300")

[-- Attachment #1: Type: text/plain, Size: 913 bytes --]

Dmitry Gutov <dgutov@yandex.ru> writes:

> On 29.05.2020 02:05, Basil L. Contovounesios wrote:

>> Could project-switch-project reuse read-multiple-choice or similar?
>
> I'm attaching a patch that makes it use read-multiple-choice, check it
> out. But I'm not sure the result looks better than what we have now.
>
> Suggestions on "similar" welcome.

I tried to same thing last night, but didn't get around to submitting it
in time. It's mosty the same, I just dropped project--keymap-prompt and
changed the type of project-switch-commands, because it seemed easier
that way.

I think it can be improved by adding a "case-insenstive" option to
read-multiple-choice, because for example currently it seems to
highlight the second "f" in "Find file"
                                  ^
        this one here ____________|

I have tried something out, and will submit a patch right after this one.

-- 
	Philip K.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Reworked-project-switch-project-to-use-read-multiple.patch --]
[-- Type: text/x-diff, Size: 2959 bytes --]

From 8b320e00fbd89a3b8e9097b04cf307d3230e6ed6 Mon Sep 17 00:00:00 2001
From: Philip K <philip@warpmail.net>
Date: Fri, 29 May 2020 09:23:15 +0200
Subject: [PATCH] Reworked project-switch-project to use read-multiple-choice

---
 lisp/progmodes/project.el | 44 ++++++++++++++-------------------------
 1 file changed, 16 insertions(+), 28 deletions(-)

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 92293d0e2d..cdc27d11f5 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -792,28 +792,21 @@ project-prompt-project-dir
 ;;; Project switching
 
 ;;;###autoload
-(defvar project-switch-commands
-  '(("f" "Find file" project-find-file)
-    ("s" "Find regexp" project-find-regexp)
-    ("d" "Dired" project-dired)
-    ("e" "Eshell" project-eshell))
+(defcustom project-switch-commands
+  '((?f "Find file" project-find-file)
+    (?s "Find regexp" project-find-regexp)
+    (?d "Dired" project-dired)
+    (?e "Eshell" project-eshell))
   "Alist mapping keys to project switching menu entries.
 Used by `project-switch-project' to construct a dispatch menu of
 commands available upon \"switching\" to another project.
 
 Each element looks like (KEY LABEL COMMAND), where COMMAND is the
 command to run when KEY is pressed.  LABEL is used to distinguish
-the choice in the dispatch menu.")
-
-(defun project--keymap-prompt ()
-  "Return a prompt for the project swithing dispatch menu."
-  (mapconcat
-   (pcase-lambda (`(,key ,label))
-     (format "[%s] %s"
-             (propertize (key-description `(,key)) 'face 'bold)
-             label))
-   project-switch-commands
-   "  "))
+the choice in the dispatch menu."
+  :type '(repeat (list (character :tag "Invocation Key")
+                       (string :tag "Label")
+                       (function :tag "Command"))))
 
 ;;;###autoload
 (defun project-switch-project ()
@@ -821,18 +814,13 @@ project-switch-project
 The available commands are picked from `project-switch-commands'
 and presented in a dispatch menu."
   (interactive)
-  (let ((dir (project-prompt-project-dir))
-        (choice nil))
-    (while (not (and choice
-                     (or (equal choice (kbd "C-g"))
-                         (assoc choice project-switch-commands))))
-      (setq choice (read-key-sequence (project--keymap-prompt))))
-    (if (equal choice (kbd "C-g"))
-        (message "Quit")
-      (let ((default-directory dir)
-            (project-current-inhibit-prompt t))
-        (call-interactively
-         (nth 2 (assoc choice project-switch-commands)))))))
+  (let* ((default-directory (project-prompt-project-dir))
+         (choice (read-multiple-choice
+                  "Open project via"
+                  (mapcar #'butlast project-switch-commands)))
+         (project-current-inhibit-prompt t))
+    (call-interactively
+     (nth 2 (assq (car choice) project-switch-commands)))))
 
 (provide 'project)
 ;;; project.el ends here
-- 
2.20.1


  reply	other threads:[~2020-05-29  7:31 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-28 20:06 New feature in project.el: Remembering the previously used projects Dmitry Gutov
2020-05-28 23:05 ` Basil L. Contovounesios
2020-05-28 23:29   ` Dmitry Gutov
2020-05-29  7:31     ` Philip K. [this message]
2020-05-29 13:51       ` Dmitry Gutov
2020-05-29 15:54         ` Simen Heggestøyl
     [not found]         ` <871rn2ivne.fsf@simenheg@gmail.com>
2020-05-30 10:29           ` Philip K.
2020-06-02 17:04             ` Simen Heggestøyl
     [not found]             ` <5ed68784.1c69fb81.61518.35eeSMTPIN_ADDED_BROKEN@mx.google.com>
2020-06-03 11:28               ` Basil L. Contovounesios
2020-05-30 12:38           ` Dmitry Gutov
2020-06-02 17:14             ` Simen Heggestøyl
2020-05-30 21:57           ` Juri Linkov
2020-05-30 23:39             ` Dmitry Gutov
2020-06-01 23:01               ` Juri Linkov
2020-06-02 21:34                 ` Dmitry Gutov
2020-06-03 20:13                   ` Dmitry Gutov
2020-06-03 22:40                     ` Juri Linkov
2020-06-03 23:13                       ` Dmitry Gutov
2020-06-04 21:55                         ` Juri Linkov
2020-06-04 22:37                           ` Dmitry Gutov
2020-06-05  8:33                           ` Philip K.
2020-06-05  8:42                             ` Simen Heggestøyl
2020-06-05 11:44                             ` Dmitry Gutov
2020-06-05 11:59                               ` Philip K.
2020-06-05 13:59                                 ` Philip K.
2020-06-05 17:20                                   ` Dmitry Gutov
2020-06-06  1:24                                   ` Jamie Beardslee
2020-12-19 22:18                                     ` Dmitry Gutov
2020-06-06 23:46                             ` Juri Linkov
2020-06-07  0:40                               ` Dmitry Gutov
2020-06-07 22:38                                 ` Juri Linkov
2020-06-02 17:43             ` Simen Heggestøyl
     [not found]             ` <5ed68fe1.1c69fb81.45e50.0c7cSMTPIN_ADDED_BROKEN@mx.google.com>
2020-06-03 11:28               ` Basil L. Contovounesios
     [not found]             ` <87a71l2wjf.fsf@simenheg@gmail.com>
2020-06-02 17:57               ` Dmitry Gutov
2020-06-03 22:34               ` Juri Linkov
2020-06-03 23:17                 ` Dmitry Gutov
2020-06-04 18:33                   ` Simen Heggestøyl
2020-06-04 21:58                   ` Juri Linkov
2020-05-31 13:00           ` Dmitry Gutov
2020-06-02 17:51             ` Simen Heggestøyl
     [not found]             ` <87k10picej.fsf@simenheg@gmail.com>
2020-06-02 21:33               ` Dmitry Gutov
     [not found]         ` <5ed13064.1c69fb81.4bf5e.dc8eSMTPIN_ADDED_BROKEN@mx.google.com>
2020-06-03 11:28           ` Basil L. Contovounesios
2020-06-03 11:27     ` Basil L. Contovounesios
2020-06-03 11:47       ` Dmitry Gutov
2020-06-03 13:38         ` Basil L. Contovounesios
2020-06-03 19:15           ` Simen Heggestøyl
     [not found]           ` <87lfl4x8p0.fsf@simenheg@gmail.com>
2020-06-03 20:11             ` Dmitry Gutov
2020-06-04 18:19               ` Simen Heggestøyl
2020-05-29 22:55 ` Kévin Le Gouguec
2020-05-29 23:22   ` Dmitry Gutov
2020-05-29 23:31     ` Dmitry Gutov
2020-05-30  0:42     ` Dmitry Gutov
2020-05-30  6:05       ` Simen Heggestøyl
     [not found]       ` <5ed1f7ae.1c69fb81.9b99b.4ce7SMTPIN_ADDED_BROKEN@mx.google.com>
2020-05-30 12:42         ` Kévin Le Gouguec
2020-05-30 13:17           ` Dmitry Gutov
2020-05-30 17:05             ` Dmitry Gutov
2020-05-30 18:29               ` Kévin Le Gouguec
2020-06-02 17:29           ` Simen Heggestøyl
     [not found]       ` <877dwuc5zu.fsf@simenheg@gmail.com>
2020-05-30 13:21         ` Dmitry Gutov

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87eer3nqnd.fsf@warpmail.net \
    --to=philip@warpmail.net \
    --cc=contovob@tcd.ie \
    --cc=dgutov@yandex.ru \
    --cc=emacs-devel@gnu.org \
    --cc=simenheg@runbox.com \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).