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

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

[nongnu] elpa/shellcop 12db5dffb2 03/10: simplify erase buffer command


From: ELPA Syncer
Subject: [nongnu] elpa/shellcop 12db5dffb2 03/10: simplify erase buffer command
Date: Wed, 5 Jan 2022 08:59:35 -0500 (EST)

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

    simplify erase buffer command
---
 README.org  |  7 ++-----
 shellcop.el | 26 +++++++++++---------------
 2 files changed, 13 insertions(+), 20 deletions(-)

diff --git a/README.org b/README.org
index a281cb5fc8..ace800cd08 100644
--- a/README.org
+++ b/README.org
@@ -19,15 +19,12 @@ Press =Enter= key. The file path and line number 
information is extracted and yo
 
 [[file:demo.png]]
 
-Run =shellcop-erase-buffer= to erase following buffers with below names,
-- =*Messages= (default)
-- =*shell*= (if parameter 1 is passed)
-- =*Javascript REPL*= (if parameter 2 is passed)
-- =*eshell*= (if parameter 3 is passed)
+Run =shellcop-erase-buffer= to erase current buffer in =shell-mode= and 
=message-buffer-mode=. Or else it erases content in message buffer.
 
 Run =shellcop-reset-with-new-command= to,
 - kill current running process
 - erase the content in shell buffer
 - If =shellcop-sub-window-has-error-function= return nil in all sub-windows, 
run =shellcop-insert-shell-command-function=
+
 * Contact me
 Report bug at [[https://github.com/redguardtoo/shellcop]].
diff --git a/shellcop.el b/shellcop.el
index b8be892ec8..7db744998e 100644
--- a/shellcop.el
+++ b/shellcop.el
@@ -2,7 +2,7 @@
 
 ;; Copyright (C) 2020 Chen Bin
 ;;
-;; Version: 0.0.1
+;; Version: 0.0.2
 ;; Keywords: unix tools
 ;; Author: Chen Bin <chenbin DOT sh AT gmail DOT com>
 ;; URL: https://github.com/redguardtoo/shellcop
@@ -287,22 +287,18 @@ Keep latest N cli program output if it's not nil."
     (message "Can't erase buffer in %s" major-mode))))
 
 ;;;###autoload
-(defun shellcop-erase-buffer (&optional n)
-  "Erase the content of the *Messages* buffer.
-N specifies the buffer to erase."
-  (interactive "P")
+(defun shellcop-erase-buffer ()
+  "Erase *Messages* buffer if not in `shell-mode' or `messages-buffer-mode'.
+Or else erase current buffer."
+  (interactive)
   (cond
-   ((null n)
-    (shellcop-erase-one-visible-buffer "*Messages*"))
-
-   ((eq 1 n)
-    (shellcop-erase-one-visible-buffer "*shell*"))
+   ((memq major-mode '(shell-mode message-buffer-mode))
+    (shellcop-erase-one-visible-buffer (buffer-name (current-buffer)))
+    (when (eq major-mode 'shell-mode)
+      (comint-send-input)))
 
-   ((eq 2 n)
-    (shellcop-erase-one-visible-buffer "*Javascript REPL*"))
-
-   ((eq 3 n)
-    (shellcop-erase-one-visible-buffer "*eshell*"))))
+   (t
+    (shellcop-erase-one-visible-buffer "*Message*"))))
 
 (provide 'shellcop)
 ;;; shellcop.el ends here



reply via email to

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