From: plugd Date: Mon, 26 Jul 2021 08:54:22 +0000 (+0200) Subject: Can now erase context output. X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?p=lurk.git;a=commitdiff_plain;h=bbb819b11b302e1352ec5c704df53b006527b0b0 Can now erase context output. --- diff --git a/lurk.el b/lurk.el index 66517ba..447f5f5 100644 --- a/lurk.el +++ b/lurk.el @@ -409,6 +409,11 @@ portion of the source component of the message, as LURK doesn't use this.") (if lurk-display-header (lurk-setup-header)))) +(defun lurk-clear-buffer () + "Completely erase all non-prompt and non-input text from lurk buffer." + (with-current-buffer "*lurk*" + (let ((inhibit-read-only t)) + (delete-region (point-min) lurk-prompt-marker)))) ;;; Output formatting and highlighting ;; @@ -560,6 +565,16 @@ portion of the source component of the message, as LURK doesn't use this.") (force-window-update "*lurk*")) (lurk-scroll-windows-to-last-line)) +(defun lurk-clear-context (context) + (with-current-buffer "*lurk*" + (save-excursion + (goto-char (point-min)) + (let ((inhibit-read-only t) + (match nil)) + (while (setq match (text-property-search-forward 'context context t)) + (delete-region (prop-match-beginning match) + (prop-match-end match))))))) + (defconst lurk-url-regex (rx (: (group (+ alpha)) @@ -602,7 +617,8 @@ portion of the source component of the message, as LURK doesn't use this.") (strikethrough nil) (prev-point (point))) (while (re-search-forward (rx (or (any "\x02\x1D\x1F\x1E\x0F") - (: "\x03" (+ digit) (opt "," (* digit))))) nil t) + (: "\x03" (+ digit) (opt "," (* digit))))) + nil t) (let ((beg (+ (match-beginning 0) 1))) (if bold (add-face-text-property prev-point beg '(:weight bold))) @@ -860,6 +876,7 @@ in which case they match anything.") ("LIST" "Display details of one or more channels." lurk-command-list) ("WHOIS" "Ask server for details of nick." nil lurk-nick-completions) ("MSG" "Send private message to user." lurk-command-msg lurk-nick-completions) + ("CLEAR" "Clear buffer text." lurk-command-clear lurk-context-completions) ("HELP" "Display help on client commands." lurk-command-help lurk-help-completions)) "Table of commands explicitly supported by Lurk.") @@ -994,6 +1011,11 @@ in which case they match anything.") (lurk-display-message lurk-nick to text)) (lurk-display-notice nil "Usage: /msg "))) +(defun lurk-command-clear (params) + (if (not params) + (lurk-clear-buffer) + (dolist (context params) + (lurk-clear-context context)))) ;;; Command entering ;;