scripts icon indicating copy to clipboard operation
scripts copied to clipboard

Adds auto_read_buffer which marks a buffer as read upon switching

Open kindrowboat opened this issue 1 year ago • 3 comments

Script info

  • Script name: auto_read_buffer.py
  • Version: 1.0.0
  • Requirements: 
  • Min WeeChat version: 
  • Script tags: buffer, read

Description

Automatically marks a buffer as read upon switching away from it to another buffer.

Checklist (new script)

  • [x] Single commit, single file added
  • [x] Commit message: New script name.py: short description…
  • [x] No similar script already exists
  • [x] Name: max 32 chars, only lower case letters, digits and underscores
  • [x] Unique name, does not already exist in repository
  • [x] No shebang on the first line
  • [x] Comment in script with name/pseudo, e-mail and license
  • [x] Only English in code/comments
  • [x] Pure WeeChat API used, no extra API
  • [x] Function hook_process is used for any blocking call
  • [x] For Python script: works with Python 3 (Python 2 support is optional)
  • [x] Score 100 / 100 displayed by weechat-script-lint

Checklist (script update)

  • [ ] Author has been contacted
  • [ ] Single commit, single file added
  • [ ] Commit message format: script_name.py X.Y: …
  • [ ] Script version and Changelog have been updated
  • [ ] For Python script: works with Python 3 (Python 2 support is optional)
  • [ ] Score 100 / 100 displayed by weechat-script-lint

Checklist (script deletion)

  • [ ] Author has been contacted
  • [ ] Single commit, single file deleted
  • [ ] Commit message format: Remove script name.py with reasons in description

kindrowboat avatar Mar 05 '24 18:03 kindrowboat

Hi, Sorry for the delay, does this script fix a bug in WeeChat? What's the use case where the buffer is not marked as read?

flashcode avatar Aug 26 '24 06:08 flashcode

Hey, no problem! I think this is an issue when you're using a weechat relay. Before this script, when I moved off of a buffer, it was still marked yellow/unread. I'd have to switch off and back onto to the buffer to get it to to be marked as read. This is true for only the relay host, I think. I swear I saw a known issue/wontfix for this, but I can't seem to find it now.

kindrowboat avatar Aug 26 '24 22:08 kindrowboat

OK, for relay (weechat protocol), this is caused by the option weechat.look.hotlist_add_conditions whose default value is ${away} || ${buffer.num_displayed} == 0 || ${info:relay_client_count,weechat,connected} > 0. So the last condition means if there's at least one client of the weechat relay, always add the buffer to the hotlist, even if it's the current one. It's done like this because the relay client may not see the same buffer as active, and thus you don't miss any notification in the client. If needed, you can remove this condition, but then that means the weechat current buffer will not be added to hotlist and not visible in the client.

flashcode avatar Aug 27 '24 06:08 flashcode