On Fri, Mar 10, 2023 at 1:25 PM David Karr <davidmichaelk...@gmail.com> wrote:
> On Tue, Mar 7, 2023 at 5:06 AM Michael Albinus <michael.albi...@gmx.de> > wrote: > >> David Karr <davidmichaelk...@gmail.com> writes: >> >> Hi David, >> >> > So, it seems like there's something about my process of creating shell >> > buffers, which if done before the first tramp connection, makes tramp >> > time out. I don't know what information tramp caches. It's possible >> > that in the last scenario, if I then tried a tramp connection to a >> > different host, that would fail, but I'm just guessing. >> >> OK, that seems to be it. >> >> > I create shell buffers using a couple of very small packages that I >> > wrote decades ago, which I haven't had any issues with since. They >> > manage a "ring" of shell buffers which I can either step through, or >> > search for a particular one by its current directory. I'll attach >> > them, if there's a clue there. Reading the file comment for >> > "cycle-shell.el", I think I must have simplified it slightly after I >> > wrote that comment, because I don't depend on a "shell-for-cycle" >> > package anymore. >> >> I've skimmed only shortly over the packages. However, you seem to create >> shell buffers premature, before calling `shell'. So that function >> expects, that the shell buffer is already prepared properly. But it >> isn't I guess, `shell' does something more when creating a new buffer. >> >> So I recommend to let `shell' do everything it believes what should be >> done creating a buffer. You might debug your functions to see where they >> block. And for your functionality, adding shell buffers to a ring, you >> could add yourself into `shell-mode-hook', which seems to be the proper >> place. >> > > I was thinking that I haven't really looked at this code for a very long > time and might not be able to figure out how to make this happen, but I > decided to give it a try, and I noticed in the doc for the "shell" function > that it can take a prefix argument for the name of the buffer to use, > instead of the default. That might be a better way to do this that might > make it more compatible with tramp. I'll see if I can figure this out. > > Before I noticed this, I had tried sending a request for help on this to > gnu.emacs.help, but I got crickets. > Unfortunately, my first stab at this didn't help. I think the new function is an improvement, but it didn't fix the problem. Here's the new defun: --------------------------- (defun cycle-make-shell () "Implements a ring of *shell* buffers. If current buffer is not a shell buffer, then it will just execute 'shell'. If it IS a shell buffer, then create a new shell buffer, starting with '*shell-1*', but skipping to the next number if that already exists." (interactive) (let* ((bufname (buffer-name (current-buffer)))) (if (string-match "\*shell\\(\*\\|-\\([0-9][0-9]*\\)\*\\)" bufname) (progn (setq change-dir default-directory) (setq done nil) (while (not done) (progn (setq new-bufname (next-bufname bufname "shell")) (if (bufferp (get-buffer new-bufname)) (setq bufname new-bufname) (setq done t) ) ) ) (shell new-bufname) ) (progn ;; check for existence of buffer last-shell-buffer. If it exists, ;; go to it. If not, then execute "shell". (if (and (bufferp last-shell-buffer) (not (killed-buffer-p last-shell-buffer))) (switch-to-buffer last-shell-buffer) (shell)) ) ) ) ) ---------------------- > > >> Sorry that I cannot say too much about. Starting by tomorrow, I'll be >> almost offline for some days. >> >> Best regards, Michael. >> >