From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: New feature in project.el: Remembering the previously used projects Date: Fri, 29 May 2020 02:29:35 +0300 Message-ID: <8834c5e9-90c7-a8ad-3dcd-b8fb95f99df5@yandex.ru> References: <6f0f6cc9-52f4-8383-9827-ead54e898472@yandex.ru> <87pnan8xuf.fsf@tcd.ie> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------BDD2C40D2DE61CE736A690CB" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="22583"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 Cc: =?UTF-8?Q?Simen_Heggest=c3=b8yl?= , emacs-devel To: "Basil L. Contovounesios" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri May 29 01:30:42 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jeRyz-0005qx-VX for ged-emacs-devel@m.gmane-mx.org; Fri, 29 May 2020 01:30:42 +0200 Original-Received: from localhost ([::1]:37500 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jeRyy-0001DW-Qc for ged-emacs-devel@m.gmane-mx.org; Thu, 28 May 2020 19:30:40 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54860) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jeRy2-0008U8-44 for emacs-devel@gnu.org; Thu, 28 May 2020 19:29:45 -0400 Original-Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:33842) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jeRy0-0000ZP-BL for emacs-devel@gnu.org; Thu, 28 May 2020 19:29:41 -0400 Original-Received: by mail-wr1-x436.google.com with SMTP id r7so1287021wro.1 for ; Thu, 28 May 2020 16:29:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=UAJ8iCI0Ng7FgYteBuSBCh7TBmhDpV4A4hT3X0fYrH4=; b=stHvUtXMA44ugGTigPiypCRii3keIip4ABRwNlQPpbQYDBPU8yZz0EnNuddskxZwpU q2s/DUhmRgUm5h168EAoXN9Al9EAtHFV3oUMIo2r2m9kJZmEbGH79/NnygrbyLsTcKP3 BlS0jzw+VAOXdQuUn6h2IMRgWS0QbNDiij9fFqDdsxSckejE5L3hAY+Cy2BphsirPnhD O8iNPZC3P+FhDGYi7uRLYoYKru0fojosDmBCHvsxTJekqGjqsKiRFTWfufW7ZOWm8V6N GNf9rVVYv9CazWREAO+fiqYmZBlpzAm4kRSWLzOwr3C2VmhEyrJZe3FTQIuLh8j9lTfl dBug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language; bh=UAJ8iCI0Ng7FgYteBuSBCh7TBmhDpV4A4hT3X0fYrH4=; b=AHeSOzkqIYzcO2GrR2hhb/So4th6HSaYWHg/58uNM/FApTgcpN1rlTzAjiHuzKXUDW HVwxaLv1QCfl84WcMIB8KusIjNuyDJFr+hyTe4R4Z9Ho5jI3tjdAJrPf47GZc9UQLAqj k5LjcERWsxVFPlXp9jI3NDW/zUhjBNC/T3NbNVFMLy7tM2G5sTChpJzVq1j1swbpfNoZ LC6nvZqgN8kK3JnvN9sqTf7NcZg4W/20Z1N/rqUEePN9yaJU++ZVoeLcKV7ca4LGsmVA samvEghgn/oG1s73iF8/0exPzIK4mUvztlKbDVDf2T3Oojy+58AiB2/1kDLv50H1T/Ba Tvhg== X-Gm-Message-State: AOAM532TEiA2ZYkg8phl0cQrzCI6YpboDcpikzRwkCAsyg2kaRu05Ql8 ga3ZDKjIPTpYO8cAjrtEdyg= X-Google-Smtp-Source: ABdhPJyQtkOfT7QXmxB578Uhu2BgfKndg954F6DyLA0g8NGCRpcLHP65kyX0a+2ERid++13JXg1VAA== X-Received: by 2002:adf:814a:: with SMTP id 68mr5788918wrm.177.1590708577910; Thu, 28 May 2020 16:29:37 -0700 (PDT) Original-Received: from [192.168.0.3] ([66.205.73.129]) by smtp.googlemail.com with ESMTPSA id r4sm7541002wro.32.2020.05.28.16.29.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 28 May 2020 16:29:37 -0700 (PDT) In-Reply-To: <87pnan8xuf.fsf@tcd.ie> Content-Language: en-US Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=raaahh@gmail.com; helo=mail-wr1-x436.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:251590 Archived-At: This is a multi-part message in MIME format. --------------BDD2C40D2DE61CE736A690CB Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 29.05.2020 02:05, Basil L. Contovounesios wrote: >> Please let us know how you like the change, and if you see any new problems. > > Only one feature request and some minor questions from me. > > Can the project-list file name please be customisable? Of course. Just an omission. > Could the contents of the project-list file comprise easily readable, > printable, and even extensible sexps? > > 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. > Isn't there a race here? > > (defun project--ensure-file-exists (filename) > "Create an empty file FILENAME if it doesn't exist." > (unless (file-exists-p filename) > (with-temp-buffer > (write-file filename)))) > > Why not use something like the following instead? > > (ignore-error file-already-exists > (write-region "" nil filename nil 0 nil 'excl)) Looks good to me. Let's see what Simen says. > In fact, couldn't project--ensure-file-exists be eliminated altogether? > If the file doesn't exist, just don't set project--list, or set it to > nil. Or that. --------------BDD2C40D2DE61CE736A690CB Content-Type: text/x-patch; charset=UTF-8; name="project-switch-read-multiple.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="project-switch-read-multiple.diff" diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 92293d0e2d..54bacc598e 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -805,15 +805,11 @@ project-switch-commands 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 +(defun project--switch-choices () + (mapcar (pcase-lambda (`(,key ,label)) - (format "[%s] %s" - (propertize (key-description `(,key)) 'face 'bold) - label)) - project-switch-commands - " ")) + (list (aref key 0) label)) + project-switch-commands)) ;;;###autoload (defun project-switch-project () @@ -822,17 +818,12 @@ project-switch-project 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))))))) + (choice (read-multiple-choice "Action:" + (project--switch-choices)))) + (let ((default-directory dir) + (project-current-inhibit-prompt t)) + (call-interactively + (nth 2 (assoc (string choice) project-switch-commands)))))) (provide 'project) ;;; project.el ends here --------------BDD2C40D2DE61CE736A690CB--