Subject: bug#53593: 29.0.50; tramp-setup-debug-buffer completion-predicate

From: Óscar Fuentes <[email-masked]>
Date: Fri, 28 Jan 2022 01:16:50 +0100

With read-extended-command-predicate set to
command-completion-default-include-p, after M-x toggle-debug-on-error,
while composing an e-mail, an error message pops out when I type M-x
tramp[TAB]:

(args-out-of-range #<buffer *unsent mail*> 1 10)

The trace is:

Debugger entered--Lisp error: (args-out-of-range #<buffer *unsent mail*> 1 10)
  tramp-debug-buffer-command-completion-p(tramp-setup-debug-buffer #<buffer *unsent mail*>)
  command-completion-default-include-p(tramp-setup-debug-buffer #<buffer *unsent mail*>)
  #f(compiled-function (sym) #<bytecode -0x89e6b482b47ff72>)(tramp-setup-debug-buffer)
  #f(compiled-function (sym) #<bytecode 0x4ac014f9e6bcd6d>)(tramp-setup-debug-buffer)
  try-completion("tra" [## magit-section-show-headings vc-src-responsible-p Read\ manual archive-proper-file-start dashboard-ls archive--file-desc-mode ivy-explorer speedbar-check-vc-this-line access-label magit-patch-save c-electric-lt-gt pcomplete-stub c-state-min-scan-pos zmq LaTeX-after-insert-env-hook znc magit-xref-insert-button js--find-newline-backward gnus-agent-group-covered-p pdf-view-mode-abbrev-table smiley-directory eshell-return-exits-minibuffer transient:magit-diff-refresh:--irreversible-delete autoload-find-file pdf-outline-mouse-display-link smie-config--guess-value gnus-summary-show-article-from-menu-as-charset-ebcdic-int LaTeX-math-Theta gnus-server-compact-server nexus byte-condition-case :mac xref--push-markers mhtml--submode-keymap nswbuff evil-exit-visual-and-repeat org-agenda-regexp-filter-preset EVENT-RESOLUTION-UNREAD-P org-agenda-menu-show-matcher nnmail-message-id-cache-file discard-new article-fill-long-lines smime-buffer-as-string-region zoo svn-status-line-format Noto\ Sans\ Gurmukhi gwene\.agency\.causal\.text stack-mode js--split-name ...] #f(compiled-function (sym) #<bytecode 0x4ac014f9e6bcd6d>))
  complete-with-action(nil [## magit-section-show-headings vc-src-responsible-p Read\ manual archive-proper-file-start dashboard-ls archive--file-desc-mode ivy-explorer speedbar-check-vc-this-line access-label magit-patch-save c-electric-lt-gt pcomplete-stub c-state-min-scan-pos zmq LaTeX-after-insert-env-hook znc magit-xref-insert-button js--find-newline-backward gnus-agent-group-covered-p pdf-view-mode-abbrev-table smiley-directory eshell-return-exits-minibuffer transient:magit-diff-refresh:--irreversible-delete autoload-find-file pdf-outline-mouse-display-link smie-config--guess-value gnus-summary-show-article-from-menu-as-charset-ebcdic-int LaTeX-math-Theta gnus-server-compact-server nexus byte-condition-case :mac xref--push-markers mhtml--submode-keymap nswbuff evil-exit-visual-and-repeat org-agenda-regexp-filter-preset EVENT-RESOLUTION-UNREAD-P org-agenda-menu-show-matcher nnmail-message-id-cache-file discard-new article-fill-long-lines smime-buffer-as-string-region zoo svn-status-line-format Noto\ Sans\ Gurmukhi gwene\.agency\.causal\.text stack-mode js--split-name ...] "tra" #f(compiled-function (sym) #<bytecode 0x4ac014f9e6bcd6d>))
  #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_49>("tra" #f(compiled-function (sym) #<bytecode -0x89e6b482b47ff72>) nil)
  completion-basic-try-completion("tra" #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_49> #f(compiled-function (sym) #<bytecode -0x89e6b482b47ff72>) 3)
  #f(compiled-function (style) #<bytecode 0x176379e77b9f729>)(basic)
  completion--some(#f(compiled-function (style) #<bytecode 0x176379e77b9f729>) (basic partial-completion emacs22))
  completion--nth-completion(1 "tra" #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_49> #f(compiled-function (sym) #<bytecode -0x89e6b482b47ff72>) 3 (metadata (affixation-function . read-extended-command--affixation) (category . command)))
  completion-try-completion("tra" #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_49> #f(compiled-function (sym) #<bytecode -0x89e6b482b47ff72>) 3 (metadata (affixation-function . read-extended-command--affixation) (category . command)))
  completion--do-completion(5 8)
  completion--in-region-1(5 8)
  #f(compiled-function (start end collection predicate) #<bytecode -0x1a8feab6e8b09cb4>)(5 8 #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_49> #f(compiled-function (sym) #<bytecode -0x89e6b482b47ff72>))
  apply(#f(compiled-function (start end collection predicate) #<bytecode -0x1a8feab6e8b09cb4>) (5 8 #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_49> #f(compiled-function (sym) #<bytecode -0x89e6b482b47ff72>)))
  #f(compiled-function (funs global args) #<bytecode -0xf7b7097427f262>)(nil nil (5 8 #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_49> #f(compiled-function (sym) #<bytecode -0x89e6b482b47ff72>)))
  completion--in-region(5 8 #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_49> #f(compiled-function (sym) #<bytecode -0x89e6b482b47ff72>))
  completion-in-region(5 8 #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_49> #f(compiled-function (sym) #<bytecode -0x89e6b482b47ff72>))
  minibuffer-complete()
  funcall-interactively(minibuffer-complete)
  command-execute(minibuffer-complete)
  completing-read-default("M-x " #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_49> #f(compiled-function (sym) #<bytecode -0x89e6b482b47ff72>) t nil extended-command-history nil nil)
  completing-read("M-x " #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_49> #f(compiled-function (sym) #<bytecode -0x89e6b482b47ff72>) t nil extended-command-history nil nil)
  read-extended-command()
  byte-code("\302\30\11\303 \10E)\207" [execute-extended-command--last-typed current-prefix-arg nil read-extended-command] 3)
  command-execute(execute-extended-command)

The problem is not consistent, the only semi-pattern I've found so far
is that it happens when the e-mail being composed is a reply.

Without setting on debug-on-error the problem is hidden by this code in
`read-extended-command':

                     ;; Don't let bugs break M-x completion; interpret
                     ;; them as the absence of a predicate.
                     (condition-case-unless-debug err
                         (funcall read-extended-command-predicate sym buffer)
                       (error (message "read-extended-command-predicate: %s: %s"
                                       sym (error-message-string err))))))))

In GNU Emacs 29.0.50 (build 3, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0)
 of 2022-01-14 built on sky
Repository revision: d29291d665e808307126bf52c3e748fef78f0f9c
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12013000
System Description: Debian GNU/Linux bookworm/sid

Configured using:
 'configure --with-native-compilation --without-toolkit-scroll-bars
 --with-x-toolkit=lucid --with-modules --without-imagemagick'

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LIBOTF LIBSELINUX LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG
RSVG SECCOMP SOUND THREADS TIFF WEBP X11 XAW3D XDBE XIM XPM LUCID ZLIB

Important settings:
  value of $LANG: C
  locale-coding-system: nil

Major mode: ELisp/l

Minor modes in effect:
  bug-reference-prog-mode: t
  window-highlight-mode: t
  global-git-commit-mode: t
  evil-owl-mode: t
  buffer-flip-mode: t
  evil-leader-mode: t
  evil-paredit-mode: t
  shell-dirtrack-mode: t
  evil-mode: t
  evil-local-mode: t
  windmove-mode: t
  pdf-occur-global-minor-mode: t
  TeX-PDF-mode: t
  paredit-mode: t
  display-fill-column-indicator-mode: t
  which-key-mode: t
  iscroll-mode: t
  global-anzu-mode: t
  anzu-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t