From: me--- via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 65928@debbugs.gnu.org
Subject: bug#65928: [PATCH] Introduce 'project-save-buffers'
Date: Wed, 13 Sep 2023 22:26:39 +0100 [thread overview]
Message-ID: <dffb442bda0b6b0fa876b43a47491125@elken.dev> (raw)
[-- Attachment #1: Type: text/plain, Size: 183 bytes --]
Hi all,
A small patch to introduce a function from projectile that I feel is
missing, please feel free to yell at me if this has already been
rejected :)
Thanks all,
Ellis (@lkn)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Introduce-project-save-buffers.patch --]
[-- Type: text/x-diff; name=0001-Introduce-project-save-buffers.patch, Size: 2103 bytes --]
From baa257a9c60cb629b1ff60a5965530863e9c11e3 Mon Sep 17 00:00:00 2001
From: Ellis Kenyo <me@elken.dev>
Date: Wed, 13 Sep 2023 22:19:54 +0100
Subject: [PATCH] Introduce 'project-save-buffers'
* etc/NEWS: Update NEWS file.
* lisp/progmodes/project.el (project-save-buffers): Add new function to
save all modified buffers in current project.
---
etc/NEWS | 4 ++++
lisp/progmodes/project.el | 19 +++++++++++++++++++
2 files changed, 23 insertions(+)
diff --git a/etc/NEWS b/etc/NEWS
index c146f464585..d9d5f7ffd94 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -828,6 +828,10 @@ additionally traverse the parent directories until a VCS root is found
(if any), so that the ignore rules for that repository are used, and
the file listing's performance is still optimized.
+*** New command 'project-save-buffers'.
+Save all the modified buffers in the current project. If no relevant
+buffers are found, print a message instead.
+
\f
* Incompatible Lisp Changes in Emacs 30.1
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 2e6ae89a443..45fb33dc77d 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1646,6 +1646,25 @@ defun project-kill-buffers
((funcall query-user)
(mapc #'kill-buffer bufs)))))
+;;;###autoload
+(defun project-save-buffers ()
+ "Save the modified buffers in the current project.
+Two buffers belong to the same project if their
+project instances, as reported by `project-current' in each
+buffer, are identical. "
+ (interactive)
+ (let* ((pr (project-current t))
+ (bufs (cl-remove-if-not (lambda (buf)
+ (and (buffer-file-name buf)
+ (buffer-modified-p buf)))
+ (project-buffers pr))))
+ (if (null bufs)
+ (message "No buffers to save in %s" (project-name pr))
+ (dolist (buf bufs)
+ (with-current-buffer buf
+ (save-buffer)))
+ (message "Saved %d buffers in %s" (length bufs) (project-name pr)))))
+
\f
;;; Project list
--
2.41.0
next reply other threads:[~2023-09-13 21:26 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-13 21:26 me--- via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-09-14 6:51 ` bug#65928: [PATCH] Introduce 'project-save-buffers' Juri Linkov
2023-09-14 13:45 ` Elken via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-14 14:09 ` Stefan Kangas
2023-09-14 14:12 ` Dmitry Gutov
2023-09-14 14:18 ` me--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-14 14:30 ` Dmitry Gutov
2023-09-14 14:07 ` Stefan Kangas
2023-09-14 14:13 ` Dmitry Gutov
2023-09-14 14:16 ` me--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-15 6:32 ` Juri Linkov
2023-09-15 16:39 ` Dmitry Gutov
2023-09-18 6:56 ` Juri Linkov
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dffb442bda0b6b0fa876b43a47491125@elken.dev \
--to=bug-gnu-emacs@gnu.org \
--cc=65928@debbugs.gnu.org \
--cc=me@elken.dev \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.