[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to force auto-save of buffers not visiting files, right now?
From: |
hw |
Subject: |
Re: how to force auto-save of buffers not visiting files, right now? |
Date: |
Fri, 18 Mar 2022 08:31:48 +0100 |
User-agent: |
Evolution 3.42.4 (3.42.4-1.fc35) |
On Thu, 2022-03-17 at 06:00 +0100, Emanuel Berg via Users list for the GNU
Emacs text editor wrote:
> hw wrote:
>
> > Replace the contents of the current buffer with the output
> > of perltidy, and make a backup of the current buffer.
> >
> > Before and after modifications to contents of buffers are
> > being made, all buffers that need to be auto-saved are being
> > auto-saved.
> >
> > The major-mode of the buffer containing the backup is set to
> > cperl-mode.
>
> Emacs thinks that ...
>
> - First line is not a complete sentence
>
> - Argument ‘arg’ should appear (as ARG) in the doc string
>
> - Lisp symbol ‘cperl-mode’ should appear in quotes
>
> Rats!
>
Thanks! I didn't know that emacs can even think, though :)
(defun my-perltidy-replace ()
"This function replaces the contents of the current buffer with
the output of perltidy, and makes a backup of the current buffer.
Before and after modifications to contents of buffers are being
made, all buffers that need to be auto-saved are being
auto-saved.
The major-mode of the buffer containing the backup is set to
'cperl-mode'."
(interactive "P")
(do-auto-save)
(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)
(do-auto-save)
(cperl-mode))
(linum-mode 1)
(message "buffer contents replaced with output of perltidy; backup is in
%s" tidy_buffer)))
(eval-after-load 'cperl-mode
'(define-key cperl-mode-map (kbd "C-x t i") 'my-perltidy-replace))
- how to force auto-save of buffers not visiting files, right now?, hw, 2022/03/14
- Re: how to force auto-save of buffers not visiting files, right now?, Eli Zaretskii, 2022/03/14
- Re: how to force auto-save of buffers not visiting files, right now?, hw, 2022/03/15
- Re: how to force auto-save of buffers not visiting files, right now?, Jean Louis, 2022/03/15
- Re: how to force auto-save of buffers not visiting files, right now?, Emanuel Berg, 2022/03/15
- Re: how to force auto-save of buffers not visiting files, right now?, hw, 2022/03/17
- Re: how to force auto-save of buffers not visiting files, right now?, Emanuel Berg, 2022/03/17
- Re: how to force auto-save of buffers not visiting files, right now?,
hw <=
- RE: [External] : Re: how to force auto-save of buffers not visiting files, right now?, Drew Adams, 2022/03/18
- Re: [External] : Re: how to force auto-save of buffers not visiting files, right now?, hw, 2022/03/18
- Re: [External] : Re: how to force auto-save of buffers not visiting files, right now?, Emanuel Berg, 2022/03/19
- Re: how to force auto-save of buffers not visiting files, right now?, Eli Zaretskii, 2022/03/15
Re: how to force auto-save of buffers not visiting files, right now?, Michael Heerdegen, 2022/03/15