comparison lisp/comint.el @ 112389:75fb060ecbc3

Don't mess with *temp*. * lisp/obsolete/spell.el: Move from textmodes/spell.el. (spell-string): * lisp/term.el (term-read-input-ring): * lisp/startup.el (display-startup-echo-area-message): * lisp/progmodes/antlr-mode.el (antlr-directory-dependencies): * lisp/gnus/message.el (message-mailer-swallows-blank-line): * lisp/comint.el (comint-read-input-ring): Use with-temp-buffer. * lisp/international/mule.el (ctext-pre-write-conversion): Don't hardcode point-min==1. * lisp/gnus/mm-util.el (mm-find-buffer-file-coding-system): Don't forget to kill the temp buffer.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Thu, 20 Jan 2011 17:36:12 -0500
parents 61f7601898b1
children 9f7614f1a892
comparison
equal deleted inserted replaced
112388:e5e8faa33346 112389:75fb060ecbc3
916 ((not (file-readable-p comint-input-ring-file-name)) 916 ((not (file-readable-p comint-input-ring-file-name))
917 (or silent 917 (or silent
918 (message "Cannot read history file %s" 918 (message "Cannot read history file %s"
919 comint-input-ring-file-name))) 919 comint-input-ring-file-name)))
920 (t 920 (t
921 (let* ((history-buf (get-buffer-create " *temp*")) 921 (let* ((file comint-input-ring-file-name)
922 (file comint-input-ring-file-name)
923 (count 0) 922 (count 0)
924 (size comint-input-ring-size) 923 (size comint-input-ring-size)
925 (ring (make-ring size))) 924 (ring (make-ring size)))
926 (unwind-protect 925 (with-temp-buffer
927 (with-current-buffer history-buf 926 (insert-file-contents file)
928 (widen) 927 ;; Save restriction in case file is already visited...
929 (erase-buffer) 928 ;; Watch for those date stamps in history files!
930 (insert-file-contents file) 929 (goto-char (point-max))
931 ;; Save restriction in case file is already visited... 930 (let (start end history)
932 ;; Watch for those date stamps in history files! 931 (while (and (< count size)
933 (goto-char (point-max)) 932 (re-search-backward comint-input-ring-separator
934 (let (start end history) 933 nil t)
935 (while (and (< count size) 934 (setq end (match-beginning 0)))
936 (re-search-backward comint-input-ring-separator 935 (setq start
937 nil t) 936 (if (re-search-backward comint-input-ring-separator
938 (setq end (match-beginning 0))) 937 nil t)
939 (setq start 938 (match-end 0)
940 (if (re-search-backward comint-input-ring-separator 939 (point-min)))
941 nil t) 940 (setq history (buffer-substring start end))
942 (match-end 0) 941 (goto-char start)
943 (point-min))) 942 (if (and (not (string-match comint-input-history-ignore
944 (setq history (buffer-substring start end)) 943 history))
945 (goto-char start) 944 (or (null comint-input-ignoredups)
946 (if (and (not (string-match comint-input-history-ignore 945 (ring-empty-p ring)
947 history)) 946 (not (string-equal (ring-ref ring 0)
948 (or (null comint-input-ignoredups) 947 history))))
949 (ring-empty-p ring) 948 (progn
950 (not (string-equal (ring-ref ring 0) 949 (ring-insert-at-beginning ring history)
951 history)))) 950 (setq count (1+ count)))))))
952 (progn
953 (ring-insert-at-beginning ring history)
954 (setq count (1+ count)))))))
955 (kill-buffer history-buf))
956 (setq comint-input-ring ring 951 (setq comint-input-ring ring
957 comint-input-ring-index nil))))) 952 comint-input-ring-index nil)))))
958 953
959 (defun comint-write-input-ring () 954 (defun comint-write-input-ring ()
960 "Writes the buffer's `comint-input-ring' to a history file. 955 "Writes the buffer's `comint-input-ring' to a history file.