[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/realgud 20d8119 33/72: realgud-clear-bufferr & realgud-
From: |
Stefan Monnier |
Subject: |
[elpa] externals/realgud 20d8119 33/72: realgud-clear-bufferr & realgud-truncate-buffer.. |
Date: |
Fri, 26 Mar 2021 22:49:08 -0400 (EDT) |
branch: externals/realgud
commit 20d811923575e5740105aa57df7d1c8d81ca4e87
Author: rocky <rocky@gnu.org>
Commit: rocky <rocky@gnu.org>
realgud-clear-bufferr & realgud-truncate-buffer..
start...
---
realgud/common/track-mode.el | 96 ++++++++++++++++++++++++++++++++++++--------
1 file changed, 79 insertions(+), 17 deletions(-)
diff --git a/realgud/common/track-mode.el b/realgud/common/track-mode.el
index 4ca2c63..ccdbb5f 100644
--- a/realgud/common/track-mode.el
+++ b/realgud/common/track-mode.el
@@ -1,4 +1,4 @@
-;; Copyright (C) 2015-2017 Free Software Foundation, Inc
+;; Copyright (C) 2015-2017, 2020 Free Software Foundation, Inc
;; Author: Rocky Bernstein <rocky@gnu.org>
@@ -102,6 +102,82 @@
(realgud-track-mode-setup realgud-track-mode)
)
+(defun realgud-remove-track-hooks()
+ (let ((mode (realgud:canonic-major-mode)))
+ (cond ((eq mode 'eshell)
+ (remove-hook 'eshell-output-filter-functions
+ 'realgud-track-eshell-output-filter-hook))
+ ((eq mode 'comint)
+ (remove-hook 'comint-output-filter-functions
+ 'realgud-track-comint-output-filter-hook))
+ )))
+
+(defun realgud-add-track-hooks()
+ (let ((mode (realgud:canonic-major-mode)))
+ (cond ((eq mode 'eshell)
+ (add-hook 'eshell-output-filter-functions
+ 'realgud-track-eshell-output-filter-hook))
+ ((eq mode 'comint)
+ (add-hook 'comint-output-filter-functions
+ 'realgud-track-comint-output-filter-hook))
+ )))
+
+;; We will hijack comint-truncate-buffer to augment it with awareness of
+;; realgud. We save the original value and restore that when leaving the mode.
+(defalias 'comint-truncate-buffer-orig
+ (symbol-function 'comint-truncate-buffer))
+
+(defun realgud-truncate-buffer (&optional last-n)
+ "Truncate the buffer to `comint-buffer-maximum-size'.
+This function could be on `comint-output-filter-functions' or bound to a key."
+ (interactive "")
+ (if (realgud-cmdbuf?)
+ (when (y-or-n-p "Clear buffer and destroy realgud debug history? ")
+ (save-excursion
+ ;; Delete up to position indicated
+ (if last-n
+ ;; FIXME figure out what the place is from the history ring.
+ ;; (goto-char ... )
+ (goto-char (process-mark (get-buffer-process (current-buffer))))
+ ;; else
+ (goto-char (process-mark (get-buffer-process (current-buffer))))
+ )
+ (forward-line 0)
+ (beginning-of-line)
+ (let ((inhibit-read-only t))
+ (delete-region (point-min) (point)))
+ (realgud-add-track-hooks)
+ (setf (realgud-cmdbuf-info-last-input-end realgud-cmdbuf-info)
(point-max))
+ (setf (realgud-cmdbuf-info-loc-hist realgud-cmdbuf-info)
(make-realgud-loc-hist))
+ ))
+ ;; else
+ (message "Nothing done - not in command buffer")
+ ))
+
+(defun realgud-clear-buffer()
+ "Remove the entire command buffer. This is like `comint-clear-buffer` or
+ `comint-truncate-buffer` except we coordinate the delete with realgud so
that it
+ doesn't get bolixed by marker removal.
+ "
+ (interactive "")
+ (if (realgud-cmdbuf?)
+ (when (y-or-n-p "Clear buffer and destroy realgud debug history? ")
+ (realgud-remove-track-hooks)
+ (save-excursion
+ (goto-char (process-mark (get-buffer-process (current-buffer))))
+ (forward-line 0)
+ (beginning-of-line)
+ (let ((inhibit-read-only t))
+ (delete-region (point-min) (point))))
+ (realgud-add-track-hooks)
+ (setf (realgud-cmdbuf-info-last-input-end realgud-cmdbuf-info)
(point-max))
+ (setf (realgud-cmdbuf-info-loc-hist realgud-cmdbuf-info)
(make-realgud-loc-hist))
+ )
+ ;; else
+ (message "Nothing done - not in command buffer")
+ ))
+
+
;; FIXME: this should have been picked up by require'ing track.
(defvar realgud-track-divert-string)
@@ -139,14 +215,7 @@ of this mode."
(set-marker comint-last-output-start (point)))
(set (make-local-variable 'tool-bar-map) realgud:tool-bar-map)
- (let ((mode (realgud:canonic-major-mode)))
- (cond ((eq mode 'eshell)
- (add-hook 'eshell-output-filter-functions
- 'realgud-track-eshell-output-filter-hook))
- ((eq mode 'comint)
- (add-hook 'comint-output-filter-functions
- 'realgud-track-comint-output-filter-hook))
- ))
+ (realgud-add-track-hooks)
(run-mode-hooks 'realgud-track-mode-hook))
;; else
(progn
@@ -156,14 +225,7 @@ of this mode."
)
(kill-local-variable 'realgud:tool-bar-map)
(realgud-fringe-erase-history-arrows)
- (let ((mode (realgud:canonic-major-mode)))
- (cond ((eq mode 'eshell)
- (remove-hook 'eshell-output-filter-functions
- 'realgud-track-eshell-output-filter-hook))
- ((eq mode 'comint)
- (remove-hook 'comint-output-filter-functions
- 'realgud-track-comint-output-filter-hook))
- ))
+ (realgud-remove-track-hooks)
(let* ((cmd-process (get-buffer-process (current-buffer)))
(status (if cmd-process
(list (propertize (format ":%s"
- [elpa] externals/realgud 4d276fd 29/72: unifiy ansi escape handling, add test, (continued)
- [elpa] externals/realgud 4d276fd 29/72: unifiy ansi escape handling, add test, Stefan Monnier, 2021/03/26
- [elpa] externals/realgud 639db29 46/72: Add locals window, Stefan Monnier, 2021/03/26
- [elpa] externals/realgud 81b3d3d 06/72: Travis 4th try, Stefan Monnier, 2021/03/26
- [elpa] externals/realgud 00902c3 03/72: Try using cask, Stefan Monnier, 2021/03/26
- [elpa] externals/realgud ea6774e 10/72: Travis 7th try, Stefan Monnier, 2021/03/26
- [elpa] externals/realgud b4a25f8 15/72: Test using more emacs versions, Stefan Monnier, 2021/03/26
- [elpa] externals/realgud 3a3a94e 21/72: Travis has changed - attempted fix #3, Stefan Monnier, 2021/03/26
- [elpa] externals/realgud cf1c7c4 18/72: Improve instruction for building from source, Stefan Monnier, 2021/03/26
- [elpa] externals/realgud 703cd5d 27/72: Travis has changed - attempted fix #9, Stefan Monnier, 2021/03/26
- [elpa] externals/realgud b854e04 32/72: Create FUNDING.yml, Stefan Monnier, 2021/03/26
- [elpa] externals/realgud 20d8119 33/72: realgud-clear-bufferr & realgud-truncate-buffer..,
Stefan Monnier <=
- [elpa] externals/realgud d2be4cf 45/72: http:// -> https://, Stefan Monnier, 2021/03/26
- [elpa] externals/realgud 52fac1f 48/72: add realgud:window-locals-undisturb-src, Stefan Monnier, 2021/03/26
- [elpa] externals/realgud f0a3676 44/72: Add "Signals" menu in comint debugger shells, Stefan Monnier, 2021/03/26
- [elpa] externals/realgud 332d136 61/72: Merge pull request #282 from 813gan/list-all-locals, Stefan Monnier, 2021/03/26
- [elpa] externals/realgud a5fff14 69/72: Merge pull request #287 from yangyingchao/hotfix_failed_to_load_helper, Stefan Monnier, 2021/03/26
- [elpa] externals/realgud bc3971a 08/72: Travis 6th try, Stefan Monnier, 2021/03/26
- [elpa] externals/realgud 854a040 16/72: One more emacs version to try, Stefan Monnier, 2021/03/26
- [elpa] externals/realgud cc5d123 17/72: One more emacs version to try, Stefan Monnier, 2021/03/26
- [elpa] externals/realgud d4d65f3 22/72: Travis has changed - attempted fix #4, Stefan Monnier, 2021/03/26
- [elpa] externals/realgud b0ff316 24/72: Travis has changed - attempted fix #6, Stefan Monnier, 2021/03/26