[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Removing line and column number settings from some buffers
From: |
Jean Louis |
Subject: |
Re: Removing line and column number settings from some buffers |
Date: |
Fri, 4 Dec 2020 09:07:51 +0300 |
User-agent: |
Mutt/2.0 (3d08634) (2020-11-07) |
* daniela-spit@gmx.it <daniela-spit@gmx.it> [2020-12-04 05:10]:
> What I want to do is to change the Mode Line, but then revert back to how it
> was in that buffer, by continue pressing same keybinding. Can I store the
> old setup and then put it back again.
As each setting is variable one can store it in other variable or into
file, and get it back later.
(defun string-to-file-force (string file)
"Prints string into file, matters not if file exists. Returns FILE as file
name."
(with-temp-file file
(insert string))
file)
(defun file-to-string (file)
"File to string function"
(with-temp-buffer
(insert-file-contents file)
(buffer-string)))
(defun data-to-file (data file)
"PRIN1 Emacs Lisp DATA to FILE"
(string-to-file-force (prin1-to-string data) file))
(defun data-from-file (file)
"Reads and returns Emacs Lisp data from FILE"
(car
(read-from-string
(file-to-string file))))
With those I am storing data into files and reading from files. It can
be just any complex Emacs Lisp data structure like hashes, it can be
lists, variables, just anything.
(setq my-hash (data-from-file "~/tmp/hash"))
(data-to-file mode-line-format "~/.emacs.d/modeline-saved.el")
saves `mode-line-format' into: "~/.emacs.d/modeline-saved.el" with
data looking like this:
("%e" mode-line-front-space mode-line-mule-info mode-line-client
mode-line-modified mode-line-remote mode-line-frame-identification
mode-line-buffer-identification " " mode-line-position (vc-mode vc-mode) " "
mode-line-modes mode-line-misc-info mode-line-end-spaces)
and
(setq mode-line-format (data-from-file "~/.emacs.d/modeline-saved.el"))
loads the data from file back into `mode-line-format'
Jean
- Re: Removing line and column number settings from some buffers, (continued)
- Re: Removing line and column number settings from some buffers, Michael Heerdegen, 2020/12/05
- Re: Removing line and column number settings from some buffers, daniela-spit, 2020/12/05
- RE: Removing line and column number settings from some buffers, Drew Adams, 2020/12/05
- Re: RE: Removing line and column number settings from some buffers, daniela-spit, 2020/12/05
- RE: RE: Removing line and column number settings from some buffers, Drew Adams, 2020/12/05
- Re: RE: RE: Removing line and column number settings from some buffers, daniela-spit, 2020/12/05
- Re: Removing line and column number settings from some buffers, Jean Louis, 2020/12/04
- Re: Removing line and column number settings from some buffers,
Jean Louis <=
- Re: Removing line and column number settings from some buffers, Michael Heerdegen, 2020/12/03
- Re: Removing line and column number settings from some buffers, daniela-spit, 2020/12/03