From: Giap Tran <txgvnn@gmail.com>
To: 49980@debbugs.gnu.org
Subject: bug#49980: 28.0.50; [PATCH] Should we have project-save-buffers?
Date: Tue, 10 Aug 2021 16:23:34 +0700 [thread overview]
Message-ID: <87czqlodpl.fsf@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 226 bytes --]
Hello,
After using `project-query-replace-regexp to query and replace. I see we don't have the function to save all buffers in project.
So after learning from projectile package. I have this patch, hope it is
useful. Thanks
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: project-save-buffers --]
[-- Type: text/x-diff, Size: 1031 bytes --]
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 4620ea8f47..b257222e21 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1395,5 +1395,22 @@ to directory DIR."
(project-current-inhibit-prompt t))
(call-interactively command))))
+(defun project-save-buffers ()
+ "Save all project buffers."
+ (interactive)
+ (let* ((project (project-current t))
+ (buffers (project--buffer-list project))
+ (modified-buffers (cl-remove-if-not (lambda (buf)
+ (and (buffer-file-name buf)
+ (buffer-modified-p buf)))
+ buffers)))
+ (if (null modified-buffers)
+ (message "No buffers need saving")
+ (dolist (buf modified-buffers)
+ (with-current-buffer buf
+ (save-buffer)))
+ (message "Saved %d buffers" (length modified-buffers)))))
+
+
(provide 'project)
;;; project.el ends here
next reply other threads:[~2021-08-10 9:23 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-10 9:23 Giap Tran [this message]
2021-08-11 6:52 ` bug#49980: 28.0.50; [PATCH] Should we have project-save-buffers? Juri Linkov
2021-08-11 7:38 ` Giap Tran
2021-08-11 12:23 ` Dmitry Gutov
2021-08-12 7:55 ` Juri Linkov
2021-08-13 2:06 ` Dmitry Gutov
2021-08-13 7:12 ` Juri Linkov
2021-08-13 9:39 ` Arthur Miller
2021-08-13 16:05 ` Juri Linkov
2021-08-13 17:22 ` Arthur Miller
2021-08-14 2:25 ` Arthur Miller
2021-08-15 8:32 ` Juri Linkov
2021-08-15 10:44 ` Arthur Miller
2021-08-13 23:54 ` Dmitry Gutov
2021-08-14 2:46 ` Arthur Miller
2021-08-16 0:37 ` Dmitry Gutov
2021-08-16 1:19 ` Arthur Miller
2021-08-16 3:06 ` Dmitry Gutov
2021-08-16 13:22 ` Arthur Miller
2021-08-11 12:22 ` Dmitry Gutov
2021-08-11 13:40 ` Giap Tran
2021-08-13 2:11 ` Dmitry Gutov
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87czqlodpl.fsf@gmail.com \
--to=txgvnn@gmail.com \
--cc=49980@debbugs.gnu.org \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).