~dpettersson <dpettersson@git.sr.ht> writes:
thanks for the patch Daniel, it is a nice improvement to the way the
buffers are generated! I fixed a small spelling mistake in the
documentation before adding the patch. Otherwise I have pushed it
upstream now.
I was going to add your name in the list of code contributors, but I
realized I didn't if you have a website, gitlab/sourcehut or similar
that you would like me to link to your name in the list? This is what I
have added for the other contributors
https://git.sr.ht/~niklaseklund/detached.el/tree/master/README.md#L331
/Niklas
From: Daniel Pettersson <daniel@dpettersson.net>
Currently only the first shell command buffer "*Detached Shell
Command*" is reused if `get-buffer-process` fails to get process.
Buffers named "*Detached Shell Command*<NUMBER>" are handled
differently and if "*Detached Shell Command*" is attached to a long
running process. New *Detached Shell Command*<NUMBER> will fill up the
buffer list.
This is fixed by doing the same check process check for
*Detached Shell Command*<NUMBER> buffers as well before creating a new
buffer.
---
Hey again Niklas!
I sent a PR/Feature request when the repo was hosted at gitlab,
regarding having last shell-command as initial input for completing-
read.
Pushing changes that I had locally. I have a FSF copyright assignment
for emacs pending, but while that is pending I thought I would send this
patch before I forget.
Can ping you when the assignment is completed.
Also having some issues with "tail" on OSX as --lines is not supported,
the replacement would be "tail -10" for 10 lines.
Can create a patch for when I have some time left over.
PS: I could not find a mail address in the README so I am hoping this
the correct one.
-- daniel petterssondetached.el | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/detached.el b/detached.el
index 0c5c4be..b878ea6 100644
--- a/detached.el+++ b/detached.el
@@ -694,10 +694,10 @@ Optionally SUPPRESS-OUTPUT."
(or detached--current-session
(detached-create-session command)))
((symbol-function #'set-process-sentinel) #'ignore)
- (buffer (get-buffer-create detached--shell-command-buffer))+ (buffer (detached--generate-buffer detached--shell-command-buffer+ (lambda (buffer)+ (not (get-buffer-process buffer))))) (command (detached--shell-command detached--current-session t)))
- (when (get-buffer-process buffer)- (setq buffer (generate-new-buffer (buffer-name buffer)))) (setq detached-enabled nil)
(funcall #'async-shell-command command buffer)
(with-current-buffer buffer
@@ -1651,6 +1651,22 @@ If event is cased by an update to the `detached' database, re-initialize
(seq-max)
(min width)))))
+(defun detached--generate-buffer (name reuse-p &optional number)+ "Reuse or generate new buffer like built-in function `generate-new-buffer'.+NAME is used the same way as `generate-new-buffer' but if a buffer which+REUSE-P for buffer returns nil, return buffer instead.++NUMBER is used internaly for recursive calls, but can be used to start searching+at NUMBER offset."+ (let* ((buffer-name (if number+ (format "%s<%d>" name number)+ name))+ (buffer (get-buffer buffer-name))+ (number (or number 1)))+ (if (and buffer (not (funcall reuse-p buffer)))+ (detached--generate-buffer name reuse-p (1+ number))+ (get-buffer-create buffer-name))))+(defun detached--metadata-git-branch ()
"Return current git branch."
(let ((args '("symbolic-ref" "HEAD" "--short")))
--
2.34.5
~dpettersson <dpettersson@git.sr.ht> writes:
thanks for the patch Daniel, it is a nice improvement to the way the
buffers are generated! I fixed a small spelling mistake in the
documentation before adding the patch. Otherwise I have pushed it
upstream now.
I was going to add your name in the list of code contributors, but I
realized I didn't if you have a website, gitlab/sourcehut or similar
that you would like me to link to your name in the list? This is what I
have added for the other contributors
https://git.sr.ht/~niklaseklund/detached.el/tree/master/README.md#L331
/Niklas