erc-discuss
[Top][All Lists]
Advanced

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

Re: [Erc-discuss] buffer local erc-hide-list ?


From: Peter Baranyi
Subject: Re: [Erc-discuss] buffer local erc-hide-list ?
Date: Sat, 26 Nov 2011 12:07:17 +0100

On Wed, 2011-11-23 at 13:07 +0100, Giorgos Keramidas wrote:
> On Sun, Nov 20, 2011 at 5:08 PM, Peter Baranyi <address@hidden> wrote:
> > Hi,
> >
> > I'd like to use different erc-hide-list values for different channels.
> > If I'm on a public channel like #debian or #emacs, I don't want to see
> > any join/part/quit messages, while on a private channel with 2-3 people
> > it's good to see when someone leaves/joins.
> >
> > I tried to (make-variable-buffer-local 'erc-hide-list), but it does not
> > work, erc uses the global value.
> >
> > How can I accomplish this?
> 
> It probably requires modifying (erc-display-message) in erc.el.  The
> current function checks erc-hide-list but without making the target
> buffer the currently active buffer, so the buffer-local value of
> erc-hide-list is not taken into account:
> 
> ,-----------------------------------------------------------------------
> | (defun erc-display-message (parsed type buffer msg &rest args)
> |   "Display MSG in BUFFER.
> |
> | ARGS, PARSED, and TYPE are used to format MSG sensibly.
> |
> | See also ‘erc-format-message’ and ‘erc-display-line’."
> |   (let ((string (if (symbolp msg)
> |                     (apply ’erc-format-message msg args)
> |                   msg)))
> |     (setq string
> |           (cond
> |            ((null type)
> |             string)
> |            ((listp type)
> |             (mapc (lambda (type)
> |                     (setq string
> |                           (erc-display-message-highlight type string)))
> |                   type)
> |             string)
> |            ((symbolp type)
> |             (erc-display-message-highlight type string))))
> |
> |     (if (not (erc-response-p parsed))
> |         (erc-display-line string buffer)
> | -       (unless (member (erc-response.command parsed) erc-hide-list)
> | +       (unless (member (erc-response.command parsed)
> | +                       (with-current-buffer buffer
> | +                         erc-hide-list))
> |       (unless (member (erc-response.command parsed)
> |                       (with-current-buffer buffer
> |                         erc-hide-list))
> |         (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)))))
> `-----------------------------------------------------------------------
> 
> Without this change the global erc-hide-list is checked, with the effect
> that you just described.
> 
> _______________________________________________
> Erc-discuss mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/erc-discuss

Thanks for your input however your solution does not work. I could not
even connect with the modified function, I got error in process filter,
stringp, "buffer name". I was able to connect after modifying as
follows:

                      (if (buffer-live-p buffer)
                          (with-current-buffer buffer
                            erc-hide-list)
                        erc-hide-list
                        )

But it made no difference.

I didn't describe the problem exactly in my first message: if I join a
public channel with unset erc-hide-list, then do 

(make-variable-buffer-local 'erc-hide-list)
OR
(make-local-variable 'erc-hide-list)

then  (setq erc-hide-list '( "PART" "QUIT" "JOIN")), all in the public
channel, then I don't get any part and join messages, but the quit
messages remain! And the above described modification does not change
this behavior, the same thing happens.

So the problem is only with the quit messages. This happens because for
QUIT messages, buffer is not one buffer (like with JOIN and PART), but a
list of one or more buffers, where the person quit. For example if I'm
on channels debian and perl, and someone quits who is also on these
channels, then buffer will be ("#perl" "#debian"). So in order to
determine a buffer local hide list, we have to loop through this list,
then check if the element is a valid buffer:

diff erc-display-message-old.el erc-display-message-new.el 
25,28c25,41
<       (unless (member (erc-response.command parsed) erc-hide-list)
<       (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)))))
---
>       (dolist (buf (if (listp buffer)
>                      buffer
>                    (list buffer))
>                  )
> 
>       (unless (member
>                (erc-response.command parsed)
>                (if (bufferp buf)
>                    (with-current-buffer buf erc-hide-list)
>                  erc-hide-list))
>         (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 buf)
>         )
>       )
>       )
>     ))

This way it's working now, all join part and quit messages are omitted
according to the buffer local hide list!

However, the two erc put text property commands were executed only once,
now they are executed once for every element of buffer. I don't know if
this is a problem or not.




reply via email to

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