help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

save-history.el: visiting file literally


From: Torsten Bronger
Subject: save-history.el: visiting file literally
Date: Mon, 02 Oct 2006 20:48:21 +0200
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.50 (gnu/linux)

Hallöchen!

I've recently installed save-history.el by Lars R. Clausen.  Now,
every time I close Emacs, it asks to re-visit the file .save-history
"literally", because currently, it is opened in some non-literally
mode.  The code is rather short, so I dare to cite it here:

--8<---------------cut here---------------start------------->8---
(defun save-history-save ()
  "Save all histories in `save-history-varlist' to `save-history-file'"
  (let ((old-buffer (current-buffer))
        (histbuffer (find-file-noselect save-history-file t t)))
    (switch-to-buffer histbuffer)
    (if (> (buffer-size) 0)
        (delete-region 1 (buffer-size)))
    (insert "(setq\n")
    (mapcar (lambda (x)
              (if (and x (eval x))
                  (progn
                    (insert "  ")
                    (prin1 x histbuffer)
                    (insert "\n    '")
                    (if save-history-max-length
                        (let ((truncated (save-history-truncate-list
                                          (eval x)
                                          save-history-max-length)))
                          (prin1 truncated histbuffer))
                      (prin1 (eval x) histbuffer))
                    (insert "\n"))))
            save-history-varlist)
    (insert ")\n")
    (basic-save-buffer)
    (switch-to-buffer old-buffer)))

(defun save-history-load ()
  "Load histories from `save-history-file'"
  (if (file-exists-p save-history-file)
      (load-file save-history-file)))

(add-hook 'after-init-hook 'save-history-load)
(add-hook 'kill-emacs-hook 'save-history-save)
--8<---------------cut here---------------end--------------->8---

How can I achieve that the save-history-file is read in the proper
way so that re-visiting is not necessary anymore?  Many thanks!

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
                                                    ICQ 264-296-646
                   (See http://ime.webhop.org for Jabber, MSN, etc.)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]