From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alex Bochannek Newsgroups: gmane.emacs.bugs Subject: bug#59856: 29.0.50; [PATCH] Feature suggestion, Newsticker runs ticker only periodically Date: Tue, 06 Dec 2022 03:14:17 -0800 Message-ID: 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="16279"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: 59856@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 06 12:15:15 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 1p2Vut-00045I-96 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 06 Dec 2022 12:15:15 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p2Vuj-00080B-8J; Tue, 06 Dec 2022 06:15:05 -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 1p2Vuh-0007zs-54 for bug-gnu-emacs@gnu.org; Tue, 06 Dec 2022 06:15: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 1p2Vug-0002ki-Mt for bug-gnu-emacs@gnu.org; Tue, 06 Dec 2022 06:15:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p2Vug-00061a-2h for bug-gnu-emacs@gnu.org; Tue, 06 Dec 2022 06:15:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alex Bochannek Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 06 Dec 2022 11:15:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 59856 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.167032528023126 (code B ref -1); Tue, 06 Dec 2022 11:15:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 6 Dec 2022 11:14:40 +0000 Original-Received: from localhost ([127.0.0.1]:42236 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p2VuJ-00060w-FZ for submit@debbugs.gnu.org; Tue, 06 Dec 2022 06:14:40 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:45890) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p2VuH-00060q-Dk for submit@debbugs.gnu.org; Tue, 06 Dec 2022 06:14:38 -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 1p2VuH-0007ql-8h for bug-gnu-emacs@gnu.org; Tue, 06 Dec 2022 06:14:37 -0500 Original-Received: from ns.lapseofthought.com ([50.0.39.240] helo=mail.lapseofthought.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p2VuE-0002gE-HT for bug-gnu-emacs@gnu.org; Tue, 06 Dec 2022 06:14:37 -0500 Original-Received: from awb-mbp.local (c-73-92-249-246.hsd1.ca.comcast.net [73.92.249.246]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.lapseofthought.com (Postfix) with ESMTPSA id 4NRHqj0cc6z3pgWp for ; Tue, 6 Dec 2022 03:14:24 -0800 (PST) Authentication-Results: ORIGINATING; auth=pass smtp.auth=alex smtp.mailfrom=alex@bochannek.com Received-SPF: pass client-ip=50.0.39.240; envelope-from=alex@bochannek.com; helo=mail.lapseofthought.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-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:250098 Archived-At: --=-=-= Content-Type: text/plain Hello! I started using the Ticker frontend of Newsticker and didn't like that it continuously scrolls the echo area. I am submitting the below patch, which only displays the list of items once, at `newsticker-ticker-period` intervals. The default behavior has not changed. Not sure if this warrants a change in NEWS. Thanks! Newsticker ticker scrolling options to only display periodically * lisp/net/newst-ticker.el (newsticker-ticker-period): Scroll news items only once each period. * doc/misc/newsticker.texi (Frontends): Document ticker scolling behavior. --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/lisp/net/newst-ticker.el b/lisp/net/newst-ticker.el index ef0fe83803..abd7c3d04b 100644 --- a/lisp/net/newst-ticker.el +++ b/lisp/net/newst-ticker.el @@ -44,8 +44,10 @@ newsticker--prev-message "Last message that the newsticker displayed.") (defvar newsticker--scrollable-text "" "The text which is scrolled smoothly in the echo area.") +(defvar newsticker--ticker-period-timer nil + "Timer for newsticker ticker display.") (defvar newsticker--ticker-timer nil - "Timer for newsticker ticker.") + "Timer for newsticker ticker scrolling.") ;;;###autoload (defun newsticker-ticker-running-p () @@ -77,7 +79,7 @@ newsticker--set-customvar-ticker (defcustom newsticker-ticker-interval 0.3 - "Time interval for displaying news items in the echo area (seconds). + "Time interval for scrolling news items in the echo area (seconds). If equal or less than 0 no messages are shown in the echo area. For smooth display (see `newsticker-scroll-smoothly') a value of 0.3 seems reasonable. For non-smooth display a value of 10 is a good starting @@ -86,6 +88,17 @@ newsticker-ticker-interval :set #'newsticker--set-customvar-ticker :group 'newsticker-ticker) +(defcustom newsticker-ticker-period + 0 + "Time interval for displaying news items in the echo area (seconds). +If equal or less than 0 messages are shown continuously. In order not +to miss new items, a value of equal or less than the shortest feed +retrieval interval (or the global `newsticker-retrieval-interval`) is +recommended." + :type 'number + :set #'newsticker--set-customvar-ticker + :group 'newsticker-ticker) + (defcustom newsticker-scroll-smoothly t "Decides whether to flash or scroll news items. @@ -129,9 +142,16 @@ newsticker--display-tick "Called from the display timer. This function calls a display function, according to the variable `newsticker-scroll-smoothly'." - (if newsticker-scroll-smoothly - (newsticker--display-scroll) - (newsticker--display-jump))) + (when (not newsticker--ticker-timer) + (if newsticker-scroll-smoothly + (setq newsticker--ticker-timer + (run-at-time 1 + newsticker-ticker-interval + #'newsticker--display-scroll)) + (setq newsticker--ticker-timer + (run-at-time nil + newsticker-ticker-interval + #'newsticker--display-jump))))) (defsubst newsticker--echo-area-clean-p () "Check whether somebody is using the echo area / minibuffer. @@ -149,7 +169,12 @@ newsticker--display-jump (when (newsticker--echo-area-clean-p) (setq newsticker--item-position (1+ newsticker--item-position)) (when (>= newsticker--item-position (length newsticker--item-list)) - (setq newsticker--item-position 0)) + (setq newsticker--item-position 0) + (when (> newsticker-ticker-period 0) + (cancel-timer newsticker--ticker-timer) + (setq newsticker--ticker-timer nil) + (run-at-time newsticker-ticker-interval nil + (lambda () (message ""))))) (setq newsticker--prev-message (nth newsticker--item-position newsticker--item-list)) (message "%s" newsticker--prev-message)))) @@ -192,7 +217,12 @@ newsticker--display-scroll (setq newsticker--prev-message subtext) (setq newsticker--item-position (1+ i)) (when (>= newsticker--item-position l) - (setq newsticker--item-position 0)))))) + (setq newsticker--item-position 0) + (when (> newsticker-ticker-period 0) + (cancel-timer newsticker--ticker-timer) + (setq newsticker--ticker-timer nil) + (run-at-time newsticker-ticker-interval nil + (lambda () (message ""))))))))) ;;;###autoload (defun newsticker-start-ticker () @@ -200,19 +230,26 @@ newsticker-start-ticker Start display timer for the actual ticker if wanted and not running already." (interactive) - (if (and (> newsticker-ticker-interval 0) - (not newsticker--ticker-timer)) - (setq newsticker--ticker-timer - (run-at-time newsticker-ticker-interval - newsticker-ticker-interval - #'newsticker--display-tick)))) + (when (and (> newsticker-ticker-interval 0) + (not newsticker--ticker-period-timer) + (not newsticker--ticker-timer)) + (if (> newsticker-ticker-period 0) + (setq newsticker--ticker-period-timer + (run-at-time nil + newsticker-ticker-period + #'newsticker--display-tick)) + (newsticker--display-tick)))) (defun newsticker-stop-ticker () "Stop newsticker's ticker (but not the news retrieval)." (interactive) - (when newsticker--ticker-timer - (cancel-timer newsticker--ticker-timer) - (setq newsticker--ticker-timer nil))) + (progn + (when newsticker--ticker-timer + (cancel-timer newsticker--ticker-timer) + (setq newsticker--ticker-timer nil)) + (when newsticker--ticker-period-timer + (cancel-timer newsticker--ticker-period-timer) + (setq newsticker--ticker-period-timer nil)))) ;; ====================================================================== ;;; Manipulation of ticker text diff --git a/doc/misc/newsticker.texi b/doc/misc/newsticker.texi index fec571d923..01384b5850 100644 --- a/doc/misc/newsticker.texi +++ b/doc/misc/newsticker.texi @@ -307,11 +307,16 @@ Frontends @findex newsticker-start-ticker @findex newsticker-stop-ticker +@vindex newsticker-ticker-period Headlines can be displayed in the echo area, either scrolling like messages in a stock-quote ticker, or just changing. This can be started with the command @code{newsticker-start-ticker}. It can be stopped with @code{newsticker-stop-ticker}. +The ticker by default runs continuously. To only run it once, at a +specific time interval, set the @code{newsticker-ticker-period} +variable. + @node Navigation @section Navigation @@ -542,8 +547,10 @@ Configuration @itemize @item @vindex newsticker-display-interval +@vindex newsticker-ticker-period @vindex newsticker-scroll-smoothly -@code{newsticker-ticker-interval} and +@code{newsticker-ticker-interval}, +@code{newsticker-ticker-period}, and @code{newsticker-scroll-smoothly} define how headlines are shown in the echo area. @end itemize --=-=-= Content-Type: text/plain -- Alex. --=-=-=--