(vc-cvs-checkout): Fix bug that broke C-x v ~-style checkouts.
[bpt/emacs.git] / lisp / ielm.el
index 6a603c6..8194a65 100644 (file)
@@ -3,6 +3,7 @@
 ;; Copyright (C) 1994 Free Software Foundation, Inc.
 
 ;; Author: David Smith <maa036@lancaster.ac.uk>
+;; Maintainer: FSF
 ;; Created: 25 Feb 1994
 ;; Keywords: lisp
 
 ;;
 ;;   (autoload 'ielm "ielm" "Start an inferior Emacs Lisp session" t)
 ;;
-;; For completion to work, the comint.el from FSF Emacs 19.23 is
+;; For completion to work, the comint.el from Emacs 19.23 is
 ;; required.  If you do not have it, or if you are running Lemacs,
 ;; also add the following code to your .emacs:
 ;;
 ;;    (setq ielm-mode-hook
 ;;         '(lambda nil
 ;;              (define-key ielm-map "\t"
-;;                 '(lambda nil (interactive) (or (ielm-tab) 
+;;                 '(lambda nil (interactive) (or (ielm-tab)
 ;;                                                 (lisp-complete-symbol))))))
 
 ;; To start: M-x ielm.  Type C-h m in the *ielm* buffer for more info.
 
-;; The latest version is available by WWW from 
+;; The latest version is available by WWW from
 ;;      http://mathssun5.lancs.ac.uk:2080/~maa036/elisp/dir.html
 ;; or by anonymous FTP from
 ;;      /anonymous@wingra.stat.wisc.edu:pub/src/emacs-lisp/ielm.el.gz
@@ -93,18 +94,23 @@ such as `edebug-defun' to work with such inputs."
   :type 'hook
   :group 'ielm)
 
+(defvar * nil
+  "Most recent value evaluated in IELM.")
+
+(defvar ** nil
+  "Second-most-recent value evaluated in IELM.")
+
+(defvar *** nil
+  "Third-most-recent value evaluated in IELM.")
+
 ;;; System variables
 
 (defvar ielm-working-buffer nil
   "Buffer in which IELM sexps will be evaluated.
 This variable is buffer-local.")
 
-(defvar ielm-header 
-  (concat
-   "*** Welcome to IELM version "
-   (substring "$Revision: 1.9 $" 11 -2)
-   " ***  Type (describe-mode) for help.\n"
-   "IELM has ABSOLUTELY NO WARRANTY; type (describe-no-warranty) for details.\n")
+(defvar ielm-header
+  "*** Welcome to IELM ***  Type (describe-mode) for help.\n"
   "Message to display when IELM is started.")
 
 (defvar ielm-map nil)
@@ -121,9 +127,9 @@ This variable is buffer-local.")
   (define-key ielm-map "\C-j" 'ielm-send-input)
   (define-key ielm-map "\e\C-x" 'eval-defun)         ; for consistency with
   (define-key ielm-map "\e\t" 'lisp-complete-symbol) ; lisp-interaction-mode
-  ;; These bindings are from shared-lisp-mode-map -- can you inherit
+  ;; These bindings are from `lisp-mode-shared-map' -- can you inherit
   ;; from more than one keymap??
-  (define-key ielm-map "\e\C-q" 'indent-sexp)      
+  (define-key ielm-map "\e\C-q" 'indent-sexp)
   (define-key ielm-map "\177" 'backward-delete-char-untabify)
   ;; Some convenience bindings for setting the working buffer
   (define-key ielm-map "\C-c\C-b" 'ielm-change-working-buffer)
@@ -131,11 +137,13 @@ This variable is buffer-local.")
   (define-key ielm-map "\C-c\C-v" 'ielm-print-working-buffer))
 
 (defvar ielm-font-lock-keywords
-  (list 
+  (list
    (cons (concat "^" (regexp-quote ielm-prompt)) 'font-lock-keyword-face)
-   '("\\(^\\*\\*\\*[^*]+\\*\\*\\*\\)\\(.*$\\)" (1 font-lock-comment-face) (2 font-lock-reference-face)))
+   '("\\(^\\*\\*\\*[^*]+\\*\\*\\*\\)\\(.*$\\)"
+     (1 font-lock-comment-face)
+     (2 font-lock-constant-face)))
   "Additional expressions to highlight in ielm buffers.")
-       
+
 ;;; Completion stuff
 
 (defun ielm-tab nil
@@ -146,7 +154,7 @@ This variable is buffer-local.")
       (progn
        (ielm-indent-line)
        t)))
-  
+
 (defun ielm-complete-symbol nil
   "Complete the lisp symbol before point."
   ;; A wrapper for lisp-complete symbol that returns non-nil if
@@ -156,9 +164,9 @@ This variable is buffer-local.")
         (ctick (and cbuffer (buffer-modified-tick cbuffer))))
     (lisp-complete-symbol)
      ;; completion has occurred if:
-    (or 
+    (or
      ;; the buffer has been modified
-     (not (= btick (buffer-modified-tick))) 
+     (not (= btick (buffer-modified-tick)))
      ;; a completions buffer has been modified or created
      (if cbuffer
         (not (= ctick (buffer-modified-tick cbuffer)))
@@ -168,12 +176,10 @@ This variable is buffer-local.")
   "Dynamically complete filename before point, if in a string."
   (if (nth 3 (parse-partial-sexp comint-last-input-start (point)))
       (comint-dynamic-complete-filename)))
-     
+
 (defun ielm-indent-line nil
   "Indent the current line as Lisp code if it is not a prompt line."
-  (if (save-excursion
-       (beginning-of-line)
-       (looking-at comint-prompt-regexp)) nil
+  (when (save-excursion (comint-bol) (bolp))
     (lisp-indent-line)))
 
 ;;; Working buffer manipulation
@@ -208,8 +214,8 @@ Complete sexps are evaluated; for incomplete sexps inserts a newline
 and indents.  If however `ielm-dynamic-return' is nil, this always
 simply inserts a newline."
   (interactive)
-  (if ielm-dynamic-return 
-      (let ((state       
+  (if ielm-dynamic-return
+      (let ((state
             (save-excursion
               (end-of-line)
               (parse-partial-sexp (ielm-pm)
@@ -226,8 +232,10 @@ simply inserts a newline."
          (newline-and-indent)))
     (newline)))
 
+(defvar ielm-input)
+
 (defun ielm-input-sender (proc input)
-  ;; Just sets the variable ielm-input, which is in the scope of 
+  ;; Just sets the variable ielm-input, which is in the scope of
   ;; `ielm-send-input's call.
   (setq ielm-input input))
 
@@ -302,15 +310,15 @@ simply inserts a newline."
              (if (ielm-is-whitespace (substring ielm-string ielm-pos))
                  ;; need this awful let convolution to work around
                  ;; an Emacs bug involving local vbls and let binding
-                 (let ((:save :)
-                       (::save ::)
-                       (:::save :::))
+                 (let ((*save *)
+                       (**save **)
+                       (***save ***))
                    (save-excursion
                      (set-buffer ielm-working-buffer)
                      (condition-case err
-                         (let ((: :save)
-                               (:: ::save)
-                               (::: :::save)
+                         (let ((* *save)
+                               (** **save)
+                               (*** ***save)
                                (ielm-obuf (current-buffer)))
                            (setq ielm-result (eval ielm-form))
                            (setq ielm-wbuf (current-buffer))
@@ -346,10 +354,10 @@ simply inserts a newline."
                (if ielm-noisy (ding))
                (setq ielm-output (concat ielm-output "*** " ielm-error-type " ***  "))
                (setq ielm-output (concat ielm-output ielm-result)))
-           ;; There was no error, so shift the ::: values
-           (setq ::: ::)
-           (setq :: :)
-           (setq : ielm-result))
+           ;; There was no error, so shift the *** values
+           (setq *** **)
+           (setq ** *)
+           (setq * ielm-result))
          (setq ielm-output (concat ielm-output "\n"))))
     (setq ielm-output (concat ielm-output ielm-prompt))
     (comint-output-filter (ielm-process) ielm-output)))
@@ -370,6 +378,8 @@ simply inserts a newline."
 
 ;;; Major mode
 
+(put 'inferior-emacs-lisp-mode 'mode-class 'special)
+
 (defun inferior-emacs-lisp-mode nil
   "Major mode for interactively evaluating Emacs Lisp expressions.
 Uses the interface provided by `comint-mode' (which see).
@@ -382,10 +392,10 @@ Uses the interface provided by `comint-mode' (which see).
   Inputs longer than one line are moved to the line following the
   prompt (but see variable `ielm-dynamic-multiline-inputs').
 
-* \\[comint-dynamic-complete] completes Lisp symbols (or filenames, within strings), 
+* \\[comint-dynamic-complete] completes Lisp symbols (or filenames, within strings),
   or indents the line if there is nothing to complete.
 
-During evaluations, the values of the variables `:', `::', and `:::'
+During evaluations, the values of the variables `*', `**', and `***'
 are the results of the previous, second previous and third previous
 evaluations respectively.
 
@@ -415,7 +425,7 @@ Customised bindings may be defined in `ielm-map', which currently contains:
   (setq paragraph-start comint-prompt-regexp)
   (setq comint-input-sender 'ielm-input-sender)
   (setq comint-process-echoes nil)
-  (setq comint-dynamic-complete-functions 
+  (setq comint-dynamic-complete-functions
        '(ielm-tab comint-replace-by-expanded-history ielm-complete-filename ielm-complete-symbol))
   (setq comint-get-old-input 'ielm-get-old-input)
   (make-local-variable 'comint-completion-addsuffix)
@@ -435,18 +445,18 @@ Customised bindings may be defined in `ielm-map', which currently contains:
   (setq fill-paragraph-function 'lisp-fill-paragraph)
 
   ;; Value holders
-  (setq : nil)
-  (make-local-variable ':)
-  (setq :: nil)
-  (make-local-variable '::)
-  (setq ::: nil)
-  (make-local-variable ':::)
+  (setq * nil)
+  (make-local-variable '*)
+  (setq ** nil)
+  (make-local-variable '**)
+  (setq *** nil)
+  (make-local-variable '***)
 
   ;; font-lock support
   (make-local-variable 'font-lock-defaults)
-  (setq font-lock-defaults 
+  (setq font-lock-defaults
        '(ielm-font-lock-keywords nil nil ((?: . "w") (?- . "w") (?* . "w"))))
-  
+
   ;; A dummy process to keep comint happy. It will never get any input
   (if (comint-check-proc (current-buffer)) nil
     (start-process "ielm" (current-buffer) "cat")
@@ -485,4 +495,6 @@ Switches to the buffer `*ielm*', or creates it if it does not exist."
       (inferior-emacs-lisp-mode)))
   (pop-to-buffer "*ielm*"))
 
+(provide 'ielm)
+
 ;;; ielm.el ends here