From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.bugs Subject: bug#50297: 28.0.50; Aggregate project functions for project.el Date: Thu, 02 Sep 2021 14:45:50 +0000 Message-ID: <87ilzjdoip.fsf@posteo.net> References: <87h7f5ok5l.fsf@posteo.net> <5c88cae7-4175-9c1e-cf20-188883e6e617@yandex.ru> <87mtovds0o.fsf@posteo.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21340"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 50297@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Sep 02 16:47:15 2021 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 1mLnzn-0005HO-Nm for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 02 Sep 2021 16:47:15 +0200 Original-Received: from localhost ([::1]:53936 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mLnzl-0007Ah-S8 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 02 Sep 2021 10:47:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38674) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mLnza-0007AL-IT for bug-gnu-emacs@gnu.org; Thu, 02 Sep 2021 10:47:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58405) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mLnza-0001FG-Am for bug-gnu-emacs@gnu.org; Thu, 02 Sep 2021 10:47:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mLnza-0004iC-9Y for bug-gnu-emacs@gnu.org; Thu, 02 Sep 2021 10:47:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Philip Kaludercic Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 02 Sep 2021 14:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50297 X-GNU-PR-Package: emacs Original-Received: via spool by 50297-submit@debbugs.gnu.org id=B50297.163059396318048 (code B ref 50297); Thu, 02 Sep 2021 14:47:02 +0000 Original-Received: (at 50297) by debbugs.gnu.org; 2 Sep 2021 14:46:03 +0000 Original-Received: from localhost ([127.0.0.1]:41718 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mLnyd-0004h1-23 for submit@debbugs.gnu.org; Thu, 02 Sep 2021 10:46:03 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:59665) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mLnyY-0004gE-J4 for 50297@debbugs.gnu.org; Thu, 02 Sep 2021 10:46:02 -0400 Original-Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id DF059240101 for <50297@debbugs.gnu.org>; Thu, 2 Sep 2021 16:45:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1630593951; bh=S5X218jxI14UW+XXyrICeVHJtM4d2uf5skrXAjc8zyg=; h=From:To:Cc:Subject:Autocrypt:Date:From; b=B/LSmORPH/BIr0ItOG7dc7ASXkfaEPzFJJZJg9NQ6tTIkXhlQj44YW3JSCdo1h6AA Vki7Wxjf2BV6/jP0iTl1VLjkwUglvnJWFW5fSvvzy0bk2bQextIrfZ4mfUmX7UNP+c oWO5DJdEJiLtrImec7G4cGKIPg2i717NgF61FU8A7/6+1LN5Mi5k3dGT6JDPZWJlOF 3x/93NjYQhGfBqEx8fewr2s9d0Ny63buzJPvmAehwYZ6UYrMRm+3lgfC+/lkM3jt/4 +gGjNKzSYu7PZeMBKZWVztF14Qr5mY3FKE99Dd4le9Ifbjq7xpbrGPmNDHyssGtnNg MJh/ekM4QJo6A== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4H0kHy6m3pz6tm4; Thu, 2 Sep 2021 16:45:50 +0200 (CEST) Autocrypt: addr=philipk@posteo.net; prefer-encrypt=mutual; keydata= mDMEYHHqUhYJKwYBBAHaRw8BAQdAp3GdmYJ6tm5McweY6dEvIYIiry+Oz9rU4MH6NHWK0Ee0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiQBBMWCAA4FiEEDM2H44ZoPt9Ms0eHtVrAHPRh1FwFAmBx6lICGwMFCwkIBwIGFQoJ CAsCBBYCAwECHgECF4AACgkQtVrAHPRh1FyTkgEAjlbGPxFchvMbxzAES3r8QLuZgCxeAXunM9gh io0ePtUBALVhh9G6wIoZhl0gUCbQpoN/UJHI08Gm1qDob5zDxnIHuDgEYHHqUhIKKwYBBAGXVQEF AQEHQNcRB+MUimTMqoxxMMUERpOR+Q4b1KgncDZkhrO2ql1tAwEIB4h4BBgWCAAgFiEEDM2H44Zo Pt9Ms0eHtVrAHPRh1FwFAmBx6lICGwwACgkQtVrAHPRh1Fw1JwD/Qo7kvtib8jy7puyWrSv0MeTS g8qIxgoRWJE/KKdkCLEA/jb9b9/g8nnX+UcwHf/4VfKsjExlnND3FrBviXUW6NcB In-Reply-To: <87mtovds0o.fsf@posteo.net> (Philip Kaludercic's message of "Thu, 02 Sep 2021 15:30:15 +0200") 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:213273 Archived-At: --=-=-= Content-Type: text/plain Philip Kaludercic writes: > An entirely different approach might be to implement a tabulated list > major mode to manage projects, comparable to package-list. For the sake of it, it tried it out how this might look like. It feels clunky as of now, doesn't implement everything that it should and it might make more sense to provide as an additional package. --=-=-= Content-Type: text/plain Content-Disposition: inline diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index e420a4ccca..b438249b95 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -1327,6 +1327,102 @@ project-execute-extended-command (let ((default-directory (project-root (project-current t)))) (call-interactively #'execute-extended-command))) + +;;; Project managment + +(defun project-list-generate-list () + "Generate a list of projects for `tabulated-list-mode'." + (let (entries) + (dolist (root (project-known-project-roots)) + (when-let* ((proj (project--find-in-directory root)) + (root (project-root proj)) + ;; XXX: Name and Type are just to keep the buffer + ;; from looking too empty. + (name (capitalize + (file-name-nondirectory + (directory-file-name root)))) + (type (if (consp proj) (format "%S" (car proj)) "??")) + (data (vector name type root))) + (push (list root data) entries))) + entries)) + +(defun project-list-select () + "Select the project at point." + (interactive) + (project-switch-project (tabulated-list-get-id))) + +(defun project-list-mark-forget () + "Mark the project at point to be forgotten." + (interactive) + (save-mark-and-excursion + (save-restriction + (narrow-to-region (region-beginning) (region-end)) + (goto-char (point-min)) + (while (not (eobp)) + (tabulated-list-put-tag "F" t))))) + +(defun project-list-forget-zombies () + "Mark the project at point to be forgotten." + (interactive) + (save-excursion + (goto-char (point-min)) + (while (not (eobp)) + (unless (file-exists-p (tabulated-list-get-id)) + (tabulated-list-put-tag "F" t))))) + +(defun project-list-unmark () + "Unmark the project at point." + (save-mark-and-excursion + (save-restriction + (narrow-to-region (region-beginning) (region-end)) + (goto-char (point-min)) + (while (not (eobp)) + (tabulated-list-put-tag " " t))))) + +(defun project-list-execute () + "Preform marked actions on the project list." + (interactive) + (let (forget-list) + (save-excursion + (goto-char (point-min)) + (while (not (eobp)) + (when (eq (char-after) ?F) + (push (tabulated-list-get-id) forget-list)) + (forward-line))) + (when (yes-or-no-p (format "Forget %d projects? " (length forget-list))) + (mapc #'project-remove-known-project forget-list) + (tabulated-list-clear-all-tags) + (tabulated-list-print)))) + +(defvar project-list-mode-map + (let ((map (make-sparse-keymap))) + (define-key map (kbd "RET") #'project-list-select) + (define-key map (kbd "f") #'project-list-mark-forget) + (define-key map (kbd "d") #'project-list-mark-forget) + (define-key map (kbd "z") #'project-list-forget-zombies) + (define-key map (kbd "u") #'project-list-unmark) + (define-key map (kbd "x") #'project-list-execute) + map)) + +(define-derived-mode project-list-mode tabulated-list-mode "Project List" + "Major mode for browsing the list of known projects." + (setq tabulated-list-format [("Name" 16 t) + ("Type" 4 nil) + ("Path" 0 t)] + tabulated-list-entries #'project-list-generate-list + tabulated-list-padding 2) + (tabulated-list-init-header) + (tabulated-list-print)) + +;;;###autoload +(defun project-list-projects () + "Display a list of all known projects." + (interactive) + (project--ensure-read-project-list) + (with-current-buffer (get-buffer-create "*Projects*") + (project-list-mode) + (pop-to-buffer-same-window (current-buffer)))) + ;;; Project switching --=-=-= Content-Type: text/plain -- Philip Kaludercic --=-=-=--