]> 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 6c8d6944eb9b98f527999399ec73744815d60776..993e9d63a94a8b7cd30178ce349819bfb652ac98 100644 (file)
@@ -1,16 +1,15 @@
 ;;; 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>
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,9 +17,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
 
 ;;; Code:
 
+(eval-when-compile
+  (require 'cl))
+
 (require 'ring)
 (require 'esh-opt)
 (require 'em-pred)
 (require 'eshell)
 
-(defgroup eshell-hist nil
+;;;###autoload
+(eshell-defgroup eshell-hist nil
   "This module provides command history management."
   :tag "History list management"
   :group 'eshell-module)
 
 ;;; 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 'ask
-  "*Determine if history should be automatically saved.
+(defcustom eshell-save-history-on-exit t
+  "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.
@@ -119,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."
@@ -129,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."
@@ -137,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)
 
@@ -172,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")))
@@ -291,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
@@ -581,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)))
@@ -725,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)))))
@@ -831,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)
@@ -838,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)))))
 
@@ -986,5 +994,8 @@ If N is negative, search backwards for the -Nth previous match."
 
 (provide 'em-hist)
 
-;;; arch-tag: 1a847333-f864-4b96-9acd-b549d620b6c6
+;; Local Variables:
+;; generated-autoload-file: "esh-groups.el"
+;; End:
+
 ;;; em-hist.el ends here