From 6eac401c238b9c98550c645f3c60df9a9668dc61 Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Sat, 21 Jul 2018 14:00:11 +0300 Subject: [PATCH] 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). --- lisp/ielm.el | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) 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) -- 2.39.5