* [PATCH] hide ERC messages
@ 2012-01-24 23:52 Philipp Haselwarter
0 siblings, 0 replies; only message in thread
From: Philipp Haselwarter @ 2012-01-24 23:52 UTC (permalink / raw)
To: emacs-devel; +Cc: Michael Olson
[-- Attachment #1: Type: text/plain, Size: 462 bytes --]
This patch for ERC offers an alternative method of hiding IRC messages
in `erc-hide-list' by using the invisible text-property. This really
/hides/ them instead of simply discarding them, which is the current
way. The new method has the advantage of allowing to toggle the
visibility as a minor-mode, buffer-locally or globally.
The default behaviour is left unchanged, but it could easily be set to
using invisible by modifying the `erc-hide-method' default.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: hide irc messages using invisible text property --]
[-- Type: text/x-patch, Size: 2382 bytes --]
--- /proc/self/fd/11 2012-01-24 20:14:43.208972689 +0100
+++ erc.el 2012-01-24 20:09:40.485514822 +0100
@@ -256,10 +256,23 @@
(defcustom erc-hide-list nil
"*List of IRC type messages to hide.
+Behaves according to `erc-hide-method'.
A typical value would be '(\"JOIN\" \"PART\" \"QUIT\")."
:group 'erc-ignore
:type 'erc-message-type)
+(defcustom erc-hide-method 'discard
+ "Either discard messages in `erc-hide-list' or make them invisible.
+
+The value discard results in complete dismissal of the message.
+invisible means the messages are inserted into the erc-buffer but
+hidden in `erc-hide-mode'.
+
+NOTE: Invisible messages are logged if `erc-log-mode' is active!"
+ :group 'erc-ignore
+ :type '(choice (const :tag "discard" discard)
+ (const :tag "make invisible" invisible)))
+
(defvar erc-session-password nil
"The password used for the current session.")
(make-variable-buffer-local 'erc-session-password)
@@ -2469,11 +2482,37 @@
(if (not (erc-response-p parsed))
(erc-display-line string buffer)
- (unless (member (erc-response.command parsed) erc-hide-list)
+ (when (or (not (member (erc-response.command parsed) erc-hide-list))
+ (and (eq erc-hide-method 'invisible)
+ (progn
+ (unless (string-match "\n$" string)
+ (setq string (concat string "\n")))
+ (erc-put-text-property
+ 0 (length string) 'invisible 'erc-hide string)
+ t)))
(erc-put-text-property 0 (length string) 'erc-parsed parsed string)
(erc-put-text-property 0 (length string) 'rear-sticky t string)
(erc-display-line string buffer)))))
+(define-minor-mode erc-hide-mode
+ "Make IRC messages matching `erc-hide-list' invisible.
+
+This mode only has an effect if `erc-hide-method' is set invisible."
+ :group 'erc-ignore
+ (if erc-hide-mode
+ (add-to-invisibility-spec 'erc-hide)
+ (remove-from-invisibility-spec 'erc-hide)))
+
+(defun erc-hide-mode-maybe (&optional buffer)
+ "Turn on `erc-hide-mode' in BUFFER (defaults to `current-buffer')."
+ (with-current-buffer (or buffer (current-buffer))
+ (when (derived-mode-p 'erc-mode)
+ (erc-hide-mode))))
+
+(define-globalized-minor-mode global-erc-hide-mode
+ erc-hide-mode erc-hide-mode-maybe
+ :group 'erc-ignore)
+
(defun erc-message-type-member (position list)
"Return non-nil if the erc-parsed text-property at POSITION is in LIST.
[-- Attachment #3: Type: text/plain, Size: 39 bytes --]
Best regards,
--
Philipp Haselwarter
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2012-01-24 23:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-24 23:52 [PATCH] hide ERC messages Philipp Haselwarter
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).