emacs-diffs
[Top][All Lists]
Advanced

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

master a1789fd: Add rcirc-omit-unless-requested option


From: Philip Kaludercic
Subject: master a1789fd: Add rcirc-omit-unless-requested option
Date: Thu, 30 Sep 2021 10:25:53 -0400 (EDT)

branch: master
commit a1789fd67b2dd67d891b6c7181aee885a9ab9447
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>

    Add rcirc-omit-unless-requested option
    
    * doc/misc/rcirc.texi (Notices): Update documentation
    * lisp/net/rcirc.el (rcirc-pending-requests): Add local variable
    (rcirc-omit-unless-requested): Add user option
    (rcirc-print): Respect rcirc-omit-unless-requested
    (rcirc-define-command): Update rcirc-pending-requests
---
 doc/misc/rcirc.texi | 13 +++++++++++++
 lisp/net/rcirc.el   | 26 +++++++++++++++++++++++---
 2 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/doc/misc/rcirc.texi b/doc/misc/rcirc.texi
index 2097129..a4ca54a 100644
--- a/doc/misc/rcirc.texi
+++ b/doc/misc/rcirc.texi
@@ -823,6 +823,19 @@ active and only omits a message if the nick has not been 
active.  The
 window @code{rcirc} considers is controlled by the
 @code{rcirc-omit-threshold} variable.
 
+@vindex rcirc-omit-unless-requested
+Certain messages can be omitted by default, unless the user manual
+requests them. For example, if you don't want to display @code{TOPIC}
+and @code{NAMES} messages, after reconnecting, you can configure
+@code{rcirc-omit-unless-requested} to hide:
+
+@example
+(setq rcirc-omit-unless-requested '("TOPIC" "NAMES"))
+@end example
+
+Now NAMES will only be displayed, after it has been requested via the
+@code{rcirc-cmd-name} command.
+
 @node Hacking and Tweaking
 @chapter Hacking and Tweaking
 @cindex hacking and tweaking
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
index ba7fbbf..c18748a 100644
--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -190,6 +190,19 @@ If nil, no maximum is applied."
 (defvar-local rcirc-low-priority-flag nil
   "Non-nil means activity in this buffer is considered low priority.")
 
+(defvar-local rcirc-pending-requests '()
+  "List of pending requests.
+See `rcirc-omit-unless-requested'.")
+
+(defcustom rcirc-omit-unless-requested '()
+  "List of commands to only be requested if preceded by a command.
+For example, if \"TOPIC\" is added to this list, TOPIC commands
+will only be displayed if `rcirc-cmd-TOPIC' was previously
+invoked.  Commands will only be hidden if `rcirc-omit-mode' is
+enabled."
+  :version "28.1"
+  :type '(repeat string))
+
 (defcustom rcirc-omit-responses
   '("JOIN" "PART" "QUIT" "NICK")
   "Responses which will be hidden when `rcirc-omit-mode' is enabled."
@@ -1958,9 +1971,15 @@ connection."
               ;; make text omittable
              (let ((last-activity-lines (rcirc-elapsed-lines process sender 
target)))
                (if (and (not (string= (rcirc-nick process) sender))
-                        (member response rcirc-omit-responses)
-                        (or (not last-activity-lines)
-                            (< rcirc-omit-threshold last-activity-lines)))
+                         (or (member response rcirc-omit-responses)
+                             (and (member response rcirc-omit-unless-requested)
+                                  (if (member response rcirc-pending-requests)
+                                      (ignore (setq rcirc-pending-requests
+                                                    (delete response 
rcirc-pending-requests)))
+                                    t)))
+                         (or (member response rcirc-omit-unless-requested)
+                             (not last-activity-lines)
+                             (< rcirc-omit-threshold last-activity-lines)))
                   (put-text-property (point-min) (point-max)
                                       'invisible 'rcirc-omit)
                  ;; otherwise increment the line count
@@ -2569,6 +2588,7 @@ that, an interactive form can specified."
                      (<= ,required (length ,argument) ,total)
                    (string-match ,regexp ,argument))
            (user-error "Malformed input (%s): %S" ',command ,argument))
+         (push ,(upcase (symbol-name command)) rcirc-pending-requests)
          (let ((process (or process (rcirc-buffer-process)))
               (target (or target rcirc-target)))
            (ignore target process)



reply via email to

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