bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#56225: args-out-of-range error in tramp-debug-buffer-command-complet


From: Michael Albinus
Subject: bug#56225: args-out-of-range error in tramp-debug-buffer-command-completion-p
Date: Sun, 26 Jun 2022 11:04:52 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Stefan Kangas <stefan@marxist.se> writes:

Hi Stefan,

> I'm seeing the below error when typing `M-x' (`execute-extended-command')
> in narrowed buffers.  I haven't been able to reproduce it in "emacs -Q".

You can reproduce it with "emacs -Q -l tramp" with

--8<---------------cut here---------------start------------->8---
(with-temp-buffer
  (insert (make-string 20 ?x))
  (narrow-to-region 2 5)
  (tramp-debug-buffer-command-completion-p nil (current-buffer)))
--8<---------------cut here---------------end--------------->8---

> The below patch seems to fix it, but I have no idea if it's correct:

tramp-debug-buffer-command-completion-p should be very cheap. So it is
sufficient to apply

--8<---------------cut here---------------start------------->8---
diff --git a/lisp/tramp.el b/lisp/tramp.el
index 1674bf27..7aba76d7 100644
--- a/lisp/tramp.el
+++ b/lisp/tramp.el
@@ -1955,7 +1955,8 @@ The outline level is equal to the verbosity of the Tramp 
message."
   "A predicate for Tramp interactive commands.
 They are completed by \"M-x TAB\" only in Tramp debug buffers."
   (with-current-buffer buffer
-    (string-equal (buffer-substring 1 (min 10 (point-max))) ";; Emacs:")))
+    (string-equal
+     (buffer-substring (point-min) (min 10 (point-max))) ";; Emacs:")))

 (put #'tramp-debug-buffer-command-completion-p 'tramp-suppress-trace t)

--8<---------------cut here---------------end--------------->8---

There could be false positives when the string ";; Emacs:" is somewhere
in the buffer, and the buffer is narrowed at this point. But that's not
the end of the world :-)

And we don't need to worry about narrowed Tramp debug buffers: they
don't exist.

> Michael, what do you think?

I've applied the patch to master. Could you pls check?

Best regards, Michael.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]