From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Brian Leung Newsgroups: gmane.emacs.bugs Subject: bug#58677: eglot: Filter events according to FileSystemWatcher.kind Date: Fri, 21 Oct 2022 06:42:01 +0000 Message-ID: <8735bhwudi.fsf@posteo.net> 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="33368"; mail-complaints-to="usenet@ciao.gmane.io" To: 58677@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Oct 21 08:48:14 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 1ollpF-0008Jt-LM for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 21 Oct 2022 08:48:13 +0200 Original-Received: from localhost ([::1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ollpD-00058g-UO for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 21 Oct 2022 02:48:11 -0400 Original-Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ollkH-0007fg-Cg for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 21 Oct 2022 02:43:05 -0400 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 1ollkF-0007bN-7x for bug-gnu-emacs@gnu.org; Fri, 21 Oct 2022 02:43:03 -0400 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 1ollkE-0004mz-VY for bug-gnu-emacs@gnu.org; Fri, 21 Oct 2022 02:43:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ollkE-0004R2-H4 for bug-gnu-emacs@gnu.org; Fri, 21 Oct 2022 02:43:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Brian Leung Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 21 Oct 2022 06:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 58677 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.166633454616996 (code B ref -1); Fri, 21 Oct 2022 06:43:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 21 Oct 2022 06:42:26 +0000 Original-Received: from localhost ([127.0.0.1]:36720 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1olljd-0004Q3-Lm for submit@debbugs.gnu.org; Fri, 21 Oct 2022 02:42:26 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:56340) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ollja-0004Pt-Bj for submit@debbugs.gnu.org; Fri, 21 Oct 2022 02:42:23 -0400 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 1olljX-0005G3-VX for bug-gnu-emacs@gnu.org; Fri, 21 Oct 2022 02:42:21 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olljL-0004eZ-0o for bug-gnu-emacs@gnu.org; Fri, 21 Oct 2022 02:42:19 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 0EE73240027 for ; Fri, 21 Oct 2022 08:42:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1666334525; bh=EeGWgRHw/3uzYQd05Ym2h6mxohWtkSgNtR1qk5guV3w=; h=From:To:Subject:Date:From; b=ogvcjPOKFYSc3ESw44JMpJGkIsSXR40eL4/P5Lp9Y+vathtHC/9h0C/17aY5J9gkq Q8yYM5GrohZ9kL/m8chocZdMg+z1LJHTzrm+w+oQwc3p2q96s906c5xRQdQJsQscEL R+NdYqtONlE7i5l9Trzr6+wy9Ht2/WlsizG89/Iem4r1YhLeLY2+VGOTvHYfERjC2n 6AEfFBSamPBSiVGuIfyWveIesCt/d0Q8dY4nHLSOvo1ePQ+9MY6iPO4B/y/TFrfIAQ OVhiJg0y88Ek4D36ouOxpmIwI+SisdMcvL99X+MlViFOvDxQ9YbqQZp1DC3wfttlWb 0lfZVKuZWkOOg== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Mtvyg197Pz6tm6 for ; Fri, 21 Oct 2022 08:42:02 +0200 (CEST) Received-SPF: pass client-ip=185.67.36.65; envelope-from=leungbk@posteo.net; helo=mout01.posteo.de 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" Xref: news.gmane.io gmane.emacs.bugs:245964 Archived-At: --=-=-= Content-Type: text/plain Tags: patch In GNU Emacs 28.2 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw3d scroll bars) Repository revision: emacs-28.2 Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12014000 System Description: NixOS 22.11 (Raccoon) Configured using: 'configure --prefix=/nix/store/dg76kpq89k20ciqqlrzi69xgyl6n13b0-emacs-unstable-28.2 --disable-build-details --with-modules --with-x-toolkit=lucid --with-xft --with-cairo --with-native-compilation' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-eglot-register-capability-Filter-events-per-FileSyst.patch >From 94d5b3a6f6c44b7e60ea46076638a50b203bf0ac Mon Sep 17 00:00:00 2001 From: Brian Leung Date: Tue, 2 Feb 2021 11:23:25 -0800 Subject: [PATCH 1/2] eglot-register-capability: Filter events per FileSystemWatcher.kind * eglot.el (eglot-register-capability): Only send notifications of interest, as determined by the optional FileSystemWatcher.kind bitmask. When the FileSystemWatcher.kind property is omitted, use the default value of 7, which is computed from taking the bitwise OR operation WatchKind.Create (1) | WatchKind.Change (2) | WatchKind.Delete (4). --- eglot.el | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 901bf30..4040d07 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -3253,8 +3253,10 @@ at point. With prefix argument, prompt for ACTION-KIND." (eglot-unregister-capability server method id) (let* (success (globs (mapcar - (eglot--lambda ((FileSystemWatcher) globPattern) - (eglot--glob-compile globPattern t t)) + (eglot--lambda ((FileSystemWatcher) globPattern kind) + (cons + (eglot--glob-compile globPattern t t) + (or kind 7))) watchers)) (dirs-to-watch (delete-dups (mapcar #'file-name-directory @@ -3263,17 +3265,22 @@ at point. With prefix argument, prompt for ACTION-KIND." (cl-labels ((handle-event (event) - (pcase-let ((`(,desc ,action ,file ,file1) event)) + (pcase-let* ((`(,desc ,action ,file ,file1) event) + (action-type (cl-case action + (created 1) + (changed 2) + (deleted 3))) + (action-bit (when action-type + (ash 1 (1- action-type))))) (cond ((and (memq action '(created changed deleted)) - (cl-find file globs :test (lambda (f g) (funcall g f)))) + (cl-loop for (glob . kind-bitmask) in globs + thereis (and (> (logand kind-bitmask action-bit) 0) + (funcall glob file)))) (jsonrpc-notify server :workspace/didChangeWatchedFiles `(:changes ,(vector `(:uri ,(eglot--path-to-uri file) - :type ,(cl-case action - (created 1) - (changed 2) - (deleted 3))))))) + :type ,action-type))))) ((eq action 'renamed) (handle-event `(,desc 'deleted ,file)) (handle-event `(,desc 'created ,file1))))))) -- 2.37.3 --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0002-eglot-register-capability-Tidy.patch >From 7103ab2db7b47e13cd50d8ebad54e918ea7e35e5 Mon Sep 17 00:00:00 2001 From: Brian Leung Date: Thu, 4 Feb 2021 21:52:29 -0800 Subject: [PATCH 2/2] eglot--register-capability: Tidy --- eglot.el | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 4040d07..07bc7d5 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -3265,25 +3265,24 @@ at point. With prefix argument, prompt for ACTION-KIND." (cl-labels ((handle-event (event) - (pcase-let* ((`(,desc ,action ,file ,file1) event) - (action-type (cl-case action - (created 1) - (changed 2) - (deleted 3))) - (action-bit (when action-type - (ash 1 (1- action-type))))) - (cond - ((and (memq action '(created changed deleted)) - (cl-loop for (glob . kind-bitmask) in globs - thereis (and (> (logand kind-bitmask action-bit) 0) - (funcall glob file)))) - (jsonrpc-notify - server :workspace/didChangeWatchedFiles - `(:changes ,(vector `(:uri ,(eglot--path-to-uri file) - :type ,action-type))))) - ((eq action 'renamed) - (handle-event `(,desc 'deleted ,file)) - (handle-event `(,desc 'created ,file1))))))) + (pcase-let ((`(,desc ,action ,file ,file1) event)) + (cl-case action + ((created changed deleted) + (cl-loop with action-type = (cl-case action + (created 1) + (changed 2) + (deleted 3)) + with action-bit = (ash 1 (1- action-type)) + for (glob . kind-bitmask) in globs + when (and (> (logand kind-bitmask action-bit) 0) + (funcall glob file)) + return (jsonrpc-notify + server :workspace/didChangeWatchedFiles + `(:changes ,(vector `(:uri ,(eglot--path-to-uri file) + :type ,action-type)))))) + (renamed + (handle-event `(,desc 'deleted ,file)) + (handle-event `(,desc 'created ,file1))))))) (unwind-protect (progn (dolist (dir dirs-to-watch) -- 2.37.3 --=-=-=--