]> code.delx.au - gnu-emacs/blobdiff - lisp/eshell/em-hist.el
Merge from emacs-23; up to 2010-06-03T22:16:02Z!dann@ics.uci.edu
[gnu-emacs] / lisp / eshell / em-hist.el
index 4c8daac140f9cc136ee732a46e2e4ccfad8bf8a9..993e9d63a94a8b7cd30178ce349819bfb652ac98 100644 (file)
@@ -1,7 +1,6 @@
 ;;; em-hist.el --- history list management
 
-;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-;;   2008  Free Software Foundation, Inc.
+;; Copyright (C) 1999-2011  Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <johnw@gnu.org>
 
@@ -71,8 +70,9 @@
 
 ;;; User Variables:
 
-(defcustom eshell-hist-load-hook '(eshell-hist-initialize)
-  "*A list of functions to call when loading `eshell-hist'."
+(defcustom eshell-hist-load-hook nil
+  "A list of functions to call when loading `eshell-hist'."
+  :version "24.1"                      ; removed eshell-hist-initialize
   :type 'hook
   :group 'eshell-hist)
 
    (function
     (lambda ()
       (remove-hook 'kill-emacs-hook 'eshell-save-some-history))))
-  "*A hook that gets run when `eshell-hist' is unloaded."
+  "A hook that gets run when `eshell-hist' is unloaded."
   :type 'hook
   :group 'eshell-hist)
 
 (defcustom eshell-history-file-name
-  (concat eshell-directory-name "history")
-  "*If non-nil, name of the file to read/write input history.
+  (expand-file-name "history" eshell-directory-name)
+  "If non-nil, name of the file to read/write input history.
 See also `eshell-read-history' and `eshell-write-history'.
 If it is nil, Eshell will use the value of HISTFILE."
   :type 'file
   :group 'eshell-hist)
 
 (defcustom eshell-history-size 128
-  "*Size of the input history ring.  If nil, use envvar HISTSIZE."
+  "Size of the input history ring.  If nil, use envvar HISTSIZE."
   :type 'integer
   :group 'eshell-hist)
 
 (defcustom eshell-hist-ignoredups nil
-  "*If non-nil, don't add input matching the last on the input ring.
+  "If non-nil, don't add input matching the last on the input ring.
 This mirrors the optional behavior of bash."
   :type 'boolean
   :group 'eshell-hist)
 
 (defcustom eshell-save-history-on-exit t
-  "*Determine if history should be automatically saved.
+  "Determine if history should be automatically saved.
 History is always preserved after sanely exiting an Eshell buffer.
 However, when Emacs is being shut down, this variable determines
 whether to prompt the user.
@@ -121,7 +121,7 @@ If set to t, history will always be saved, silently."
   (function
    (lambda (str)
      (not (string-match "\\`\\s-*\\'" str))))
-  "*Predicate for filtering additions to input history.
+  "Predicate for filtering additions to input history.
 Takes one argument, the input.  If non-nil, the input may be saved on
 the input history list.  Default is to save anything that isn't all
 whitespace."
@@ -131,7 +131,7 @@ whitespace."
 (put 'eshell-input-filter 'risky-local-variable t)
 
 (defcustom eshell-hist-match-partial t
-  "*If non-nil, movement through history is constrained by current input.
+  "If non-nil, movement through history is constrained by current input.
 Otherwise, typing <M-p> and <M-n> will always go to the next history
 element, regardless of any text on the command line.  In that case,
 <C-c M-r> and <C-c M-s> still offer that functionality."
@@ -139,25 +139,25 @@ element, regardless of any text on the command line.  In that case,
   :group 'eshell-hist)
 
 (defcustom eshell-hist-move-to-end t
-  "*If non-nil, move to the end of the buffer before cycling history."
+  "If non-nil, move to the end of the buffer before cycling history."
   :type 'boolean
   :group 'eshell-hist)
 
 (defcustom eshell-hist-event-designator
   "^!\\(!\\|-?[0-9]+\\|\\??[^:^$%*?]+\\??\\|#\\)"
-  "*The regexp used to identifier history event designators."
+  "The regexp used to identifier history event designators."
   :type 'regexp
   :group 'eshell-hist)
 
 (defcustom eshell-hist-word-designator
   "^:?\\([0-9]+\\|[$^%*]\\)?\\(\\*\\|-[0-9]*\\|[$^%*]\\)?"
-  "*The regexp used to identify history word designators."
+  "The regexp used to identify history word designators."
   :type 'regexp
   :group 'eshell-hist)
 
 (defcustom eshell-hist-modifier
   "^\\(:\\([hretpqx&g]\\|s/\\([^/]*\\)/\\([^/]*\\)/\\)\\)*"
-  "*The regexp used to identity history modifiers."
+  "The regexp used to identity history modifiers."
   :type 'regexp
   :group 'eshell-hist)
 
@@ -174,7 +174,7 @@ element, regardless of any text on the command line.  In that case,
     ([(meta ?n)]      . eshell-next-matching-input-from-input)
     ([up]             . eshell-previous-matching-input-from-input)
     ([down]           . eshell-next-matching-input-from-input))
-  "*History keys to bind differently if point is in input text."
+  "History keys to bind differently if point is in input text."
   :type '(repeat (cons (vector :tag "Keys to bind"
                               (repeat :inline t sexp))
                       (function :tag "Command")))
@@ -293,7 +293,7 @@ element, regardless of any text on the command line.  In that case,
 
 (defun eshell-save-some-history ()
   "Save the history for any open Eshell buffers."
-  (eshell-for buf (buffer-list)
+  (dolist (buf (buffer-list))
     (if (buffer-live-p buf)
        (with-current-buffer buf
          (if (and eshell-mode
@@ -583,6 +583,10 @@ See also `eshell-read-history'."
                  posb (cdr posb)
                  pose (cdr pose))))))))
 
+(defvar pcomplete-stub)
+(defvar pcomplete-last-completion-raw)
+(declare-function pcomplete-actual-arg "pcomplete")
+
 (defun eshell-complete-history-reference ()
   "Complete a history reference, by completing the event designator."
   (let ((arg (pcomplete-actual-arg)))
@@ -727,7 +731,7 @@ matched."
          (narrow-to-region here (point))
          (goto-char (point-min))
          (let ((modifiers (cdr (eshell-parse-modifiers))))
-           (eshell-for mod modifiers
+           (dolist (mod modifiers)
              (setq hist (funcall mod hist)))
            hist))
       (delete-region here (point)))))
@@ -833,6 +837,8 @@ With prefix argument N, search for Nth previous match.
 If N is negative, find the next or Nth next match."
   (interactive (eshell-regexp-arg "Previous input matching (regexp): "))
   (setq arg (eshell-search-arg arg))
+  (if (> eshell-last-output-end (point))
+      (error "Point not located after prompt"))
   (let ((pos (eshell-previous-matching-input-string-position regexp arg)))
     ;; Has a match been found?
     (if (null pos)
@@ -840,7 +846,7 @@ If N is negative, find the next or Nth next match."
       (setq eshell-history-index 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
+      ;; Can't use kill-region as it sets this-command
       (delete-region eshell-last-output-end (point))
       (insert-and-inherit (eshell-get-history pos)))))
 
@@ -992,5 +998,4 @@ If N is negative, search backwards for the -Nth previous match."
 ;; generated-autoload-file: "esh-groups.el"
 ;; End:
 
-;; arch-tag: 1a847333-f864-4b96-9acd-b549d620b6c6
 ;;; em-hist.el ends here