all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#49980: 28.0.50; [PATCH] Should we have project-save-buffers?
@ 2021-08-10  9:23 Giap Tran
  2021-08-11  6:52 ` Juri Linkov
  2021-08-11 12:22 ` Dmitry Gutov
  0 siblings, 2 replies; 22+ messages in thread
From: Giap Tran @ 2021-08-10  9:23 UTC (permalink / raw)
  To: 49980

[-- 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

^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2021-08-16 13:22 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-10  9:23 bug#49980: 28.0.50; [PATCH] Should we have project-save-buffers? Giap Tran
2021-08-11  6:52 ` 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

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.