unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Simen Heggestøyl" <simenheg@runbox.com>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: "Basil L. Contovounesios" <contovob@tcd.ie>,
	"Philip K." <philip@warpmail.net>,
	emacs-devel <emacs-devel@gnu.org>
Subject: Re: New feature in project.el: Remembering the previously used projects
Date: Fri, 29 May 2020 17:54:45 +0200	[thread overview]
Message-ID: <36815.5526042514$1590767744@news.gmane.org> (raw)
In-Reply-To: d5af62ff-eaa4-404d-30d2-1346e5c533d2@yandex.ru

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

Hi Basil and Philip, thanks for checking it out!

Dmitry Gutov <dgutov@yandex.ru> writes:

> On 29.05.2020 02:05, Basil L. Contovounesios wrote:
>
>> Can the project-list file name please be customisable?
>
> Of course. Just an omission.

Yup.

"Basil L. Contovounesios" <contovob@tcd.ie> writes:

> Could the contents of the project-list file comprise easily readable,
> printable, and even extensible sexps?

I guess it could, but do you have any immediate use case in mind, or
were you thinking about easier forward compatibility in general?

I modeled the current approach after org-agenda-files, thinking that the
scheme with one project directory per line would be the easiest to edit
by hand.

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

Sounds good to me. How about the attached?

> Could project-switch-project reuse read-multiple-choice or similar?

There's definitely an advantage to reusing a function like that,
especially since it provides a more unified interface for the users.

I tested it with Philip's patch, but I have to agree with Dmitry in that
I prefer the current interface where the key choices are presented in
brackets next to the labels. I find it much easier to read the choices
at a glance compared to when the keys are made bold in midst of the
label texts. Also the "Find regexp" choice doesn't have an "s" in it, so
in that case read-multiple-choice puts the "s" in brackets instead,
making it non-uniform with the layout of the other choices.

The current approach where button choices are kept apart from the labels
is inspired by the Org Export Dispatcher and Magit's many menus, which I
think are excellent interfaces. If it turns out that more people, like
Dmitry and myself, like this approach better, maybe
read-multiple-choice's layout could be changed?

"Philip K." <philip@warpmail.net> writes:

> 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 ____________|

Hm, won't that be a problem when the user wants to use the lower and
upper variants of the same character for different commands? That's done
extensively in Org Mode's Export Dispatcher for instance. The bracketed
layout approach has natural support for it however:

  [f] Find foo  [F] Find bar

-- Simen


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Remove-project-ensure-file-exists.patch --]
[-- Type: text/x-diff, Size: 2154 bytes --]

From 4cb6cbb3776f142050cd70de279294cf98c63969 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Simen=20Heggest=C3=B8yl?= <simenheg@gmail.com>
Date: Fri, 29 May 2020 16:58:09 +0200
Subject: [PATCH] Remove 'project--ensure-file-exists'

* lisp/progmodes/project.el (project--ensure-file-exists): Remove.
(project--read-project-list): Set 'project--list' to nil when the
project list file doesn't exist.
---
 lisp/progmodes/project.el | 27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 92293d0e2d..56087a7290 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -718,25 +718,20 @@ project-compile
 (defvar project--list 'unset
   "List of known project directories.")
 
-(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))))
-
 (defun project--read-project-list ()
   "Initialize `project--list' from the project list file."
   (let ((filename (locate-user-emacs-file "project-list")))
-    (project--ensure-file-exists filename)
-    (with-temp-buffer
-      (insert-file-contents filename)
-      (let ((dirs (split-string (buffer-string) "\n" t))
-            (project-list '()))
-        (dolist (dir dirs)
-          (cl-pushnew (file-name-as-directory dir)
-                      project-list
-                      :test #'equal))
-        (setq project--list (reverse project-list))))))
+    (setq project--list
+          (when (file-exists-p filename)
+            (with-temp-buffer
+              (insert-file-contents filename)
+              (let ((dirs (split-string (buffer-string) "\n" t))
+                    (project-list '()))
+                (dolist (dir dirs)
+                  (cl-pushnew (file-name-as-directory dir)
+                              project-list
+                              :test #'equal))
+                (reverse project-list)))))))
 
 (defun project--ensure-read-project-list ()
   "Initialize `project--list' if it hasn't already been."
-- 
2.26.2


  reply	other threads:[~2020-05-29 15:54 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.
2020-05-29 13:51       ` Dmitry Gutov
2020-05-29 15:54         ` Simen Heggestøyl [this message]
     [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='36815.5526042514$1590767744@news.gmane.org' \
    --to=simenheg@runbox.com \
    --cc=contovob@tcd.ie \
    --cc=dgutov@yandex.ru \
    --cc=emacs-devel@gnu.org \
    --cc=philip@warpmail.net \
    /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).