comparison lisp/comint.el @ 34977:29a7d4d1846b

(comint-input-history-ignore): New variable. (comint-read-input-ring): Ignore entries matching comint-input-history-ignore.
author Gerd Moellmann <gerd@gnu.org>
date Tue, 02 Jan 2001 14:15:22 +0000
parents 792f41f27d41
children ebc45a028f0f
comparison
equal deleted inserted replaced
34976:05c36b1fa618 34977:29a7d4d1846b
1 ;;; comint.el --- general command interpreter in a window stuff 1 ;;; comint.el --- general command interpreter in a window stuff
2 2
3 ;; Copyright (C) 1988, 90, 92, 93, 94, 95, 96, 97, 98, 99, 2000 3 ;; Copyright (C) 1988, 90, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 2001
4 ;; Free Software Foundation, Inc. 4 ;; Free Software Foundation, Inc.
5 5
6 ;; Author: Olin Shivers <shivers@cs.cmu.edu> then 6 ;; Author: Olin Shivers <shivers@cs.cmu.edu> then
7 ;; Simon Marshall <simon@gnu.org> 7 ;; Simon Marshall <simon@gnu.org>
8 ;; Maintainer: FSF 8 ;; Maintainer: FSF
294 (defvar comint-input-ring-size 32 294 (defvar comint-input-ring-size 32
295 "Size of input history ring.") 295 "Size of input history ring.")
296 296
297 (defvar comint-input-ring-separator "\n" 297 (defvar comint-input-ring-separator "\n"
298 "Separator between commands in the history file.") 298 "Separator between commands in the history file.")
299
300 (defvar comint-input-history-ignore "^#"
301 "Regexp for history entries that should be ignored when comint initializes.")
299 302
300 (defcustom comint-process-echoes nil 303 (defcustom comint-process-echoes nil
301 "*If non-nil, assume that the subprocess echoes any input. 304 "*If non-nil, assume that the subprocess echoes any input.
302 If so, delete one copy of the input so that only one copy eventually 305 If so, delete one copy of the input so that only one copy eventually
303 appears in the buffer. 306 appears in the buffer.
830 failure to read the history file. 833 failure to read the history file.
831 834
832 This function is useful for major mode commands and mode hooks. 835 This function is useful for major mode commands and mode hooks.
833 836
834 The commands stored in the history file are separated by the 837 The commands stored in the history file are separated by the
835 `comint-input-ring-separator'. The most recent command comes last. 838 `comint-input-ring-separator', and entries that match
839 `comint-input-history-ignore' are ignored. The most recent command
840 comes last.
836 841
837 See also `comint-input-ignoredups' and `comint-write-input-ring'." 842 See also `comint-input-ignoredups' and `comint-write-input-ring'."
838 (cond ((or (null comint-input-ring-file-name) 843 (cond ((or (null comint-input-ring-file-name)
839 (equal comint-input-ring-file-name "")) 844 (equal comint-input-ring-file-name ""))
840 nil) 845 nil)
864 (if (re-search-backward comint-input-ring-separator nil t) 869 (if (re-search-backward comint-input-ring-separator nil t)
865 (setq start (match-end 0)) 870 (setq start (match-end 0))
866 (setq start (point-min))) 871 (setq start (point-min)))
867 (setq history (buffer-substring start end)) 872 (setq history (buffer-substring start end))
868 (goto-char start) 873 (goto-char start)
869 (if (or (null comint-input-ignoredups) 874 (if (and (not (string-match comint-input-history-ignore history))
870 (ring-empty-p ring) 875 (or (null comint-input-ignoredups)
871 (not (string-equal (ring-ref ring 0) history))) 876 (ring-empty-p ring)
877 (not (string-equal (ring-ref ring 0) history))))
872 (progn 878 (progn
873 (ring-insert-at-beginning ring history) 879 (ring-insert-at-beginning ring history)
874 (setq count (1+ count))))))) 880 (setq count (1+ count)))))))
875 (kill-buffer history-buf)) 881 (kill-buffer history-buf))
876 (setq comint-input-ring ring 882 (setq comint-input-ring ring