-;;; em-hist --- history list management
+;;; em-hist.el --- history list management
;; Copyright (C) 1999, 2000 Free Software Foundation
+;; Author: John Wiegley <johnw@gnu.org>
+
;; This file is part of GNU Emacs.
;; GNU Emacs is free software; you can redistribute it and/or modify
(defun eshell-put-history (input &optional ring at-beginning)
"Put a new input line into the history ring."
(unless ring (setq ring eshell-history-ring))
- (subst-char-in-string ?\n ?\177 input t)
(if at-beginning
(ring-insert-at-beginning ring input)
(ring-insert ring input)))
(defun eshell-get-history (index &optional ring)
"Get an input line from the history ring."
- (unless ring (setq ring eshell-history-ring))
- (let ((input (concat (ring-ref ring index))))
- (subst-char-in-string ?\177 ?\n input t)
- input))
+ (ring-ref (or ring eshell-history-ring) index))
(defun eshell-add-to-history ()
"Add INPUT to the history ring.
(ring-empty-p eshell-history-ring)
(not (string-equal (eshell-get-history 0) input))))
(eshell-put-history input))
- (setq eshell-save-history-index eshell-history-ring)
+ (setq eshell-save-history-index eshell-history-index)
(setq eshell-history-index nil))))
(defun eshell-read-history (&optional filename silent)
(if (or (null ignore-dups)
(ring-empty-p ring)
(not (string-equal (ring-ref ring 0) history)))
- (ring-insert-at-beginning ring history)))
+ (ring-insert-at-beginning
+ ring (subst-char-in-string ?\177 ?\n history))))
(setq count (1+ count))))
(setq eshell-history-ring ring
eshell-history-index nil))))))
(with-temp-buffer
(while (> index 0)
(setq index (1- index))
- (insert (ring-ref ring index) ?\n))
+ (let ((start (point)))
+ (insert (ring-ref ring index) ?\n)
+ (subst-char-in-region start (1- (point)) ?\n ?\177)))
(eshell-with-private-file-modes
(write-region (point-min) (point-max) file append
'no-message))))))))
(if (null pos)
(error "Not found")
(setq eshell-history-index pos)
- (message "History item: %d" (- (ring-length eshell-history-ring) pos))
+ (unless (minibuffer-window-active-p (selected-window))
+ (message "History item: %d" (- (ring-length eshell-history-ring) pos)))
;; Can't use kill-region as it sets this-command
(delete-region (save-excursion (eshell-bol) (point)) (point))
(insert-and-inherit (eshell-get-history pos)))))
(goto-char eshell-last-output-end)
(delete-region (point) (point-max))
(when (and text (> (length text) 0))
- (subst-char-in-string ?\177 ?\n text t)
(insert text)
(put-text-property (1- (point)) (point)
'last-search-pos before)