diff options
author | Bozhidar Batsov <bozhidar@batsov.com> | 2018-07-21 14:00:11 +0300 |
---|---|---|
committer | Bozhidar Batsov <bozhidar@batsov.com> | 2018-07-21 14:00:11 +0300 |
commit | 6eac401c238b9c98550c645f3c60df9a9668dc61 (patch) | |
tree | a086dc0ae73d50f5262968a20372b6dcddba709b /lisp/ielm.el | |
parent | 03e3440dbbfea40b449a9f6f23a3630664275d11 (diff) | |
download | emacs-6eac401c238b9c98550c645f3c60df9a9668dc61.tar.gz |
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).
Diffstat (limited to 'lisp/ielm.el')
-rw-r--r-- | lisp/ielm.el | 14 |
1 files 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) |