From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Campbell Barton Newsgroups: gmane.emacs.devel Subject: Re: Possible support for buffer local idle timers? Date: Tue, 21 Sep 2021 01:50:47 +1000 Message-ID: References: <83fstz1cyj.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25847"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Sep 20 17:51:43 2021 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 1mSLa2-0006Sz-Au for ged-emacs-devel@m.gmane-mx.org; Mon, 20 Sep 2021 17:51:42 +0200 Original-Received: from localhost ([::1]:34950 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mSLa0-0003fA-QV for ged-emacs-devel@m.gmane-mx.org; Mon, 20 Sep 2021 11:51:40 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58792) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mSLZO-0002vo-Fy for emacs-devel@gnu.org; Mon, 20 Sep 2021 11:51:02 -0400 Original-Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]:51195) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mSLZN-0002Ga-1Y; Mon, 20 Sep 2021 11:51:02 -0400 Original-Received: by mail-pj1-x102e.google.com with SMTP id k23so12322018pji.0; Mon, 20 Sep 2021 08:51:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=yimNXFm0mh7/fmv5Efb/4EKKyeZW0rcvodJsvRXs8ME=; b=T7JKOJBaBNM0sUaGLyzjpc8BGPMn+eaeTOrI7fTYO9FowanKnlaB2SXDldSCAq8zO5 v6Et96PTcyxslTWp/e+J3gLK98XheF2cUQ+/IvJ9yD1yZS1nSlKqW7USjh0D54J9rVh1 HFCHjXTDgJQogKKSeezALOnfOxDFYy2fSFVIcGP/8WRby3RGVmeGcDqHjdx93OBN4k3M 7dF+X0CrjAFVZ5SBjyzqDGbULqCgPLrg4MO/ak5IpBInD3qJQ1o+aZT/JV4V+DbPiJaP GQKNymtFWb754vqxuI9h5deHaEZFjxcVKqvvDBRg/+tx6kSCQbDG0pWkq9mZV482K6a7 AfHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=yimNXFm0mh7/fmv5Efb/4EKKyeZW0rcvodJsvRXs8ME=; b=hChAa2iEIA3dqBHJpVuE6V+NHa99lQnAvNWDIE2xkFaoZNXr1UBnxk1rzB3ExsPoJt mLS0EMouXT0qQUzSR552HojKCeDLe0QiW8nVmbWICFicNj6QyWgmTRPBieclFo7M75sM ukXaBleyYSEv8m1JHCKjuRPEZyWEiUjbw+hggrP1CZr9EIS2DE5EZIqVRw/2eFB8BXIm FRv3P2hmhU9mwpopLFUg6ONxifCMqOC1q4mXwxc6tsE4IrduPYCNLd42ZsL2/91hhOUP IdRhNrfEOTcIQGK0V8FGYu2wAISpWs44ui96+wGbRLB4y2/tylDzGVPx5PtPrlU/JGm6 o9+Q== X-Gm-Message-State: AOAM532CGaSEF2GZFrpwuvr+KD08GWvgxgYwhlh/WY/qJV0MJa741hrz 8pLCngxBDE+t5sMw19K2QqtqzIChZAQdivz3g1fKA0wxMCg= X-Google-Smtp-Source: ABdhPJxRD0SIIlwsygDZSOAzMirKAOEmJHYzAUTMZBmfT7Xz/i55f6iaoR09JLHPa1sC1dS+AnieiMvnOo1iPGHwbdE= X-Received: by 2002:a17:90a:6c97:: with SMTP id y23mr30397986pjj.117.1632153058809; Mon, 20 Sep 2021 08:50:58 -0700 (PDT) In-Reply-To: <83fstz1cyj.fsf@gnu.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=ideasman42@gmail.com; helo=mail-pj1-x102e.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-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:275149 Archived-At: On Tue, Sep 21, 2021 at 1:31 AM Eli Zaretskii wrote: > > > From: Campbell Barton > > Date: Mon, 20 Sep 2021 23:49:28 +1000 > > > > Hi, I was wondering if buffer-local idle timers had been considered. > > I'm not sure I understand how would that work. Timers run as part of > the Emacs main command loop, so they are by their nature global. How > did you imagine that a buffer-local timer would express its "locality"? Yes, the idle timers themselves would be global, but only some buffers would have call-backs registered to run with these timers. Exactly how this works internally is an implementation detail, for the purpose of discussion it could work like this: ;; Setup might look like this. (setq-local my-timer-handle (run-with-idle-timer-local delay t 'my-fn)) Internally a pool of repeating timers would be kept, one for each unique delay used by one or more handles, this handle would be created and added to a list of handles associated with this timer. Running the timer would loop over callbacks running them if their buffer matches the current buffer. Any deleted buffers could have their timer-handles discarded at this point. ;; Cancel might look like this. (cancel-timer-local buffer timer-handle) This would remove the handle as well as the timer if there are no timer-handles left using this timer. -- - Campbell