[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/bash-completion abbe3bc268 301/313: Cleanup implementation
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/bash-completion abbe3bc268 301/313: Cleanup implementation of bash-completion-debug. |
Date: |
Sat, 3 Dec 2022 10:59:39 -0500 (EST) |
branch: elpa/bash-completion
commit abbe3bc268a8b161a27806b46baf36d2e8f06634
Author: Stephane Zermatten <szermatt@gmx.net>
Commit: Stephane Zermatten <szermatt@gmx.net>
Cleanup implementation of bash-completion-debug.
---
bash-completion.el | 132 +++++++++++++++++++++++++++--------------------------
1 file changed, 68 insertions(+), 64 deletions(-)
diff --git a/bash-completion.el b/bash-completion.el
index 0878bd1a8f..e69c7148e3 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -280,13 +280,8 @@ Bash processes.")
(defvar bash-completion--debug-info nil
"Alist that stores info about the last call to `bash-completion-send'.
-Keys:
- commandline: COMMANDLINE argument
- process: PROCESS argument
- error: nil or a short string
- buffer-string: captured output buffer content, if error is non-nil
- status: status code number
- wrapped-status: nil or a wrapped-status string")
+Created by `bash-completion-send' and printed by
+`bash-completion-debug'.")
;;; ---------- Struct
@@ -1534,6 +1529,8 @@ Return the status code of the command, as a number."
(defun bash-completion-debug ()
(interactive)
(with-help-window "*bash-completion-debug*"
+ (unless bash-completion--debug-info
+ (error "No debug information available for bash-completion. Please try
it out first."))
(princ "This buffer contains information about the last completion
command\n")
(princ "and the BASH process it was sent to. This can help you figure
out\n")
(princ "what's happening.\n\n")
@@ -1544,64 +1541,71 @@ Return the status code of the command, as a number."
(princ "- what you expected to happen\n")
(princ "- what actually happened\n\n")
(princ "Then add a copy of the information below:\n\n")
- (let ((debug-info bash-completion--debug-info))
- (princ "command line:<<EOF")
- (terpri)
- (princ (cdr (assq 'commandline debug-info)))
- (princ "EOF")
- (terpri)
- (terpri)
- (when (cdr (assq 'error debug-info))
- (princ "error: ")
- (print (cdr (assq 'error debug-info)))
- (terpri)
- (princ "captured output:<<EOF")
- (terpri)
- (princ (cdr (assq 'buffer-string debug-info)))
- (princ "EOF")
- (terpri)
- (terpri))
- (when (cdr (assq 'status debug-info))
- (princ "status: ")
- (print (cdr (assq 'status debug-info)))
- (when (cdr (assq 'wrapped-status debug-info))
- (princ "wrapped-status: ")
- (print (cdr (assq 'wrapped-status debug-info))))
- (terpri))
- (princ "output-buffer:<<EOF")
- (terpri)
- (princ (with-current-buffer (bash-completion--get-buffer
- (cdr (assq 'process debug-info)))
- (buffer-substring-no-properties (point-min) (point-max))))
- (princ "EOF")
- (terpri)
- (terpri)
-
- (let ((process (cdr (assq 'process debug-info))))
- (princ "process: ")
- (print process)
- (terpri)
- (princ "use-separate-process: ")
- (print (cdr (assq 'separate debug-info)))
- (terpri)
- (princ "bash-major-version:")
- (print (process-get process 'bash-major-version))
- (terpri)
- (princ "emacs-version:\n")
- (princ emacs-version)
- (terpri)
- (terpri)
- (princ "completion-ignore-case:")
- (print (process-get process 'completion-ignore-case))
- (terpri)
- (when (cdr (assq 'context debug-info))
- (princ "debug-context:\n")
- (pp (cdr (assq 'context debug-info)))
+ (bash-completion--debug-print-info 'commandline 'eof)
+ (bash-completion--debug-print-info 'error)
+ (bash-completion--debug-print-info 'buffer-string 'eof)
+ (bash-completion--debug-print-info 'status)
+ (bash-completion--debug-print-info 'wrapped-status)
+ (bash-completion--debug-print-info 'process)
+ (bash-completion--debug-print-info 'use-separate-processes)
+
+ (let* ((debug-info bash-completion--debug-info)
+ (process (cdr (assq 'process debug-info)))
+ (bash-completion-use-separate-processes
+ (cdr (assq 'use-separate-processes debug-info))))
+ (if (process-live-p process)
+ (bash-completion--debug-print
+ 'output-buffer
+ (with-current-buffer (bash-completion--get-buffer process)
+ (buffer-substring-no-properties (point-min) (point-max)))
+ 'eof)
+ (princ "\nERROR: Process is dead. ")
+ (princ "Information collection is incomplete.\n")
+ (princ "Please retry\n\n")))
+
+ (bash-completion--debug-print-info 'use-separate-processes)
+ (bash-completion--debug-print-procinfo 'bash-major-version)
+ (bash-completion--debug-print 'emacs-version emacs-version)
+ (bash-completion--debug-print-procinfo 'completion-ignore-case)
+ (bash-completion--debug-print-info 'context)
+ (bash-completion--debug-print-procinfo 'complete-p)))
+
+(defun bash-completion--debug-print-info (symbol &optional eof)
+ "Print variable SYMBOL from `bash-completion-debug-info'.
+
+If EOF is non-nil, VALUE might contain newlines and other special
+characters. These are output as-is."
+ (bash-completion--debug-print
+ symbol (cdr (assq symbol bash-completion--debug-info)) eof))
+
+(defun bash-completion--debug-print-procinfo (symbol &optional eof)
+ "Print variable SYMBOL from `bash-completion-debug-info''s process.
+
+If EOF is non-nil, VALUE might contain newlines and other special
+characters. These are output as-is."
+ (let ((process (cdr (assq 'process bash-completion--debug-info))))
+ (when (process-live-p process)
+ (bash-completion--debug-print
+ symbol (process-get process symbol) eof))))
+
+(defun bash-completion--debug-print (name value &optional eof)
+ "Print debugging information NAME and VALUE.
+
+If EOF is non-nil, VALUE might contain newlines and other special
+characters. These are output as-is."
+ (when value
+ (princ name)
+ (princ ": ")
+ (if eof
+ (progn
+ (princ "<<EOF")
+ (terpri)
+ (princ value)
+ (princ "EOF")
+ (terpri)
(terpri))
- (princ "complete-p:\n")
- (pp (process-get process 'complete-p))
- (terpri))
- )))
+ (pp value)
+ (terpri))))
(defun bash-completion--get-output (process)
"Return the output of the last command sent through `bash-completion-send'."
- [nongnu] elpa/bash-completion 51c7770758 284/313: Fix and update README.md, (continued)
- [nongnu] elpa/bash-completion 51c7770758 284/313: Fix and update README.md, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion c6decb1d6c 285/313: Avoid escaping all non-ASCII characters., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 4c216c4eea 286/313: Add an integration test to cover multiple completion results., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 8f877dc2ce 287/313: Let bash compute COMP_POINT, always at the end of COMP_LINE., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 377969faa7 288/313: Fix typos in README.md, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 72e9fce93d 291/313: Properly apply filter passed to the dynamic completion function., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 35d38fd3dc 295/313: Workaround for output containing \r\n instead of \n., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 666244383e 296/313: Workaround for command-line being echoed., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion abb72c36b8 297/313: Merge branch 'master' of github.com:szermatt/emacs-bash-completion, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion e35943f37e 299/313: Fix backward-compatibility issue on 24.3: avoid using alist-get., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion abbe3bc268 301/313: Cleanup implementation of bash-completion-debug.,
ELPA Syncer <=
- [nongnu] elpa/bash-completion ca4fbce016 305/313: Turn off bash completion when non-bash prompts are detected., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion abe93ae2f6 308/313: Fix whitespace (#47), ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion df635e79fd 310/313: Replace deprecated `cl` package with `cl-lib` (#50), ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 8e9c20dbfe 313/313: Replace or quote certain single quotes in docstrings (#55), ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion aa9bea48ba 022/313: fix position, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 6aedd69000 164/313: Delete duplicates when extracting candidates. fixes #26, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 58447c67bf 206/313: Merge the send functions, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion d6c28d3132 302/313: Add a troubleshooting section to README.md, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion d550256e3f 306/313: Disable flakey test for now., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion a8f7de1e91 173/313: Merge remote-tracking branch 'montag451/remote-shell-support-rebase', ELPA Syncer, 2022/12/03