Mercurial > emacs
comparison lisp/eshell/em-hist.el @ 31241:3099993cba0f
See ChangeLog
author | John Wiegley <johnw@newartisans.com> |
---|---|
date | Tue, 29 Aug 2000 00:47:45 +0000 |
parents | 34b1ab9d583d |
children | 8e57189d61b4 |
comparison
equal
deleted
inserted
replaced
31240:10b1c85c0bbe | 31241:3099993cba0f |
---|---|
348 nil)) | 348 nil)) |
349 | 349 |
350 (defun eshell-put-history (input &optional ring at-beginning) | 350 (defun eshell-put-history (input &optional ring at-beginning) |
351 "Put a new input line into the history ring." | 351 "Put a new input line into the history ring." |
352 (unless ring (setq ring eshell-history-ring)) | 352 (unless ring (setq ring eshell-history-ring)) |
353 (subst-char-in-string ?\n ?\177 input t) | |
354 (if at-beginning | 353 (if at-beginning |
355 (ring-insert-at-beginning ring input) | 354 (ring-insert-at-beginning ring input) |
356 (ring-insert ring input))) | 355 (ring-insert ring input))) |
357 | 356 |
358 (defun eshell-get-history (index &optional ring) | 357 (defun eshell-get-history (index &optional ring) |
359 "Get an input line from the history ring." | 358 "Get an input line from the history ring." |
360 (unless ring (setq ring eshell-history-ring)) | 359 (ring-ref (or ring eshell-history-ring) index)) |
361 (let ((input (concat (ring-ref ring index)))) | |
362 (subst-char-in-string ?\177 ?\n input t) | |
363 input)) | |
364 | 360 |
365 (defun eshell-add-to-history () | 361 (defun eshell-add-to-history () |
366 "Add INPUT to the history ring. | 362 "Add INPUT to the history ring. |
367 The input is entered into the input history ring, if the value of | 363 The input is entered into the input history ring, if the value of |
368 variable `eshell-input-filter' returns non-nil when called on the | 364 variable `eshell-input-filter' returns non-nil when called on the |
417 nil t)) | 413 nil t)) |
418 (let ((history (match-string 1))) | 414 (let ((history (match-string 1))) |
419 (if (or (null ignore-dups) | 415 (if (or (null ignore-dups) |
420 (ring-empty-p ring) | 416 (ring-empty-p ring) |
421 (not (string-equal (ring-ref ring 0) history))) | 417 (not (string-equal (ring-ref ring 0) history))) |
422 (ring-insert-at-beginning ring history))) | 418 (ring-insert-at-beginning |
419 ring (subst-char-in-string ?\177 ?\n history)))) | |
423 (setq count (1+ count)))) | 420 (setq count (1+ count)))) |
424 (setq eshell-history-ring ring | 421 (setq eshell-history-ring ring |
425 eshell-history-index nil)))))) | 422 eshell-history-index nil)))))) |
426 | 423 |
427 (defun eshell-write-history (&optional filename append) | 424 (defun eshell-write-history (&optional filename append) |
449 ;; Write it all out into a buffer first. Much faster, but | 446 ;; Write it all out into a buffer first. Much faster, but |
450 ;; messier, than writing it one line at a time. | 447 ;; messier, than writing it one line at a time. |
451 (with-temp-buffer | 448 (with-temp-buffer |
452 (while (> index 0) | 449 (while (> index 0) |
453 (setq index (1- index)) | 450 (setq index (1- index)) |
454 (insert (ring-ref ring index) ?\n)) | 451 (let ((start (point))) |
452 (insert (ring-ref ring index) ?\n) | |
453 (subst-char-in-region start (1- (point)) ?\n ?\177))) | |
455 (eshell-with-private-file-modes | 454 (eshell-with-private-file-modes |
456 (write-region (point-min) (point-max) file append | 455 (write-region (point-min) (point-max) file append |
457 'no-message)))))))) | 456 'no-message)))))))) |
458 | 457 |
459 (defun eshell-list-history () | 458 (defun eshell-list-history () |
889 (point) (line-end-position))) | 888 (point) (line-end-position))) |
890 (orig (marker-position eshell-last-output-end))) | 889 (orig (marker-position eshell-last-output-end))) |
891 (goto-char eshell-last-output-end) | 890 (goto-char eshell-last-output-end) |
892 (delete-region (point) (point-max)) | 891 (delete-region (point) (point-max)) |
893 (when (and text (> (length text) 0)) | 892 (when (and text (> (length text) 0)) |
894 (subst-char-in-string ?\177 ?\n text t) | |
895 (insert text) | 893 (insert text) |
896 (put-text-property (1- (point)) (point) | 894 (put-text-property (1- (point)) (point) |
897 'last-search-pos before) | 895 'last-search-pos before) |
898 (set-marker eshell-last-output-end orig) | 896 (set-marker eshell-last-output-end orig) |
899 (goto-char eshell-last-output-end)))))) | 897 (goto-char eshell-last-output-end)))))) |