[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Erc-discuss] buffer local erc-hide-list ?
From: |
Giorgos Keramidas |
Subject: |
Re: [Erc-discuss] buffer local erc-hide-list ? |
Date: |
Sun, 27 Nov 2011 05:11:34 +0100 |
On Sat, Nov 26, 2011 at 12:07 PM, Peter Baranyi <address@hidden> wrote:
>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:
>>> 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:
>>
>> ,-----------------------------------------------------------------------
>> | (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))
>> | (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)))))
>> `-----------------------------------------------------------------------
>
> 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:
You're right. I posted too fast. Reading the code of `erc-display-line'
it's clear that there are more cases of 'buffer' values. So I modified
this function once more:
,-----------------------------------------------------------------------
| (defun erc-display-buffer-list (buffer)
| "Sanitize a 'buffer' name or list, and convert to a buffer-name list."
| (cond ((bufferp buffer) (list buffer))
| ((listp buffer) buffer)
| ((processp buffer) (list (process-buffer buffer)))
| ((eq 'all buffer)
| ;; Hmm, or all of the same session server?
| (erc-buffer-list nil erc-server-process))
| ((and (eq 'active buffer) (erc-active-buffer))
| (list (erc-active-buffer)))
| ((erc-server-buffer-live-p)
| (list (process-buffer erc-server-process)))
| (t (list (current-buffer)))))
|
| (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)
| (erc-put-text-property 0 (length string) 'erc-parsed parsed string)
| (erc-put-text-property 0 (length string) 'rear-sticky t string)
| (dolist (buf (erc-display-buffer-list buffer))
| (unless (member (erc-response.command parsed)
| (with-current-buffer buf
| erc-hide-list))
| (erc-display-line string buffer))))))
`-----------------------------------------------------------------------
> 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.
This is probably a different problem. I haven't seen QUIT messages in
quiet-mode in a while, but I will also try to use the patched version of
`erc-display-message' with an IRC server other than bitlbee.
> 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.
Yes, that makes sense. You should probably try to move the calls to
put-text-property outside of the dolist loop. It should work fine.