[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/inf-ruby ac80ea9fd3 188/265: Make run-ruby do one thing on
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/inf-ruby ac80ea9fd3 188/265: Make run-ruby do one thing only |
Date: |
Sat, 9 Jul 2022 21:59:25 -0400 (EDT) |
branch: elpa/inf-ruby
commit ac80ea9fd35f14c0f7048445de2fc9b77a7f3cee
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>
Make run-ruby do one thing only
- Extract run-ruby-or-pop-to-buffer, to be used by the former's callers.
- Use it in inf-ruby.
- Yet to be integrated with the inf-ruby-console-* code.
Fixes #96
---
inf-ruby.el | 79 ++++++++++++++++++++++++++++++++-----------------------------
1 file changed, 41 insertions(+), 38 deletions(-)
diff --git a/inf-ruby.el b/inf-ruby.el
index 880c960072..ba1ff9be53 100755
--- a/inf-ruby.el
+++ b/inf-ruby.el
@@ -307,10 +307,10 @@ The following commands are available:
(defun inf-ruby (&optional impl)
"Run an inferior Ruby process in a buffer.
With prefix argument, prompts for which Ruby implementation
-\(from the list `inf-ruby-implementations') to use. Runs the
-hooks `inf-ruby-mode-hook' \(after the `comint-mode-hook' is
-run)."
+\(from the list `inf-ruby-implementations') to use.
+If there is a Ruby process running in an existing buffer, switch
+to that buffer. Otherwise create a new buffer."
(interactive (list (if current-prefix-arg
(completing-read "Ruby Implementation: "
(mapc #'car
inf-ruby-implementations))
@@ -318,50 +318,53 @@ run)."
(setq impl (or impl "ruby"))
(let ((command (cdr (assoc impl inf-ruby-implementations))))
- (run-ruby command impl)))
+ (run-ruby-or-pop-to-buffer command impl
+ (or (inf-ruby-buffer)
+ inf-ruby-buffer))))
;;;###autoload
-(defun run-ruby (&optional command name)
- "Run an inferior Ruby process in a buffer related to the current project.
-If there is a process already running in a corresponding buffer,
-switch to that buffer. Otherwise create a new buffer.
+(defun run-ruby (command &optional name)
+ "Run an inferior Ruby process, input and output in a buffer.
+
The consecutive buffer names will be:
`*NAME*', `*NAME*<2>', `*NAME*<3>' and so on.
-NAME defaults to \"ruby\". COMMAND defaults to the default entry
-in `inf-ruby-implementations'.
+NAME defaults to \"ruby\".
-\(Type \\[describe-mode] in the process buffer for the list of commands.)"
+Runs the hooks `comint-mode-hook' and `inf-ruby-mode-hook'.
- (interactive)
- (setq command (or command (cdr (assoc inf-ruby-default-implementation
- inf-ruby-implementations))))
+\(Type \\[describe-mode] in the process buffer for the list of commands.)"
(setq name (or name "ruby"))
- (if (not (comint-check-proc (inf-ruby-buffer)))
- (let ((commandlist (split-string-and-unquote command))
- (buffer (current-buffer))
- (process-environment process-environment))
- ;; http://debbugs.gnu.org/15775
- (setenv "PAGER" (executable-find "cat"))
- (set-buffer (apply 'make-comint-in-buffer
- name
- (generate-new-buffer-name (format "*%s*" name))
- (car commandlist)
- nil (cdr commandlist)))
- (inf-ruby-mode)
- (ruby-remember-ruby-buffer buffer)
- (push (current-buffer) inf-ruby-buffers)
- (setq inf-ruby-buffer-impl-name name
- inf-ruby-buffer-command command)))
-
- (let ((buffer (inf-ruby-buffer)))
- (with-current-buffer buffer
- (if (and (string= inf-ruby-buffer-impl-name name)
- (string= inf-ruby-buffer-command command))
- (pop-to-buffer (setq inf-ruby-buffer buffer))
- (error "Found inf-ruby buffer for directory %s but it was run with
different COMMAND and/or NAME."
- (expand-file-name default-directory))))))
+ (let ((commandlist (split-string-and-unquote command))
+ (buffer (current-buffer))
+ (process-environment process-environment))
+ ;; http://debbugs.gnu.org/15775
+ (setenv "PAGER" (executable-find "cat"))
+ (set-buffer (apply 'make-comint-in-buffer
+ name
+ (generate-new-buffer-name (format "*%s*" name))
+ (car commandlist)
+ nil (cdr commandlist)))
+ (inf-ruby-mode)
+ (ruby-remember-ruby-buffer buffer)
+ (push (current-buffer) inf-ruby-buffers)
+ (setq inf-ruby-buffer-impl-name name
+ inf-ruby-buffer-command command))
+
+ (pop-to-buffer (setq inf-ruby-buffer (current-buffer))))
+
+(defun run-ruby-or-pop-to-buffer (command &optional name buffer)
+ (if (not (and buffer
+ (comint-check-proc buffer)))
+ (run-ruby command name)
+ (pop-to-buffer buffer)
+ (unless (and (string= inf-ruby-buffer-impl-name name)
+ (string= inf-ruby-buffer-command command))
+ (error (concat "Found inf-ruby buffer, but it was created using "
+ "a different NAME-COMMAND combination: %s %s")
+ inf-ruby-buffer-impl-name
+ inf-ruby-buffer-command))))
(defun inf-ruby-proc ()
"Return the inferior Ruby process for the current buffer or project.
- [nongnu] elpa/inf-ruby 562fa9a422 094/265: Close #37, (continued)
- [nongnu] elpa/inf-ruby 562fa9a422 094/265: Close #37, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 55559dfaac 144/265: fix OpenStruct.new syntax to work with ruby 1.8.7, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 488fc1b129 147/265: Refine the previous change, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby aad537f010 156/265: Merge pull request #82 from mkaschenko/ruby-send-buffer, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 3968234eed 150/265: Merge pull request #77 from syohex/update-url, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby a2a6434bb3 163/265: Reverting to re-search-forward, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 9f02c4a1c8 158/265: Adding ruby-debug pattern, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 2598a06923 164/265: Updating docstrings to follow Emacs' conventions, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 8c8819f84a 167/265: Improve docs, add autoloads, rename and make interactive the setup/remove functions, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby e4337ff378 182/265: inf-ruby-console-default: Support executable "console" script as well, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby ac80ea9fd3 188/265: Make run-ruby do one thing only,
ELPA Syncer <=
- [nongnu] elpa/inf-ruby 91424afd17 192/265: inf-ruby-console-*: Make sure default-directory is set to the project root, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 1dd007201a 197/265: Do not overwrite inf-ruby-buffer if it's still live, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 9bd6d24aca 202/265: inf-ruby-console-gem: Enable completion, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 81adadf0f9 203/265: Bump the version, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby fd8d392fef 224/265: ruby-print-result: Fallback to inf-ruby-buffer, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 03dd9c9d4e 246/265: Avoid creating duplicates in inf-ruby-buffers, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 3cdf30dc73 251/265: Apply code review - remove cl-lib and optional args, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby 3e16215cb2 128/265: Document changing C-c C-s to call inf-ruby-console-auto, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby b3ee3093b5 105/265: Autoloading inf-ruby-minor-mode is more important, ELPA Syncer, 2022/07/09
- [nongnu] elpa/inf-ruby c5bfcf59eb 112/265: Turn string into a choice, ELPA Syncer, 2022/07/09