From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: hw Newsgroups: gmane.emacs.help Subject: Re: how to force auto-save of buffers not visiting files, right now? Date: Thu, 17 Mar 2022 05:35:32 +0100 Message-ID: <3119c8db-f395-3ae3-b027-b03553dbcc69@adminart.net> References: <019b7e509c29caa462ff1c30079ce9bfb8cdc668.camel@adminart.net> <8335jklmyf.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------t8XNLHKlu000U9diIHbrvdNO" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32968"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.2 To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu Mar 17 05:36:55 2022 Return-path: Envelope-to: geh-help-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 1nUhsc-0008LR-IR for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 17 Mar 2022 05:36:54 +0100 Original-Received: from localhost ([::1]:60778 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nUhsb-0000aG-04 for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 17 Mar 2022 00:36:53 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:47316) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUhrr-0000a4-Ez for help-gnu-emacs@gnu.org; Thu, 17 Mar 2022 00:36:07 -0400 Original-Received: from mo4-p00-ob.smtp.rzone.de ([81.169.146.218]:41595) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUhrm-0006xY-VG for help-gnu-emacs@gnu.org; Thu, 17 Mar 2022 00:36:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1647491732; s=strato-dkim-0002; d=adminart.net; h=In-Reply-To:References:To:Subject:From:Date:Message-ID:Cc:Date:From: Subject:Sender; bh=XjU8ehs8ga5kSAi3nSHsQu7/S10lH4MHCoZXdTw1r14=; b=tAjmkgBBUIMjOW64Raid4g10d1IO8m97M1L3ZGenRazIadb36/5zN5fqSnEPDZAJGr iInIhXS9Y9Famdu2fHjpRGfdqgHEAjOeAx0UXytlSFdn9j2WnvLdUivG2xu8PBvVuve5 h3hERJ+JkEfR/uPiDdyFx/43aXR2VWqa3EtYmbIUgVlQQHc3SR1M4AFvGhIBRxe7iNHv mShi1NO+rDEFb9Ok160RdnIGE2OTLr95Cpr/M0jOrn6Dc2LwbkfWOmQvGI/uEH9mVCg7 t8HiWpF+vrapFWshYhfryWYgiK6YvdnVXzLIsxOvtJOf13MZXFnRAe0kJu/5HPKZdOe1 yayg== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":O2kGeEG7b/pS1FS4THaxjVF9w0vVgfQ9xGcjwO5WMRo5c+h5ceMqQWZ/wat1/QVDA7yXpByJNi5Q" X-RZG-CLASS-ID: mo00 Original-Received: from himinbjorg.adminart.net by smtp.strato.de (RZmta 47.41.1 AUTH) with ESMTPSA id U40bf1y2H4ZW10V (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate) for ; Thu, 17 Mar 2022 05:35:32 +0100 (CET) Original-Received: from toy.adminart.net ([192.168.3.55]) by himinbjorg.adminart.net with esmtp (Exim 4.94.2) (envelope-from ) id 1nUhrI-003nYY-7B for help-gnu-emacs@gnu.org; Thu, 17 Mar 2022 05:35:32 +0100 Content-Language: de-DE In-Reply-To: Received-SPF: none client-ip=81.169.146.218; envelope-from=hw@adminart.net; helo=mo4-p00-ob.smtp.rzone.de X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:136622 Archived-At: This is a multi-part message in MIME format. --------------t8XNLHKlu000U9diIHbrvdNO Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 3/15/22 07:47, Jean Louis wrote: > * hw [2022-03-15 08:22]: >> Yes, and how do I make it so that a buffer not visiting a file is >> being auto-saved without delay once the auto-save-mode has been >> enabled? Or can I make it auto-save once before enabling auto-save >> mode? > > Buffer not visiting file does not know where it should be saved. I am > using and doing something similar like you, I use buffers without file > names as additional scratch buffers. If Emacs session is over, those > temporary buffers are over. And I like sometimes to invoke them in > different mode, such as `sql-mode' or `emacs-lisp-mode'. Because they > are not connected to files, they can't be saved so easily. > > (defvar rcd-temp-buffer-mode-history nil) > (defvar rcd-temp-file-directory "~/tmp/") > (defvar rcd-temp-buffer-name "RCD TEMPORARY BUFFER") > (defvar rcd-temp-buffer-modes '(("adoc-mode" . "adoc") > ("emacs-lisp-mode" . "el") > ("lisp-mode" . ".lisp") > ("markdown-mode" . ".md") > ("org-mode" . "org") > ("sql-mode" . "sql") > ("fundamental-mode" . "txt") > ("html-mode" . "html"))) > > > (defun rcd-temp-buffer (&optional name mode) > "Generate new temporary buffer." > (interactive "p") > (let* ((format (concat "*" rcd-temp-buffer-name "%s%s*")) > (buffer (if name (format format ": " name) (format format "" "")))) > (switch-to-buffer (generate-new-buffer buffer)) > (if current-prefix-arg > (let* ((mode (completing-read > "Mode: " > (map-keys rcd-temp-buffer-modes) nil t nil > 'rcd-temp-buffer-mode-history))) > (funcall (intern mode))) > (funcall (intern (or mode "fundamental-mode")))))) > > and that function could be adopted to provide file names for buffers: > > (defun rcd-temp-buffer (&optional name mode) > "Generate new temporary buffer." > (interactive "p") > (let* ((format (concat "*" rcd-temp-buffer-name "%s%s*")) > (buffer (if name (format format ": " name) (format format "" ""))) > (file-name (concat rcd-temp-file-directory (format-time-string "%Y-%m-%d-%H:%M:%S.txt")))) > (switch-to-buffer (generate-new-buffer buffer)) > (setq buffer-file-name file-name) > (if current-prefix-arg > (let* ((mode (completing-read > "Mode: " > (map-keys rcd-temp-buffer-modes) nil t nil > 'rcd-temp-buffer-mode-history))) > (funcall (intern mode))) > (funcall (intern (or mode "fundamental-mode")))))) > > Now if I have `do-auto-save' those temporary buffers would be saved I guess. Thank you very much! With this, it's not at all necessary to tie the buffers to files. The do-auto-save function saves "all buffers that need it", and does it "right now", without delay when called. That's perfect for what I'm doing. --------------t8XNLHKlu000U9diIHbrvdNO Content-Type: text/x-emacs-lisp; charset=UTF-8; name="tidyperl.el" Content-Disposition: attachment; filename="tidyperl.el" Content-Transfer-Encoding: base64 CihkZWZ1biBteS1wZXJsdGlkeS1yZXBsYWNlIChhcmcpCiAgIlJlcGxhY2UgdGhlIGNvbnRl bnRzIG9mIHRoZSBjdXJyZW50IGJ1ZmZlciB3aXRoIHRoZSBvdXRwdXQgb2YKcGVybHRpZHks IGFuZCBtYWtlIGEgYmFja3VwIG9mIHRoZSBjdXJyZW50IGJ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