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: how to force auto-save of buffers not visiting files, right now? Date: Mon, 14 Mar 2022 05:55:34 +0100 Message-ID: <019b7e509c29caa462ff1c30079ce9bfb8cdc668.camel@adminart.net> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39427"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Evolution 3.42.4 (3.42.4-1.fc35) To: Help GNU Emacs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Mar 14 05:56:14 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 1nTckg-000A1E-9e for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 14 Mar 2022 05:56:14 +0100 Original-Received: from localhost ([::1]:52882 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nTcke-0003K6-Os for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 14 Mar 2022 00:56:12 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:51414) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nTckA-0003IC-0M for help-gnu-emacs@gnu.org; Mon, 14 Mar 2022 00:55:42 -0400 Original-Received: from mo4-p00-ob.smtp.rzone.de ([85.215.255.21]:42869) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nTck8-0006HD-1P for help-gnu-emacs@gnu.org; Mon, 14 Mar 2022 00:55:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1647233735; s=strato-dkim-0002; d=adminart.net; h=Date:To:From:Subject:Message-ID:Cc:Date:From:Subject:Sender; bh=6GFh/1NjePHtORlPwCHp0SDsIWugdiSQg7meDPgvCfA=; b=AUtZD5RGnDxkq+q0dAdq5XNFTaVcrEiJpqIkXrhJ0AuJTF5V1btJP36d7aBjG0nJc3 r8vSWGk0RSO4/5AJdDvBjM0JrpccIILE3Ucd346QgUGbey4PTCIqaH03fPW7nxUqfJWe i5iZtukdUxhdFxcjXeRwMM+jcn0ydNT7GXuH2W9dURqvq/7a325rr73WM4b4sZE9FHB8 A3MnAttEk45aJzrjtngZsppEBoXqdXHJ0ycfDHHqMwvKNqaDFVY7X0pOXMNeO+Kxk8aF 1vOadXcXg0CppncujU49oOh5p+MdlUdgb5gR+/Lgc1ZhaaaWUcBPrnjRdj5TEB2HkjJY oLww== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":JHskdESlcvGJlcww5P8kEdDfB60eDdbwg2z1BLI60U5wCzf09BLZZsSKYxPQaavhGO/kap91D/ptKSRtydLNbfmwvcaIb5qsrA==" X-RZG-CLASS-ID: mo00 Original-Received: from [IPv6:2a09:8e40:1b4d:a200:8ba8:ee:41a9:f22d] by smtp.strato.de (RZmta 47.40.1 AUTH) with ESMTPSA id Cf0e1ay2E4tY3X7 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate) for ; Mon, 14 Mar 2022 05:55:34 +0100 (CET) Received-SPF: none client-ip=85.215.255.21; envelope-from=hw@adminart.net; helo=mo4-p00-ob.smtp.rzone.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, 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:136528 Archived-At: Hi, how do I force auto-saving of a particular buffer, or of all buffers, that are not visiting a file, right now? I would like to improve below function by auto-saving the backup: (defun my-perltidy-replace (arg) "Replace the contents of the current buffer with the output of perltidy, and make a backup of the current buffer." (interactive "P") (save-some-buffers) (let ((tidy_buffer (generate-new-buffer (generate-new-buffer-name (concat "TidyBackup-" (buffer-name)))))) (with-current-buffer (buffer-name) ;; swapping the text can screw up linum mode with two buffers in ;; the same frame when automatically enabled by cperl-mode (linum-mode -1) (shell-command-on-region (point-min) (point-max) "perltidy --standard-output" tidy_buffer) (buffer-swap-text tidy_buffer)) (with-current-buffer tidy_buffer (auto-save-mode nil) (cperl-mode)) (linum-mode 1) (message "buffer contents replaced with output of perltidy; backup is in %s" tidy_buffer))) I want an autosave of the backup once the buffer contents were swapped to keep the original in case something goes wrong. If nothing went wrong, I'll eventually kill the buffer holding the backup, which is why I don't want to save it to a file the buffer would be visiting and which I would have to explicitly delete at some time (and because some of the files would have to be saved on remote hosts, which would make things rather unwieldy). The problem is with "right now". Without further ado, the backup is automatically being saved after "a while", but I need it saved "right now" since meanwhile, things can go wrong. Or is this a bad idea? Another question would be how I can copy all modes of a buffer and apply them to another one. Just enabling cperl-mode works for me, but it's not really nice like this. Somehow, that seems difficult to do.