annotate lisp/savehist.el @ 66112:9bb08ad57594

*** empty log message ***
author YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
date Sun, 16 Oct 2005 02:23:23 +0000
parents 9b8e76617c8c
children 87310076f109
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
66106
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;;; savehist.el --- Save minibuffer history
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3 ;; Copyright (c) 1997 Free Software Foundation
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;; Author: Hrvoje Niksic <hniksic@xemacs.org>
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; Keywords: minibuffer
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; Version: 0.4
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; any later version.
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; GNU General Public License for more details.
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;; Boston, MA 02110-1301, USA.
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 ;;; Commentary:
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 ;; This package provides the feature of saving minibuffer
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;; history to an external file after exit. When Emacs is about the exit,
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;; `savehist-save' will dump the contents of various minibuffer
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ;; histories (as determined by `savehist-history-variables') to a save
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 ;; file (`~/.emacs-history' by default). Although the package was
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;; designed for saving the minibuffer histories, any variables can be
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 ;; saved that way.
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;; To use savehist, put the following to `~/.emacs':
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 ;;
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;; (require 'savehist)
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 ;; (savehist-load)
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 ;; Be sure to have `savehist.el' in a directory that is in your
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 ;; load-path, and byte-compile it.
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 ;;; Code:
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 ;; User variables
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 (defgroup savehist nil
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 "Save minibuffer history."
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 :group 'minibuffer)
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 (defcustom savehist-history-variables
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 '(
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 ;; Catch-all minibuffer history
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 minibuffer-history
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 ;; File-oriented commands
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 file-name-history
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 ;; Regexp-related reads
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 regexp-history
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 ;; Searches in minibuffer (via `M-r' and such)
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 minibuffer-history-search-history
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 ;; Query replace
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 query-replace-history
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 ;; eval-expression (`M-:')
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 read-expression-history
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 ;; shell-command (`M-!')
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 shell-command-history
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 ;; compile
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 compile-history
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 ;; find-tag (`M-.')
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 find-tag-history
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 ;; grep
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 grep-history
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 ;; Viper stuff
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 vip-ex-history vip-search-history
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 vip-replace1-history vip-replace2-history
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 vip-shell-history vip-search-history
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 ;; XEmacs-specific:
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 ;; Buffer-related commands
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 buffer-history
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 ;; Reads of variables and functions
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 variable-history function-history
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 ;; Extended commands
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 read-command-history
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 ;; Info, lookup, and bookmark historys
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 Info-minibuffer-history
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 Manual-page-minibuffer-history
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 ;; Emacs-specific:
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 ;; Extended commands
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 extended-command-history)
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 "*List of symbols to be saved.
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 Every symbol should refer to a variable. The variable will be saved
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 only if it is bound and has a non-nil value. Thus it is safe to
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 specify a superset of the variables a user is expected to want to
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 save.
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 Default value contains minibuffer history variables used by Emacs, XEmacs,
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 and Viper (uh-oh)."
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 :type '(repeat (symbol :tag "Variable"))
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 :group 'savehist)
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 (defcustom savehist-file "~/.emacs-history"
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 "*File name to save minibuffer history to.
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 The minibuffer history is a series of Lisp expressions, which should be
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 loaded using `savehist-load' from your .emacs. See `savehist-load' for
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 more details."
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 :type 'file
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 :group 'savehist)
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 (defcustom savehist-length 100
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 "*Maximum length of a minibuffer list.
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 If set to nil, the length is unlimited."
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 :type '(choice integer
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 (const :tag "Unlimited" nil))
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 :group 'savehist)
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 (defcustom savehist-modes 384
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 "*Default permissions of the history file.
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 This is decimal, not octal. The default is 384 (0600 in octal)."
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 :type 'integer
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 :group 'savehist)
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 ;; Functions
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 ;;;###autoload
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 (defun savehist-load (&optional no-hook)
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 "Load the minibuffer histories from `savehist-file'.
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 Unless NO-HOOK is specified, the function will also add the save function
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 to `kill-emacs-hook', thus ensuring that the minibuffer contents will be
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 saved before leaving Emacs.
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 This function should be normally used from your Emacs init file. Since it
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 removes your current minibuffer histories, it is unwise to call it at any
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 other time."
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 (interactive "P")
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 (unless no-hook
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 (add-hook 'kill-emacs-hook 'savehist-save))
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 (load savehist-file t))
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 ;;;###autoload
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 (defun savehist-save ()
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 "Save the histories from `savehist-history-variables' to `savehist-file'.
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 A variable will be saved if it is bound and non-nil."
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 (interactive)
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 (save-excursion
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 ;; Is it wise to junk `find-file-hooks' just like that? How else
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 ;; should I avoid font-lock et al.?
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 (let ((find-file-hooks nil)
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 (buffer-exists-p (get-file-buffer savehist-file)))
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 (set-buffer (find-file-noselect savehist-file))
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 (unwind-protect
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 (progn
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 (erase-buffer)
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 (insert
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 ";; -*- emacs-lisp -*-\n"
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 ";; Minibuffer history file.\n\n"
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 ";; This file is automatically generated by `savehist-save'"
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 " or when\n"
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 ";; exiting Emacs.\n"
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 ";; Do not edit. Unless you really want to, that is.\n\n")
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 (let ((print-length nil)
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 (print-string-length nil)
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 (print-level nil)
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 (print-readably t))
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 (dolist (sym savehist-history-variables)
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 (when (and (boundp sym)
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 (symbol-value sym))
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 (prin1
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 `(setq ,sym (quote ,(savehist-delimit (symbol-value sym)
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 savehist-length)))
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 (current-buffer))
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 (insert ?\n))))
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 (save-buffer)
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 (set-file-modes savehist-file savehist-modes))
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 (or buffer-exists-p
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 (kill-buffer (current-buffer)))))))
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 ;; If ARG is a list with less than N elements, return it, else return
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 ;; its subsequence of N elements. If N is nil or ARG is not a list,
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 ;; always return ARG.
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 (defun savehist-delimit (arg n)
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 (if (and n
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 (listp arg)
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 (> (length arg) n))
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 (subseq arg 0 n)
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 arg))
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 (provide 'savehist)
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194
9b8e76617c8c New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 ;;; savehist.el ends here