From: Bozhidar Batsov Date: Sat, 21 Jul 2018 11:00:11 +0000 (+0300) Subject: Make ielm accept an optional buffer name param X-Git-Tag: emacs-27.0.90~4664^2~49 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=6eac401c238b9c98550c645f3c60df9a9668dc61;p=emacs.git Make ielm accept an optional buffer name param The ielm buffer name was hardcoded which made it hard for programs to interactively create ielm buffers with different names and switch to them (e.g. perhaps you want to have one ielm buffer for each of the Elisp projects you're working on). --- diff --git a/lisp/ielm.el b/lisp/ielm.el index b4ad69e4c72..8d1efcdc3bf 100644 --- a/lisp/ielm.el +++ b/lisp/ielm.el @@ -612,17 +612,19 @@ Customized bindings may be defined in `ielm-map', which currently contains: ;;; User command ;;;###autoload -(defun ielm nil +(defun ielm (&optional buf-name) "Interactively evaluate Emacs Lisp expressions. -Switches to the buffer `*ielm*', or creates it if it does not exist. +Switches to the buffer named BUF-NAME if provided (`*ielm*' by default), +or creates it if it does not exist. See `inferior-emacs-lisp-mode' for details." (interactive) - (let (old-point) - (unless (comint-check-proc "*ielm*") - (with-current-buffer (get-buffer-create "*ielm*") + (let (old-point + (buf-name (or buf-name "*ielm*"))) + (unless (comint-check-proc buf-name) + (with-current-buffer (get-buffer-create buf-name) (unless (zerop (buffer-size)) (setq old-point (point))) (inferior-emacs-lisp-mode))) - (pop-to-buffer-same-window "*ielm*") + (pop-to-buffer-same-window buf-name) (when old-point (push-mark old-point)))) (provide 'ielm)