emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/shellcop 7c025b1017 09/10: add debug code


From: ELPA Syncer
Subject: [nongnu] elpa/shellcop 7c025b1017 09/10: add debug code
Date: Wed, 5 Jan 2022 08:59:35 -0500 (EST)

branch: elpa/shellcop
commit 7c025b10173ef380ea539dbbdcd7d60977119e24
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: Chen Bin <chenbin.sh@gmail.com>

    add debug code
---
 shellcop.el | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/shellcop.el b/shellcop.el
index 793726d3b5..a2f9178135 100644
--- a/shellcop.el
+++ b/shellcop.el
@@ -2,7 +2,7 @@
 
 ;; Copyright (C) 2020-2021 Chen Bin
 ;;
-;; Version: 0.0.5
+;; Version: 0.0.6
 ;; Keywords: unix tools
 ;; Author: Chen Bin <chenbin DOT sh AT gmail DOT com>
 ;; URL: https://github.com/redguardtoo/shellcop
@@ -97,15 +97,24 @@ If there is error, it returns t."
   :type 'function
   :group 'shellcop)
 
+(defcustom shellcop-shell-buffer-name "*shell*"
+  "The name of buffer in `shell-mode'."
+  :type 'string
+  :group 'shellcop)
+
+(defvar shellcop-debug nil "Enable debug output if not nil.")
+
 (defun shellcop-location-detail (str)
   "Get file, line and column from STR."
-  (when (string-match "^\\([^:]+\\):\\([0-9]+\\)+\\(:[0-9]+\\)?$" str)
+  (when shellcop-debug (message "shellcop-location-details (%s)" str))
+  (when (string-match "^\\([^:]+\\):\\([0-9]+\\)+\\(:[0-9]+\\)?" str)
     (let* ((file (match-string 1 str))
            (line (match-string 2 str))
            (col (match-string 3 str)))
       ;; clean the column format
       (when col
         (setq col (replace-regexp-in-string ":" "" col)))
+      (when shellcop-debug (message "file=%s line=%s col=%s" file line col))
       (list file line col))))
 
 (defun shellcop-extract-location ()
@@ -150,6 +159,10 @@ If ABOVE is t, extract locations above current point; or 
else below current poin
   "Extract all locations near current point."
   (let* ((location (shellcop-extract-location))
          rlt)
+
+    (when shellcop-debug
+      (message "shellcop-extract-all-locations called. location=%s" location))
+
     ;; at least current line should contain file path
     (when location
       (shellcop-push-location location rlt)
@@ -169,6 +182,8 @@ If ABOVE is t, extract locations above current point; or 
else below current poin
 Extract file paths when user presses enter key shell."
   (let* ((artifical (nth 1 args))
          locations)
+    (when shellcop-debug
+      (message "shellcop-comint-send-input-hack (%s)" artifical))
     (cond
      ((or artifical (not (eq major-mode 'shell-mode)))
       ;; do nothing
@@ -250,6 +265,7 @@ Keep latest N cli program output if it's not nil."
     (cond
      ((not target-window)
       (message "Buffer %s is not visible!" buf-name))
+
      (t
       (select-window target-window)
       (let* ((inhibit-read-only t))
@@ -257,6 +273,7 @@ Keep latest N cli program output if it's not nil."
           ;; skip current prompt line
           (forward-line -2)
           (setq beg (shellcop-search-backward-prompt n)))
+
         (cond
          (beg
           (delete-region (point-min) beg))
@@ -334,6 +351,8 @@ Or else erase current buffer."
                     (buffer-substring (region-beginning) (region-end)))
                    (t
                     (thing-at-point 'word)))))
+    (when shellcop-debug
+      (message "shellcop-focus-window called. sub-window=%s keyword=%s" 
sub-window keyword))
     (when sub-window
       ;; select sub-window
       (select-window sub-window)
@@ -345,7 +364,7 @@ Or else erase current buffer."
   "Search symbol or selected text in *shell* buffer of the other window."
   (interactive)
   (shellcop-focus-window
-   "*shell*"
+   shellcop-shell-buffer-name
    (lambda (keyword)
      (when keyword
        (funcall shellcop-string-search-function keyword)))))



reply via email to

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