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: Tue, 31 Aug 2021 12:47:50 +0000 Message-ID: <87h7f5ok5l.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="19307"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Dmitry Gutov To: 50297@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Aug 31 15:31:43 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 1mL3rb-0004nK-C2 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 31 Aug 2021 15:31:43 +0200 Original-Received: from localhost ([::1]:33560 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mL3ra-0005ta-45 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 31 Aug 2021 09:31:42 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38708) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mL3CJ-0008G9-54 for bug-gnu-emacs@gnu.org; Tue, 31 Aug 2021 08:49:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49954) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mL3CI-0000mP-3C for bug-gnu-emacs@gnu.org; Tue, 31 Aug 2021 08:49:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mL3CI-0002wA-21 for bug-gnu-emacs@gnu.org; Tue, 31 Aug 2021 08:49: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: Tue, 31 Aug 2021 12:49:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 50297 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.163041408811219 (code B ref -1); Tue, 31 Aug 2021 12:49:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 31 Aug 2021 12:48:08 +0000 Original-Received: from localhost ([127.0.0.1]:33267 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mL3BM-0002up-Ek for submit@debbugs.gnu.org; Tue, 31 Aug 2021 08:48:08 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:43348) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mL3BH-0002uH-Ld for submit@debbugs.gnu.org; Tue, 31 Aug 2021 08:48:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38320) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mL3BG-0006Ur-Kw for bug-gnu-emacs@gnu.org; Tue, 31 Aug 2021 08:47:59 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:46731) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mL3BD-0000LC-Ie for bug-gnu-emacs@gnu.org; Tue, 31 Aug 2021 08:47:58 -0400 Original-Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 5A3E0240104 for ; Tue, 31 Aug 2021 14:47:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1630414072; bh=w1HP9z1M6Y7MElJRyHM/u8LnfKbr0Jl//9TCl2jOUUs=; h=From:To:Cc:Subject:Autocrypt:Date:From; b=HSn7p0dSH4udJcz2rxTTane9DS0bYrwPAUblYNyYNVmriKMBPpC/2tmG78x8m1SjN ha9FJSZVBP7914/uDTQzNRxLNA7aFZHFdJ/4m3imPBrJjOJ992ydC+LVnJO00JEXai BoNxksW68roXNSijHPsZSjE3JUsa/BkhiAB0EbPgiV2G0XFMa6RygXPL6J2MC6ZYL1 Fx40VJNBgP6MvpzYwZxCoWPr80sCwwNVXjqtc68cSzprNhl1l9YsZigFJtn2BKE29Y iwf2+pnSKCm8dcMAyaqZqLYrXHP68CcreYTslipjy31oWAJsYvEgn/RWuknmHEH17U X4s8GzaG4rwxg== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4GzRml39Hvz6tmV; Tue, 31 Aug 2021 14:47:51 +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 Received-SPF: pass client-ip=185.67.36.66; envelope-from=philipk@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:213102 Archived-At: --=-=-= Content-Type: text/plain The following patch introduces a few functions for aggregate project maintenance: - project-find-projects-under Select a directory with projects to index all at once. - project-remove-zombie-projects Check if all known projects still exist and remove those that don't anymore - project-remove-projects-under Remove all projects in a directory (inverse of project-find-projects-under). Especially the last two are useful to maintain a clean project list without having to manually remove every project one by one. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Add-aggregate-project-discovery-and-maintenance-func.patch >From 3431a9123753d769f10621d2f5f6ef72ab0e2f3a Mon Sep 17 00:00:00 2001 From: Philip Kaludercic Date: Tue, 31 Aug 2021 14:12:13 +0200 Subject: [PATCH] Add aggregate project discovery and maintenance functions * project.el (project-remember-project): Add optional no-write argument (project-find-projects-under): Add command (project-remove-zombie-projects): Add command (project-remove-known-projects): Add command --- lisp/progmodes/project.el | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index ae9bf03571..2f251393e2 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -1261,9 +1261,10 @@ project--write-project-list (write-region nil nil filename nil 'silent)))) ;;;###autoload -(defun project-remember-project (pr) +(defun project-remember-project (pr &optional no-write) "Add project PR to the front of the project list. -Save the result in `project-list-file' if the list of projects has changed." +Save the result in `project-list-file' if the list of projects +has changed, and NO-WRITE is nil." (project--ensure-read-project-list) (let ((dir (project-root pr))) (unless (equal (caar project--list) dir) @@ -1271,7 +1272,8 @@ project-remember-project (when (equal dir (car ent)) (setq project--list (delq ent project--list)))) (push (list dir) project--list) - (project--write-project-list)))) + (unless no-write + (project--write-project-list))))) (defun project--remove-from-project-list (project-root report-message) "Remove directory PROJECT-ROOT of a missing project from the project list. @@ -1325,6 +1327,35 @@ project-execute-extended-command (let ((default-directory (project-root (project-current t)))) (call-interactively #'execute-extended-command))) +(defun project-find-projects-under (dir) + "Index all projects below a directory DIR." + (interactive "DDirectory: ") + (let ((count 0)) + (dolist (subdir (directory-files dir t nil t)) + (when-let (pr (project--find-in-directory subdir)) + (project-remember-project pr t) + (message "Found %s..." (project-root pr)) + (setq count (1+ count)))) + (if (zerop count) + (message "No projects found") + (project--write-project-list) + (message "%d project%s found" + count (if (= count 1) "" "s"))))) + +(defun project-remove-zombie-projects () + "Remove all known projects that don't exist any more." + (interactive) + (dolist (proj (project-known-project-roots)) + (unless (file-exists-p proj) + (project-remove-known-project proj)))) + +(defun project-remove-known-projects (dir) + "Remove all known projects below a directory DIR." + (interactive "DDirectory: ") + (dolist (proj (project-known-project-roots)) + (when (file-in-directory-p proj dir) + (project-remove-known-project proj)))) + ;;; Project switching -- 2.30.2 --=-=-= Content-Type: text/plain In GNU Emacs 28.0.50 (build 7, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw scroll bars) of 2021-08-26 built on icterid Repository revision: b74afe63d02f126127d9211c0d1c1dc2cf5dd5bb Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12011000 System Description: Debian GNU/Linux 11 (bullseye) Configured using: 'configure LDFLAGS=-flto 'CFLAGS=-O2 -march=native -mtune=native -pipe' --with-native-compiler' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY INOTIFY PDUMPER PNG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM LUCID ZLIB Important settings: value of $EMACSLOADPATH: value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: Git-Log-View Minor modes in effect: TeX-PDF-mode: t global-git-commit-mode: t magit-auto-revert-mode: t shell-dirtrack-mode: t icomplete-mode: t rcirc-track-minor-mode: t display-time-mode: t winner-mode: t windmove-mode: t electric-pair-mode: t recentf-mode: t save-place-mode: t savehist-mode: t show-paren-mode: t tooltip-mode: t global-eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t tab-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t temp-buffer-resize-mode: t buffer-read-only: t line-number-mode: t indent-tabs-mode: t transient-mark-mode: t Load-path shadows: /home/philip/.config/emacs/elpa/transient-0.3.6/transient hides /home/philip/Code/src/emacs/lisp/transient ~/.config/emacs/site-lisp/autoload hides /home/philip/Code/src/emacs/lisp/emacs-lisp/autoload Features: (shadow emacsbug tramp-archive tramp-gvfs tramp-cache zeroconf tramp tramp-loaddefs trampver tramp-integration files-x tramp-compat ls-lisp flymake-cc macrostep-c cmacexp macrostep preview tex-buf tex-fold reftex-dcr reftex-auc reftex reftex-loaddefs reftex-vars font-latex latex latex-flymake tex-ispell tex-style tex texmathp tex-mode latexenc apropos eieio-opt speedbar ezimage dframe shortdoc vc-annotate help-at-pt gnus-fun cl-print debug backtrace pulse find-func rect markdown-mode shell-command+ rng-xsd xsd-regexp rng-cmpct rng-nxml rng-valid rng-loc rng-uri rng-parse nxml-parse rng-match rng-dt rng-util rng-pttrn nxml-ns nxml-mode nxml-outln nxml-rap nxml-util nxml-enc xmltok xref find-dired grep mhtml-mode css-mode smie eww xdg url-queue mm-url color js cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs sgml-mode facemenu whitespace make-mode dired-aux ffap avy magit-extras bug-reference face-remap magit-submodule magit-obsolete magit-blame magit-stash magit-reflog magit-bisect magit-push magit-pull magit-fetch magit-clone magit-remote magit-commit magit-sequence magit-notes magit-worktree magit-tag magit-merge magit-branch magit-reset magit-files magit-refs magit-status magit magit-repos magit-apply magit-wip magit-log which-func imenu magit-diff git-commit log-edit add-log magit-core magit-autorevert autorevert filenotify magit-margin magit-transient magit-process with-editor term ehelp eshell esh-cmd esh-ext esh-opt esh-proc esh-io esh-arg esh-module esh-groups esh-util shell pcomplete server magit-mode transient format-spec magit-git magit-section magit-utils dash vc-fossil vc-mtn vc-hg vc-git vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs icomplete project memory-report char-fold misearch multi-isearch mailalias bbdb-pgp url-http url-gw url-cache url-auth cus-edit pp cus-start finder-inf bbdb-message autocrypt-message smerge-mode diff-mode jka-compr mule-util smiley gnus-cite flow-fill mm-archive mail-extr gnus-async gnus-bcklg qp sort gnus-ml disp-table autocrypt-gnus autocrypt nndraft nnmh epa-file gnutls network-stream nsm nnmaildir nnfolder vc-backup log-view pcvs-util vc vc-dispatcher diff time-stamp bbdb-gnus bbdb-mua bbdb-com crm nnnil gnus-agent gnus-srvr gnus-score score-mode nnvirtual gnus-msg gnus-art mm-uu mml2015 mm-view mml-smime smime dig nntp gnus-cache gnus-sum shr kinsoku svg dom gnus-group gnus-undo gnus-start gnus-dbus dbus xml gnus-cloud nnimap nnmail mail-source utf7 netrc nnoo gnus-spec gnus-int gnus-range message rmc puny rfc822 mml mml-sec epa mm-decode mm-bodies mm-encode mailabbrev gmm-utils mailheader gnus-win modus-vivendi-theme paredit checkdoc flymake-proc flymake warnings thingatpt flyspell ispell noutline outline easy-mmode gnus-dired dired-x dired dired-loaddefs rcirc parse-time iso8601 rx time bbdb bbdb-site timezone sendmail gnus nnheader gnus-util rmail rmail-loaddefs time-date mail-utils hippie-exp winner windmove elec-pair recentf tree-widget wid-edit saveplace savehist paren modus-operandi-theme modus-themes holidays hol-loaddefs cal-menu calendar cal-loaddefs cus-load setup load compile text-property-search comint ansi-color autoload lisp-mnt mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr tex-site geiser-impl help-fns radix-tree geiser-custom geiser-base ring slime-autoloads info package let-alist derived edmacro kmacro pcase cl-extra help-mode browse-url url url-proxy url-privacy url-expand url-methods url-history url-cookie url-domsuf url-util mailcap url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs password-cache json map url-vars seq byte-opt gv bytecomp byte-compile cconv epg epg-config subr-x cl-loaddefs cl-lib iso-transl tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote threads dbusbind inotify dynamic-setting system-font-setting font-render-setting cairo x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 1167755 519125) (symbols 48 100287 1576) (strings 32 294014 1164412) (string-bytes 1 10068553) (vectors 16 85242) (vector-slots 8 1729184 892975) (floats 8 776 1974) (intervals 56 55886 9874) (buffers 992 65)) -- Philip K. --=-=-=--