comparison lisp/ido.el @ 69156:e14bc51fc1eb

(ido-save-history, ido-load-history): Simplify. Don't use find-file-noselect to avoid interference from other modes.
author Kim F. Storm <storm@cua.dk>
date Sun, 26 Feb 2006 00:48:27 +0000
parents 4ac434def21f
children 1e827d428dd6 8a1ee48a8386
comparison
equal deleted inserted replaced
69155:a8425fb1877d 69156:e14bc51fc1eb
1179 (insert "\n)\n"))) 1179 (insert "\n)\n")))
1180 1180
1181 (defun ido-save-history () 1181 (defun ido-save-history ()
1182 "Save ido history and cache information between sessions." 1182 "Save ido history and cache information between sessions."
1183 (interactive) 1183 (interactive)
1184 (if (and ido-last-directory-list ido-save-directory-list-file) 1184 (when (and ido-last-directory-list ido-save-directory-list-file)
1185 (save-excursion 1185 (let ((buf (get-buffer-create " *ido session*"))
1186 (save-window-excursion 1186 (version-control 'never))
1187 (if (find-buffer-visiting ido-save-directory-list-file) 1187 (unwind-protect
1188 (kill-buffer (find-buffer-visiting ido-save-directory-list-file))) 1188 (with-current-buffer buf
1189 (if (file-exists-p ido-save-directory-list-file) 1189 (erase-buffer)
1190 (delete-file ido-save-directory-list-file)) 1190 (ido-pp 'ido-last-directory-list)
1191 (set-buffer (let ((enable-local-variables nil)) 1191 (ido-pp 'ido-work-directory-list)
1192 (find-file-noselect ido-save-directory-list-file t))) 1192 (ido-pp 'ido-work-file-list)
1193 (goto-char (point-min)) 1193 (ido-pp 'ido-dir-file-cache "\n\n ")
1194 (delete-region (point-min) (point-max)) 1194 (insert "\n")
1195 (ido-pp 'ido-last-directory-list)
1196 (ido-pp 'ido-work-directory-list)
1197 (ido-pp 'ido-work-file-list)
1198 (ido-pp 'ido-dir-file-cache "\n\n ")
1199 (insert "\n")
1200 (let ((version-control 'never))
1201 (write-file ido-save-directory-list-file nil)) 1195 (write-file ido-save-directory-list-file nil))
1202 (kill-buffer (current-buffer)))))) 1196 (kill-buffer buf)))))
1203 1197
1204 (defun ido-load-history (&optional arg) 1198 (defun ido-load-history (&optional arg)
1205 "Load ido history and cache information from previous session. 1199 "Load ido history and cache information from previous session.
1206 With prefix argument, reload history unconditionally." 1200 With prefix argument, reload history unconditionally."
1207 (interactive "P") 1201 (interactive "P")
1208 (if (or arg (and ido-save-directory-list-file (not ido-last-directory-list))) 1202 (if (or arg (and ido-save-directory-list-file (not ido-last-directory-list)))
1209 (let ((file (expand-file-name ido-save-directory-list-file)) 1203 (let ((file (expand-file-name ido-save-directory-list-file))
1210 buf) 1204 buf)
1211 (when (file-readable-p file) 1205 (when (file-readable-p file)
1212 (save-excursion 1206 (setq buf (get-buffer-create " *ido session*"))
1213 (save-window-excursion 1207 (unwind-protect
1214 (setq buf (set-buffer (let ((enable-local-variables nil)) 1208 (with-current-buffer buf
1215 (find-file-noselect file)))) 1209 (erase-buffer)
1216 (goto-char (point-min)) 1210 (insert-file-contents file)
1217 (condition-case nil 1211 (condition-case nil
1218 (setq ido-last-directory-list (read (current-buffer)) 1212 (setq ido-last-directory-list (read (current-buffer))
1219 ido-work-directory-list (read (current-buffer)) 1213 ido-work-directory-list (read (current-buffer))
1220 ido-work-file-list (read (current-buffer)) 1214 ido-work-file-list (read (current-buffer))
1221 ido-dir-file-cache (read (current-buffer))) 1215 ido-dir-file-cache (read (current-buffer)))
1222 (error nil)))) 1216 (error nil)))
1223 (kill-buffer buf)))) 1217 (kill-buffer buf)))))
1224 (ido-wash-history)) 1218 (ido-wash-history))
1225 1219
1226 (defun ido-wash-history () 1220 (defun ido-wash-history ()
1227 "Clean-up ido history and cache information. 1221 "Clean-up ido history and cache information.
1228 Removes badly formatted data and ignored directories." 1222 Removes badly formatted data and ignored directories."