X-Git-Url: https://git.hcoop.net/bpt/emacs.git/blobdiff_plain/5df4f04cd32af723742c81095b38ae83b3c2b462..797c9e3df26496debbfb9bf506ad5049b503e98c:/lisp/ielm.el?ds=sidebyside diff --git a/lisp/ielm.el b/lisp/ielm.el index 5974a55566..610cc3ea36 100644 --- a/lisp/ielm.el +++ b/lisp/ielm.el @@ -1,7 +1,6 @@ ;;; ielm.el --- interaction mode for Emacs Lisp -;; Copyright (C) 1994, 2001, 2002, 2003, 2004, 2005, -;; 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +;; Copyright (C) 1994, 2001-2013 Free Software Foundation, Inc. ;; Author: David Smith ;; Maintainer: FSF @@ -60,10 +59,10 @@ override the read-only-ness of IELM prompts is to call `comint-kill-whole-line' or `comint-kill-region' with no 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 `.emacs' file: +wish to put something like the following in your init file: \(add-hook 'ielm-mode-hook - '(lambda () + (lambda () (define-key ielm-map \"\\C-w\" 'comint-kill-region) (define-key ielm-map [C-S-backspace] 'comint-kill-whole-line))) @@ -185,6 +184,13 @@ This variable is buffer-local.") "Keymap for IELM mode.") (defvaralias 'inferior-emacs-lisp-mode-map 'ielm-map) +(easy-menu-define ielm-menu ielm-map + "IELM mode menu." + '("IELM" + ["Change Working Buffer" ielm-change-working-buffer t] + ["Display Working Buffer" ielm-display-working-buffer t] + ["Print Working Buffer" ielm-print-working-buffer t])) + (defvar ielm-font-lock-keywords '(("\\(^\\*\\*\\*[^*]+\\*\\*\\*\\)\\(.*$\\)" (1 font-lock-comment-face) @@ -283,7 +289,7 @@ simply inserts a newline." (defvar ielm-input) -(defun ielm-input-sender (proc input) +(defun ielm-input-sender (_proc input) ;; Just sets the variable ielm-input, which is in the scope of ;; `ielm-send-input's call. (setq ielm-input input)) @@ -304,8 +310,17 @@ simply inserts a newline." ;;; Evaluation -(defun ielm-eval-input (ielm-string) - "Evaluate the Lisp expression IELM-STRING, and pretty-print the result." +(defvar ielm-string) +(defvar ielm-form) +(defvar ielm-pos) +(defvar ielm-result) +(defvar ielm-error-type) +(defvar ielm-output) +(defvar ielm-wbuf) +(defvar ielm-pmark) + +(defun ielm-eval-input (input-string) + "Evaluate the Lisp expression INPUT-STRING, and pretty-print the result." ;; This is the function that actually `sends' the input to the ;; `inferior Lisp process'. All comint-send-input does is works out ;; what that input is. What this function does is evaluates that @@ -318,7 +333,8 @@ simply inserts a newline." ;; ;; NOTE: all temporary variables in this function will be in scope ;; during the eval, and so need to have non-clashing names. - (let (ielm-form ; form to evaluate + (let ((ielm-string input-string) ; input expression, as a string + ielm-form ; form to evaluate ielm-pos ; End posn of parse in string ielm-result ; Result, or error message ielm-error-type ; string, nil if no error @@ -372,7 +388,8 @@ simply inserts a newline." (*** *3)) (kill-buffer (current-buffer)) (set-buffer ielm-wbuf) - (setq ielm-result (eval ielm-form)) + (setq ielm-result + (eval ielm-form lexical-binding)) (setq ielm-wbuf (current-buffer)) (setq ielm-temp-buffer @@ -395,7 +412,7 @@ simply inserts a newline." (goto-char ielm-pmark) (unless ielm-error-type - (condition-case err + (condition-case nil ;; Self-referential objects cause loops in the printer, so ;; trap quits here. May as well do errors, too (setq ielm-output (concat ielm-output (pp-to-string ielm-result))) @@ -489,6 +506,9 @@ Customized bindings may be defined in `ielm-map', which currently contains: (setq comint-get-old-input 'ielm-get-old-input) (set (make-local-variable 'comint-completion-addsuffix) '("/" . "")) (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) (set (make-local-variable 'indent-line-function) 'ielm-indent-line) (set (make-local-variable 'ielm-working-buffer) (current-buffer)) @@ -543,8 +563,6 @@ Customized bindings may be defined in `ielm-map', which currently contains: ;;; User command -;;;###autoload (add-hook 'same-window-buffer-names (purecopy "*ielm*")) - ;;;###autoload (defun ielm nil "Interactively evaluate Emacs Lisp expressions. @@ -555,10 +573,9 @@ Switches to the buffer `*ielm*', or creates it if it does not exist." (with-current-buffer (get-buffer-create "*ielm*") (unless (zerop (buffer-size)) (setq old-point (point))) (inferior-emacs-lisp-mode))) - (pop-to-buffer "*ielm*") + (switch-to-buffer "*ielm*") (when old-point (push-mark old-point)))) (provide 'ielm) -;; arch-tag: ef60e4c0-9c4f-4bdb-8402-271313329790 ;;; ielm.el ends here