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: Sat, 19 Mar 2022 04:14:38 +0100 Message-ID: <9c3935a33573d50e595f37103434db5e29c21063.camel@adminart.net> References: <019b7e509c29caa462ff1c30079ce9bfb8cdc668.camel@adminart.net> <87zglq200a.fsf@web.de> <8fffdb6b532a1fc1805229acfcf9510c3afe18ec.camel@adminart.net> <87wngsmdwp.fsf@web.de> <9f32ac59eb1bc186b015c0b6c5b94822e70d4135.camel@adminart.net> <87y2164u5p.fsf@web.de> 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="17100"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Evolution 3.42.4 (3.42.4-1.fc35) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Mar 19 04:15:30 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 1nVPYv-0004DZ-DQ for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 19 Mar 2022 04:15:29 +0100 Original-Received: from localhost ([::1]:42928 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVPYt-0007US-W6 for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 18 Mar 2022 23:15:28 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:51862) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVPYB-0007Sp-JZ for help-gnu-emacs@gnu.org; Fri, 18 Mar 2022 23:14:43 -0400 Original-Received: from mo4-p00-ob.smtp.rzone.de ([85.215.255.20]:33137) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVPY9-0004f9-FY for help-gnu-emacs@gnu.org; Fri, 18 Mar 2022 23:14:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1647659678; s=strato-dkim-0002; d=adminart.net; h=References:In-Reply-To:Date:To:From:Subject:Message-ID:Cc:Date:From: Subject:Sender; bh=9v2wkuT0apjWYtzmTRLYNfodP59mgW8YPtt52Ite7go=; b=fJ7muojodCija0K1Z+xsIT9lFu8LfNv7v5QLE3Ssb37ROQyu1OfZzDADAfuvpQi1A1 z5cnbf6cZ0afC2f8GhFRSHjdz8CC3hFd9qRrW4oUbnOqJHroEAHn+0f8+PY5NW1DwV09 aE28xi8tsaYMctYuFJQtPr1FMm4RH1Phk7rOSPskDgM5LPZUcBXaXZJCx1kGVqxfC32S MoexjjP9PJxhIagzF21La4KUQz0siHBrrdquPp3YpHJySIpjw3d8sob9Da5t1flkqer8 dEf0uht/Id54mCaHPv99V9hexTJ96ysIScJJK6IG0vjfrJkRTfbGjcV5tCuC1WKdx2tJ aPWg== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":JHskdESlcvGJlcww5P8kEdDfB60eDdbwg2z1BLI60U5wCzf09BLZZsSKYxPQaavhGO/kap91D/tqxuwp7piPF9poSqa1YYPBvy5k" X-RZG-CLASS-ID: mo00 Original-Received: from [IPv6:2a09:8e40:1b4d:a200:93a0:9c63:a52c:54d8] by smtp.strato.de (RZmta 47.41.1 AUTH) with ESMTPSA id U40bf1y2J3Ec8hh (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate) for ; Sat, 19 Mar 2022 04:14:38 +0100 (CET) In-Reply-To: <87y2164u5p.fsf@web.de> Received-SPF: none client-ip=85.215.255.20; 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_H3=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:136667 Archived-At: On Sat, 2022-03-19 at 02:18 +0100, Michael Heerdegen wrote: > hw writes: > > > When you use perltidy only right before you want to run and test your > > program, you still want to have a backup from before you used perltidy > > so that, if you need to, can try the version that wasn't altered by > > perltidy to see if that makes a difference. Of course you can save > > backups manually, but it's nicer to have that automated. > > But why isn't your code located in a buffer visiting a file? It is. The output of perltidy replaces it. So I can either manually have perltidy save the output to a (temporary) file, mark and delete the source code in the buffer visiting the file, visit the temporary file, mark the altered source code, copy it, paste it into the buffer visiting the file, save it and finally delete the temporary file. That would be quite unwieldy, and I won't have a backup. I guess I could have perltidy overwrite the file that is being visited. In that case, I would have to revert the buffer and the unmodified version is lost, so I still won't have a backup. I'm not sure if and how well undo would work in these cases. I may be wrong, but I'm assuming there is a limit to how much undo information is kept. A simple case like the power going out will destroy all undo information and the unaltered version of the file. I have seen (cheap, but APC) UPSs causing power outages more often than the power went out simply by perferming a self test, and there is no guarantee that more expensive ones may not have the same issue. > > I can't possibly list all things that can go wrong. Maybe you have never > > experienced that a computer or software doesn't work as it should or that > > things can go wrong. If you want to find out, you might use wayland with > > sway [...] > > X crashes often enough, sometimes including the kernel. That's good > enough for me. > Hm, I haven't had that in a very long time. It almost never happens. > > Why would you expect that perltidy will never ever damage your source code > > so that you do not need to keep a copy of what you used it on? That would > > be unreasonable. > > That's what I don't understand: if it's your source code, why is your > question about "how to force auto-save of buffers not visiting files, > right now?"? Because I was trying to find out how to do that. If you look at the function I wrote and\or try it out and see what it does, you'll understand. How would you do what the function does? I found some functions like it on the emacs wiki and on github. I didn't like the ones on the wiki and was unsure about the one on github. So I decided to write my own. It doesn't even matter if you use perltidy or any other program to alter and replace the contents of the current buffer, or if you don't alter them at all (or alter them yourself) and just make transient copies. Being able to make transient copies on the fly can be a useful feature in itself.