From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "J.P." Newsgroups: gmane.emacs.bugs Subject: bug#59943: 30.0.50; ERC 5.5+: Add visual indicator to ERC keep-place Date: Sat, 10 Dec 2022 07:52:14 -0800 Message-ID: <87fsdndzo1.fsf__43908.5422128969$1670687619$gmane$org@neverwas.me> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37248"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-erc@gnu.org To: 59943@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Dec 10 16:53:31 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p42AM-0009R4-02 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 10 Dec 2022 16:53:30 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p429w-0002Xm-Cy; Sat, 10 Dec 2022 10:53:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p429v-0002XA-0o; Sat, 10 Dec 2022 10:53:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p429u-000370-Oq; Sat, 10 Dec 2022 10:53:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p429u-00008h-Dx; Sat, 10 Dec 2022 10:53:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: "J.P." Original-Sender: "Debbugs-submit" Resent-CC: emacs-erc@gnu.org, bug-gnu-emacs@gnu.org Resent-Date: Sat, 10 Dec 2022 15:53:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 59943 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org X-Debbugs-Original-Xcc: emacs-erc@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.1670687551521 (code B ref -1); Sat, 10 Dec 2022 15:53:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 10 Dec 2022 15:52:31 +0000 Original-Received: from localhost ([127.0.0.1]:43449 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p429O-00008L-Di for submit@debbugs.gnu.org; Sat, 10 Dec 2022 10:52:31 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:38100) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p429K-00008F-HB for submit@debbugs.gnu.org; Sat, 10 Dec 2022 10:52:28 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p429K-0002P2-BY for bug-gnu-emacs@gnu.org; Sat, 10 Dec 2022 10:52:26 -0500 Original-Received: from mail-108-mta195.mxroute.com ([136.175.108.195]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p429H-0002wk-FA for bug-gnu-emacs@gnu.org; Sat, 10 Dec 2022 10:52:26 -0500 Original-Received: from mail-111-mta2.mxroute.com ([136.175.111.2] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta195.mxroute.com (ZoneMTA) with ESMTPSA id 184fcbcb62d0001d7e.001 for (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256); Sat, 10 Dec 2022 15:52:16 +0000 X-Zone-Loop: f03759030731494068072665fa319f75c9918aac19a7 X-Originating-IP: [136.175.111.2] DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=neverwas.me ; s=x; h=Content-Type:MIME-Version:Message-ID:Date:Subject:To:From:Sender: Reply-To:Cc:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=kPA1h6sF2+UD9ZvbGw1TY3YKiUCdz34ztmnDQsHswlE=; b=LSMFEbSMPxCipuAouqSoNNviEJ L0mDLcc28mOCUcstmEF9jtl8VGH/eyno/ExNTzawEUtT5H5HSjLwg6a+jQnDSgKQgf9N9pM3RT2O5 aM9565nA+9g2KWzIiNiLyGrXPREJBw+M/tMb6QH/d9ap8W64pMpr75/TrRlO58uNMQ7ERtKWDpPB8 Sw6Dd6plFsluOi/jxICrFXOvBMxhdWTAEJl36IB8iuny2fHUik6c0pXuQaBlGdIpl1DfTH1ZWXr3H H45iztTxb39QOgbPoXJXE7DplsY8s6JMH6tHFxxFaP4NIn/RH7lqfv9xyC4scdLSzvkYPnxe/S/Gx EQ8nTCAg==; X-Authenticated-Id: masked@neverwas.me Received-SPF: pass client-ip=136.175.108.195; envelope-from=jp@neverwas.me; helo=mail-108-mta195.mxroute.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:250529 Archived-At: --=-=-= Content-Type: text/plain Tags: patch Hi people, There's been some recent talk regarding ERC's lack of a visual element to demarcate the boundary between seen and unseen messages in a target buffer. This approach leverages the existing `keep-place' module located in erc-goodies. (But perhaps there's a smarter way?) Improvements or replacements welcome, as always. Thanks, J.P. In GNU Emacs 30.0.50 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.35, cairo version 1.17.6) of 2022-12-10 built on localhost Repository revision: 9c670695b91deb3424a74cd2b0f6a37356a4efcc Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12014000 System Description: Fedora Linux 36 (Workstation Edition) Configured using: 'configure --enable-check-lisp-object-type --enable-checking=yes,glyphs 'CFLAGS=-O0 -g3' PKG_CONFIG_PATH=:/usr/lib64/pkgconfig:/usr/share/pkgconfig' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB Important settings: value of $LANG: en_US.UTF-8 value of $XMODIFIERS: @im=ibus locale-coding-system: utf-8-unix Major mode: Lisp Interaction Minor modes in effect: tooltip-mode: t global-eldoc-mode: t eldoc-mode: t show-paren-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t line-number-mode: t indent-tabs-mode: t transient-mark-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message mailcap yank-media puny dired dired-loaddefs rfc822 mml mml-sec epa derived epg rfc6068 epg-config gnus-util text-property-search mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils erc iso8601 time-date auth-source cl-seq eieio eieio-core cl-macs password-cache json subr-x map thingatpt pp format-spec cl-loaddefs cl-lib erc-backend erc-goodies erc-networks byte-opt gv bytecomp byte-compile erc-common erc-compat erc-loaddefs rmc iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic indonesian philippine cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite emoji-zwj charscript charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget keymap hashtable-print-readable backquote threads dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting cairo move-toolbar gtk x-toolkit xinput2 x multi-tty make-network-process emacs) Memory information: ((conses 16 64369 5963) (symbols 48 8607 0) (strings 32 23642 2119) (string-bytes 1 684025) (vectors 16 15217) (vector-slots 8 208839 8628) (floats 8 24 27) (intervals 56 227 0) (buffers 984 11)) --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-option-to-show-visual-erc-keep-place-indicator.patch >From 685e151fa4565970683cd76eb111afd308d1b531 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Fri, 9 Dec 2022 22:00:59 -0800 Subject: [PATCH] Add option to show visual erc-keep-place indicator * etc/ERC-NEWS: Create new section for version 5.6 and mention keep-place indicator. * lisp/erc/erc-goodies.el (erc-keep-place-indicator, erc-keep-place-indicator-follow): New options for anchoring kept place visually. (erc-keep-place-indicator-line, erc-keep-place-indicator-arrow): New faces. (erc--keep-place-overlay): New internal local state var. (erc--keep-place-on-window-configuration-change): New function to subscribe to `window-configuration-change-hook' and maybe update keep-place indicator. (erc--keep-place-setup-overlay): New function to initialize buffer for option `erc-keep-place-indicator'. (erc-keep-place-enable, erc-keep-place-disable): Add setup and teardown to support `erc-keep-place-indicator'. (erc-keep-place-move, erc-keep-place-goto): Add new commands for manually updating and jumping to keep-place indicator. (erc-keep-place): Move `erc--keep-place-overlay' when applicable. --- etc/ERC-NEWS | 10 ++++ lisp/erc/erc-goodies.el | 102 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 110 insertions(+), 2 deletions(-) diff --git a/etc/ERC-NEWS b/etc/ERC-NEWS index d0d84d0a98..af1cfcacea 100644 --- a/etc/ERC-NEWS +++ b/etc/ERC-NEWS @@ -11,6 +11,16 @@ This file is about changes in ERC, the powerful, modular, and extensible IRC (Internet Relay Chat) client distributed with GNU Emacs since Emacs version 22.1. + +* Changes in ERC 5.6 + +** Module 'keep-place' now offers a visual indicator. + +Remember your place in a target buffer a bit more easily while also +having the freedom to roam. Optionally sync the indicator manually if +you've made progress but still haven't caught up to the live stream. +See new option 'erc-keep-place-indicator'. + * Changes in ERC 5.5 diff --git a/lisp/erc/erc-goodies.el b/lisp/erc/erc-goodies.el index 1af83b58ba..18e9f665bd 100644 --- a/lisp/erc/erc-goodies.el +++ b/lisp/erc/erc-goodies.el @@ -46,6 +46,7 @@ erc-log-p (declare-function erc-error "erc" (&rest args)) (declare-function erc-extract-command-from-line "erc" (line)) (declare-function erc-beg-of-input-line "erc" nil) +(declare-function erc-default-target "erc" nil) (defun erc-imenu-setup () "Setup Imenu support in an ERC buffer." @@ -154,11 +155,106 @@ erc-move-to-prompt-setup "Initialize the move-to-prompt module." (add-hook 'pre-command-hook #'erc-move-to-prompt nil t)) +(defcustom erc-keep-place-indicator nil + "Show kept place with visual indicator in target buffers. +For use with the `keep-place' module. A value of `arrow' +displays an arrow in the left fringe or margin. A value of +`face' applies `erc-keep-place-indicator-line' to the appropriate +line. A value of t does both. A value of nil does neither." + :group 'erc + :package-version '(ERC . "5.6") + :type '(choice (const nil) (const t) (const face) (const arrow))) + +(defcustom erc-keep-place-indicator-follow nil + "Whether to sync visual kept place to window's top when reading." + :group 'erc + :package-version '(ERC . "5.6") + :type 'boolean) + +(defface erc-keep-place-indicator-line + '((((class color) (min-colors 88) (background light) + (supports :underline (:style wave))) + (:underline (:color "PaleGreen3" :style wave))) + (((class color) (min-colors 88) (background dark) + (supports :underline (:style wave))) + (:underline (:color "PaleGreen1" :style wave))) + (t :underline t)) + "Face for option `erc-keep-place-indicator'." + :group 'erc-faces) + +(defface erc-keep-place-indicator-arrow + '((((class color) (min-colors 88) (background light)) + (:foreground "PaleGreen3")) + (((class color) (min-colors 88) (background dark)) + (:foreground "PaleGreen1")) + (t :inherit fringe)) + "Face for arrow value of option `erc-keep-place-indicator'." + :group 'erc-faces) + +(defvar-local erc--keep-place-overlay nil + "Overlay for option `erc-keep-place-indicator'.") + +(defun erc--keep-place-on-window-configuration-change () + "Maybe sync `erc--keep-place-overlay'." + (when erc-keep-place-indicator-follow + (unless (minibuffer-window-active-p (minibuffer-window)) + (when (< (overlay-end erc--keep-place-overlay) + (window-start) + erc-insert-marker) + (erc-keep-place-move (window-start)))))) + +(defun erc--keep-place-setup-overlay () + (when (erc-default-target) + (add-hook 'window-configuration-change-hook + #'erc--keep-place-on-window-configuration-change nil t) + (setq erc--keep-place-overlay (make-overlay 0 0)) + (when (memq erc-keep-place-indicator '(t arrow)) + (overlay-put erc--keep-place-overlay 'before-string + (propertize + " " + 'display + (if (zerop (fringe-columns 'left)) + `((margin left-margin) ,overlay-arrow-string) + '(left-fringe right-triangle + erc-keep-place-indicator-arrow))))) + (when (memq erc-keep-place-indicator '(t face)) + (overlay-put erc--keep-place-overlay 'face + 'erc-keep-place-indicator-line)))) + ;;; Keep place in unvisited channels (define-erc-module keep-place nil "Leave point above un-viewed text in other channels." - ((add-hook 'erc-insert-pre-hook #'erc-keep-place)) - ((remove-hook 'erc-insert-pre-hook #'erc-keep-place))) + ((add-hook 'erc-insert-pre-hook #'erc-keep-place) + (when erc-keep-place-indicator + (if (derived-mode-p 'erc-mode) + (erc--keep-place-setup-overlay) + (add-hook 'erc-mode-hook #'erc--keep-place-setup-overlay)))) + ((remove-hook 'erc-insert-pre-hook #'erc-keep-place) + (when erc-keep-place-indicator + (remove-hook 'erc-mode-hook #'erc--keep-place-setup-overlay) + (erc-with-all-buffers-of-server erc-server-process nil + (when erc--keep-place-overlay + (delete-overlay erc--keep-place-overlay) + (remove-hook 'window-configuration-change-hook + #'erc--keep-place-on-window-configuration-change t) + (kill-local-variable 'erc--keep-place-overlay)))))) + +(defun erc-keep-place-move (&optional pos) + "Move keep-place indicator to the current line." + (interactive "P") + (save-excursion + (let ((inhibit-field-text-motion t)) + (when (numberp pos) + (goto-char pos)) + (move-overlay erc--keep-place-overlay + (line-beginning-position) + (line-end-position))))) + +(defun erc-keep-place-goto () + "Jump to keep-place indicator." + (interactive) + (goto-char (overlay-start erc--keep-place-overlay)) + (recenter (truncate (* (window-height) 0.25)) t)) (defun erc-keep-place (_ignored) "Move point away from the last line in a non-selected ERC buffer." @@ -168,6 +264,8 @@ erc-keep-place (deactivate-mark) (goto-char (erc-beg-of-input-line)) (forward-line -1) + (when erc-keep-place-indicator + (erc-keep-place-move)) ;; if `switch-to-buffer-preserve-window-point' is set, ;; we cannot rely on point being saved, and must commit ;; it to window-prev-buffers. -- 2.38.1 --=-=-=--