]> code.delx.au - gnu-emacs/blobdiff - lisp/ielm.el
; Revert "Use eldoc-documentation-functions"
[gnu-emacs] / lisp / ielm.el
index 83142257a58c08e39725b46401951c4a43376d0b..dd02778b417c4f9e9ef96abff10f4a4673c65c40 100644 (file)
@@ -1,10 +1,9 @@
-;;; -*- lexical-binding: t -*-
-;;; ielm.el --- interaction mode for Emacs Lisp
+;;; ielm.el --- interaction mode for Emacs Lisp  -*- lexical-binding: t -*-
 
-;; Copyright (C) 1994, 2001-2014 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 2001-2016 Free Software Foundation, Inc.
 
 ;; Author: David Smith <maa036@lancaster.ac.uk>
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
 ;; Created: 25 Feb 1994
 ;; Keywords: lisp
 
@@ -62,11 +61,11 @@ narrowing in effect.  This way you will be certain that none of
 the remaining prompts will be accidentally messed up.  You may
 wish to put something like the following in your init file:
 
-\(add-hook 'ielm-mode-hook
+\(add-hook \\='ielm-mode-hook
           (lambda ()
-             (define-key ielm-map \"\\C-w\" 'comint-kill-region)
+             (define-key ielm-map \"\\C-w\" \\='comint-kill-region)
              (define-key ielm-map [C-S-backspace]
-               'comint-kill-whole-line)))
+               \\='comint-kill-whole-line)))
 
 If you set `comint-prompt-read-only' to t, you might wish to use
 `comint-mode-hook' and `comint-mode-map' instead of
@@ -118,7 +117,7 @@ such as `edebug-defun' to work with such inputs."
 
 (defcustom ielm-mode-hook nil
   "Hooks to be run when IELM (`inferior-emacs-lisp-mode') is started."
-  :options '(turn-on-eldoc-mode)
+  :options '(eldoc-mode)
   :type 'hook
   :group 'ielm)
 (defvaralias 'inferior-emacs-lisp-mode-hook 'ielm-mode-hook)
@@ -168,7 +167,7 @@ This variable is buffer-local.")
 
 (defvar ielm-map
   (let ((map (make-sparse-keymap)))
-    (define-key map "\t" 'completion-at-point)
+    (define-key map "\t" 'ielm-tab)
     (define-key map "\C-m" 'ielm-return)
     (define-key map "\e\C-m" 'ielm-return-for-effect)
     (define-key map "\C-j" 'ielm-send-input)
@@ -201,40 +200,23 @@ This variable is buffer-local.")
 
 ;;; Completion stuff
 
-(defun ielm-tab nil
-  "Possibly indent the current line as Lisp code."
+(defun ielm-tab ()
+  "Indent or complete."
   (interactive)
-  (when (or (eq (preceding-char) ?\n)
-            (eq (char-syntax (preceding-char)) ?\s))
-    (ielm-indent-line)
-    t))
-
-(defun ielm-complete-symbol nil
-  "Complete the Lisp symbol before point."
-  ;; A wrapper for completion-at-point that returns non-nil if
-  ;; completion has occurred
-  (let* ((btick (buffer-modified-tick))
-         (cbuffer (get-buffer "*Completions*"))
-         (ctick (and cbuffer (buffer-modified-tick cbuffer)))
-         (completion-at-point-functions '(lisp-completion-at-point)))
-    (completion-at-point)
-     ;; completion has occurred if:
-    (or
-     ;; the buffer has been modified
-     (not (= btick (buffer-modified-tick)))
-     ;; a completions buffer has been modified or created
-     (if cbuffer
-         (not (= ctick (buffer-modified-tick cbuffer)))
-       (get-buffer "*Completions*")))))
+  (if (or (eq (preceding-char) ?\n)
+          (eq (char-syntax (preceding-char)) ?\s))
+      (ielm-indent-line)
+    (completion-at-point)))
+
 
 (defun ielm-complete-filename nil
   "Dynamically complete filename before point, if in a string."
   (when (nth 3 (parse-partial-sexp comint-last-input-start (point)))
-    (comint-dynamic-complete-filename)))
+    (comint-filename-completion)))
 
 (defun ielm-indent-line nil
   "Indent the current line as Lisp code if it is not a prompt line."
-  (when (save-excursion (comint-bol) (bolp))
+  (when (save-excursion (comint-bol t) (bolp))
     (lisp-indent-line)))
 
 ;;; Working buffer manipulation
@@ -397,7 +379,7 @@ nonempty, then flushes the buffer."
                      (*3 ***)
                      (active-process (ielm-process))
                      (old-standard-output standard-output)
-                     new-standard-output 
+                     new-standard-output
                      ielm-temp-buffer)
                 (set-match-data ielm-match-data)
                 (save-excursion
@@ -528,7 +510,7 @@ evaluations respectively.  If the working buffer is another IELM
 buffer, then the values in the working buffer are used.  The variables
 `*1', `*2' and `*3', yield the process buffer values.
 
-If, at the start of evaluation, `standard-output' is `t' (the
+If, at the start of evaluation, `standard-output' is t (the
 default), `standard-output' is set to a special function that
 causes output to be directed to the ielm buffer.
 `standard-output' is restored after evaluation unless explicitly
@@ -557,8 +539,10 @@ Customized bindings may be defined in `ielm-map', which currently contains:
   (setq comint-input-sender 'ielm-input-sender)
   (setq comint-process-echoes nil)
   (set (make-local-variable 'completion-at-point-functions)
-       '(ielm-tab comint-replace-by-expanded-history
-         ielm-complete-filename ielm-complete-symbol))
+       '(comint-replace-by-expanded-history
+         ielm-complete-filename elisp-completion-at-point))
+  (add-function :before-until (local 'eldoc-documentation-function)
+                #'elisp-eldoc-documentation-function)
   (set (make-local-variable 'ielm-prompt-internal) ielm-prompt)
   (set (make-local-variable 'comint-prompt-read-only) ielm-prompt-read-only)
   (setq comint-get-old-input 'ielm-get-old-input)
@@ -566,7 +550,7 @@ Customized bindings may be defined in `ielm-map', which currently contains:
   (setq mode-line-process '(":%s on " (:eval (buffer-name ielm-working-buffer))))
   ;; Useful for `hs-minor-mode'.
   (setq-local comment-start ";")
-  (setq-local comment-use-global-state t)
+  (setq-local comment-use-syntax t)
 
   (set (make-local-variable 'indent-line-function) 'ielm-indent-line)
   (set (make-local-variable 'ielm-working-buffer) (current-buffer))
@@ -630,7 +614,7 @@ See `inferior-emacs-lisp-mode' for details."
       (with-current-buffer (get-buffer-create "*ielm*")
         (unless (zerop (buffer-size)) (setq old-point (point)))
         (inferior-emacs-lisp-mode)))
-    (switch-to-buffer "*ielm*")
+    (pop-to-buffer-same-window "*ielm*")
     (when old-point (push-mark old-point))))
 
 (provide 'ielm)