From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Basil L. Contovounesios" Newsgroups: gmane.emacs.devel Subject: Re: master d378615: Cancel timer when world-clock buffer is killed Date: Thu, 03 Sep 2020 14:46:34 +0100 Message-ID: <87sgbzrn0l.fsf@tcd.ie> References: <20200903105449.22858.36474@vcs0.savannah.gnu.org> <20200903105450.8CD2D20A15@vcs0.savannah.gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2771"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Stefan Kangas Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Sep 03 15:47:30 2020 Return-path: Envelope-to: ged-emacs-devel@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 1kDpaM-0000ds-2M for ged-emacs-devel@m.gmane-mx.org; Thu, 03 Sep 2020 15:47:30 +0200 Original-Received: from localhost ([::1]:57138 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kDpaL-0003LV-3M for ged-emacs-devel@m.gmane-mx.org; Thu, 03 Sep 2020 09:47:29 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47880) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kDpZb-00024T-AF for emacs-devel@gnu.org; Thu, 03 Sep 2020 09:46:43 -0400 Original-Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]:53240) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kDpZZ-0001PM-45 for emacs-devel@gnu.org; Thu, 03 Sep 2020 09:46:42 -0400 Original-Received: by mail-pj1-x1036.google.com with SMTP id o16so1563140pjr.2 for ; Thu, 03 Sep 2020 06:46:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=14U4abWt7rLXkiZwcnQBliOL1k7XmkAoaLAyFtZgoyo=; b=QoZ9AOERm38TVRwWvv8/uETC1beF/dC6go6pg8mxCXAp0KJ7OKGldAON6mo/MwfbG6 Y4kIGAGk37Z/X7oekm+2l5Kby8hT85FuuUfcYzP/kDQZ5a9BqLW3zgkg7i3kycBFv3ik GH6ThRfkTNi157NYAWU1gNjDI96zWy205Lq3pxBGqPFX/C4c6vkg0lEPDMsTZfpBARGl QPP992BancfeKUG5AOgaAdNoYrQUdRcBH5/Rnk3fIbnj8QC4VoT0esMZ7wb7Aw/gG+CU R3EShgL0ka2dASAJeJ6jY6kqinW3WWYCnSXTSQdVBduzlvTdOQsF/0ocQf5GyTbYmP30 2b2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=14U4abWt7rLXkiZwcnQBliOL1k7XmkAoaLAyFtZgoyo=; b=GC3Q+uHLhux+KWUYhYfehdglaYPpKWWeMZjpJ+pGCSPcw62uP/6HRSSFFO65f4lG8+ 22odcUSlQW1hJr7A2kQiR69qIX4JkAugInqF5Tse3itxSvV3cQlOtHllLXPJ5oSKIQjD qqRd7qV73QkRdISrqGSj/8+61RqhmI/qjCc2J8z+VYS+L7G+/rMX+2p45sArwZvJ4uIP v0c2H3vaI02xya718AlzZxujKb23l/VTShWS8nn3L5xup16Bguo+9jJRZseYjqDgPRsu 4fDpydrP9W2/ekmr5xn9C7MxcQdhke7PkUV01kb4FBGCBHdY4lh6OED12K5WheLpqDs8 GxRw== X-Gm-Message-State: AOAM533tEN/9srKzI5aiCedB2ox03ZNyTx6ONiFhPNHdJUgvvkzPTCaS e6kwmvlgvbsc8gdzR7cmpONt+g== X-Google-Smtp-Source: ABdhPJxLeCwe71XTt3l/SwyyFReMgWLYMR+d9j7ghgF2vYA/VNc3WwGjYjIJ8o1APijSAKkPNpbVTg== X-Received: by 2002:a17:90a:658a:: with SMTP id k10mr3355349pjj.48.1599140798047; Thu, 03 Sep 2020 06:46:38 -0700 (PDT) Original-Received: from localhost ([2a02:8084:20e2:c380:36e2:16c0:7240:397]) by smtp.gmail.com with ESMTPSA id n2sm3326739pfa.182.2020.09.03.06.46.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 06:46:37 -0700 (PDT) In-Reply-To: <20200903105450.8CD2D20A15@vcs0.savannah.gnu.org> (Stefan Kangas's message of "Thu, 3 Sep 2020 06:54:50 -0400 (EDT)") Received-SPF: none client-ip=2607:f8b0:4864:20::1036; envelope-from=contovob@tcd.ie; helo=mail-pj1-x1036.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:254495 Archived-At: stefankangas@gmail.com (Stefan Kangas) writes: > branch: master > commit d37861535dfd452f7c2255ae5edcf7686b75fe5a > Author: Stefan Kangas > Commit: Stefan Kangas > > Cancel timer when world-clock buffer is killed > > * lisp/time.el (world-clock-timer): New variable. > (world-clock-cancel-timer): New defun. > (world-clock): Add 'world-clock-cancel-timer' to 'kill-buffer-hook'. > --- > lisp/time.el | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git a/lisp/time.el b/lisp/time.el > index 1ab992a..5ced920 100644 > --- a/lisp/time.el > +++ b/lisp/time.el > @@ -523,6 +523,8 @@ See `world-clock'." > (setq-local revert-buffer-function #'world-clock-update) > (setq show-trailing-whitespace nil)) > > +(defvar world-clock-timer nil) Should this be given an internal name (and docstring)? > (defun world-clock-display (alist) > "Replace current buffer text with times in various zones, based on ALIST." > (let ((inhibit-read-only t) > @@ -561,12 +563,20 @@ To turn off the world time display, go to the window and type `\\[quit-window]'. > (interactive) > (when (and world-clock-timer-enable > (not (get-buffer world-clock-buffer-name))) > - (run-at-time t world-clock-timer-second #'world-clock-update)) > + (setq world-clock-timer > + (run-at-time t world-clock-timer-second #'world-clock-update)) > + (add-hook 'kill-buffer-hook #'world-clock-cancel-timer)) Should this be hooked buffer-locally? > (pop-to-buffer world-clock-buffer-name) > (world-clock-display (time--display-world-list)) > (world-clock-mode) > (fit-window-to-buffer)) > > +(defun world-clock-cancel-timer () > + "Cancel the world clock timer." > + (when world-clock-timer > + (cancel-timer world-clock-timer) > + (setq world-clock-timer nil))) > + > (defun world-clock-update (&optional _arg _noconfirm) > "Update the `world-clock' buffer." > (if (get-buffer world-clock-buffer-name) Actually, doesn't world-clock-update already try to cancel itself when world-clock-buffer-name no longer names an existing buffer? It seems to me that world-clock-cancel-timer and world-clock-update are duplicating each other. Or am I missing something? Thanks, -- Basil