From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Newsgroups: gmane.emacs.bugs Subject: bug#41741: [PATCH] Save project list as lisp data Date: Sat, 06 Jun 2020 18:40:05 +0200 Message-ID: <35622.6527875819$1591469962@news.gmane.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="34838"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.91 (gnu/linux) Cc: "Basil L. Contovounesios" , Dmitry Gutov , Juri Linkov To: 41741@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jun 06 20:59:21 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1jhe2J-00091C-Ob for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 06 Jun 2020 20:59:20 +0200 Original-Received: from localhost ([::1]:32876 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jhe2I-0007jM-Pr for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 06 Jun 2020 14:59:18 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35366) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jhe15-0006pm-Nd for bug-gnu-emacs@gnu.org; Sat, 06 Jun 2020 14:58:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:40929) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jhe14-0008UU-QI for bug-gnu-emacs@gnu.org; Sat, 06 Jun 2020 14:58:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jhe14-0001d8-Pl for bug-gnu-emacs@gnu.org; Sat, 06 Jun 2020 14:58:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Simen =?UTF-8?Q?Heggest=C3=B8yl?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 06 Jun 2020 18:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 41741 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.15914698716227 (code B ref -1); Sat, 06 Jun 2020 18:58:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 6 Jun 2020 18:57:51 +0000 Original-Received: from localhost ([127.0.0.1]:52473 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jhe0s-0001cM-HZ for submit@debbugs.gnu.org; Sat, 06 Jun 2020 14:57:51 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:57846) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jhd2a-0006Py-T2 for submit@debbugs.gnu.org; Sat, 06 Jun 2020 13:55:33 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52884) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jhd2Z-0004sA-4T for bug-gnu-emacs@gnu.org; Sat, 06 Jun 2020 13:55:32 -0400 Original-Received: from aibo.runbox.com ([91.220.196.211]:52564) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jhd2W-0003n3-PN for bug-gnu-emacs@gnu.org; Sat, 06 Jun 2020 13:55:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Type:MIME-Version:Message-ID:Date:Subject:Cc:To:From; bh=SzNzh/Hv96QYtO96rh1YzHtNRjF1RRYb2ih7dO1odd4=; b=WkNj3KhTAoA9t3zHUXiBjoSyw dqMvsA0IyPm6DLnbhpKq0H3SnyO1xcPagOFKI9WMts+iWVjt6ZrTunf2waub7h3vkQbx6V0Eu54B9 lzhvxMG9JhzUEgibnQD9H8k2DLubWsd01eAvWjdg5JVF3OM1zVzLS/YvC1G1u5F7w31I9kNCFfF00 t7mv2/eo9JEtxnImnoSehosxrREPaARaBHkvQP9nHm0DsURjMa/4D2XhjdXWZfUUle+QwXaPgrvoe ehcMlWFuWLiQZ4WP8QvYT1+YZM0Xi1xyGJQUmDv+ZMJ8p5c6jmvyFonhOePUlXq4IPQ4jP0kfOMw2 j/PObWdQA==; Original-Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1jhbrb-0007jb-MY; Sat, 06 Jun 2020 18:40:07 +0200 Original-Received: by submission03.runbox with esmtpsa [Authenticated alias (963757)] (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) id 1jhbrZ-00051X-Mb; Sat, 06 Jun 2020 18:40:05 +0200 Received-SPF: pass client-ip=91.220.196.211; envelope-from=simenheg@runbox.com; helo=aibo.runbox.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/06 13:55:24 X-ACL-Warn: Detected OS = ??? 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_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, MSGID_MULTIPLE_AT=1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Mailman-Approved-At: Sat, 06 Jun 2020 14:57:49 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:181630 Archived-At: --=-=-= Content-Type: text/plain Hi. I'm attaching a suggested patch for changing project.el's project list format from a line based one to proper Lisp data as discussed in the "New feature in project.el: Remembering the previously used projects" thread on emacs-devel. No metadata is added at this point, but it makes it extensible for the future. -- Simen --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Save-project-list-as-lisp-data.patch >From 3084f651d6c0f5e6b4b3ac699b59742f98af2248 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simen=20Heggest=C3=B8yl?= Date: Fri, 5 Jun 2020 19:32:30 +0200 Subject: [PATCH] Save project list as lisp data Save the project list file as lisp data instead of line separated strings to make it more extendable in the future. * lisp/progmodes/project.el (project--read-project-list) (project--write-project-list, project--add-to-project-list-front) (project--remove-from-project-list): Adjust to `project--list' now being an alist. --- lisp/progmodes/project.el | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 4d57fb25fd..3b007bc8dc 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -757,19 +757,13 @@ project--list "List of known project directories.") (defun project--read-project-list () - "Initialize `project--list' from the project list file." + "Initialize `project--list' from the file `project-list-file'." (let ((filename project-list-file)) (setq project--list - (when (file-exists-p filename) + (when (file-readable-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))))))) + (car (read-from-string (buffer-string)))))))) (defun project--ensure-read-project-list () "Initialize `project--list' if it hasn't already been." @@ -780,7 +774,8 @@ project--write-project-list "Persist `project--list' to the project list file." (let ((filename project-list-file)) (with-temp-buffer - (insert (string-join project--list "\n")) + (insert ";;; -*- lisp-data -*-\n") + (pp project--list (current-buffer)) (write-region nil nil filename nil 'silent)))) (defun project--add-to-project-list-front (pr) @@ -788,9 +783,9 @@ project--add-to-project-list-front Save the result to disk if the project list was changed." (project--ensure-read-project-list) (let ((dir (project-root pr))) - (unless (equal (car project--list) dir) - (setq project--list (delete dir project--list)) - (push dir project--list) + (unless (equal (caar project--list) dir) + (setq project--list (assoc-delete-all dir project--list)) + (push (list dir) project--list) (project--write-project-list)))) (defun project--remove-from-project-list (pr-dir) @@ -798,8 +793,8 @@ project--remove-from-project-list If the directory was in the list before the removal, save the result to disk." (project--ensure-read-project-list) - (when (member pr-dir project--list) - (setq project--list (delete pr-dir project--list)) + (when (assoc pr-dir project--list) + (setq project--list (assoc-delete-all pr-dir project--list)) (message "Project `%s' not found; removed from list" pr-dir) (project--write-project-list))) -- 2.26.2 --=-=-=--