emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New feature in project.el: Remembering the previously used projects


From: Simen Heggestøyl
Subject: Re: New feature in project.el: Remembering the previously used projects
Date: Fri, 29 May 2020 17:54:45 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.91 (gnu/linux)

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

>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 via email to

[Prev in Thread] Current Thread [Next in Thread]