all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#58677: eglot: Filter events according to FileSystemWatcher.kind
@ 2022-10-21  6:42 Brian Leung
       [not found] ` <handler.58677.B.166633454616996.ack@debbugs.gnu.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Brian Leung @ 2022-10-21  6:42 UTC (permalink / raw)
  To: 58677

[-- Attachment #1: Type: text/plain, Size: 514 bytes --]

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'


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-eglot-register-capability-Filter-events-per-FileSyst.patch --]
[-- Type: text/patch, Size: 3039 bytes --]

From 94d5b3a6f6c44b7e60ea46076638a50b203bf0ac Mon Sep 17 00:00:00 2001
From: Brian Leung <leungbk@posteo.net>
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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-eglot-register-capability-Tidy.patch --]
[-- Type: text/patch, Size: 2812 bytes --]

From 7103ab2db7b47e13cd50d8ebad54e918ea7e35e5 Mon Sep 17 00:00:00 2001
From: Brian Leung <leungbk@posteo.net>
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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#58677: [PATCH] eglot: Filter events according to FileSystemWatcher.kind
       [not found] ` <handler.58677.B.166633454616996.ack@debbugs.gnu.org>
@ 2022-10-21  8:02   ` Brian Leung
  2022-11-09  8:02     ` Brian Leung
  0 siblings, 1 reply; 4+ messages in thread
From: Brian Leung @ 2022-10-21  8:02 UTC (permalink / raw)
  To: 58677; +Cc: joaotavora


CCing Joao Tavora.

help-debbugs@gnu.org (GNU bug Tracking System) writes:

> Thank you for filing a new bug report with debbugs.gnu.org.
>
> This is an automatically generated reply to let you know your 
> message
> has been received.
>
> Your message is being forwarded to the package maintainers and 
> other
> interested parties for their attention; they will reply in due 
> course.
>
> Your message has been sent to the package maintainer(s):
>  bug-gnu-emacs@gnu.org
>
> If you wish to submit further information on this problem, 
> please
> send it to 58677@debbugs.gnu.org.
>
> Please do not send mail to help-debbugs@gnu.org unless you wish
> to report a problem with the Bug-tracking system.






^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#58677: [PATCH] eglot: Filter events according to FileSystemWatcher.kind
  2022-10-21  8:02   ` bug#58677: [PATCH] " Brian Leung
@ 2022-11-09  8:02     ` Brian Leung
  2022-11-11 15:29       ` João Távora
  0 siblings, 1 reply; 4+ messages in thread
From: Brian Leung @ 2022-11-09  8:02 UTC (permalink / raw)
  To: 58677; +Cc: Stefan Kangas, João Távora

Friendly ping.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#58677: [PATCH] eglot: Filter events according to FileSystemWatcher.kind
  2022-11-09  8:02     ` Brian Leung
@ 2022-11-11 15:29       ` João Távora
  0 siblings, 0 replies; 4+ messages in thread
From: João Távora @ 2022-11-11 15:29 UTC (permalink / raw)
  To: Brian Leung, 58677-done; +Cc: Stefan Kangas

[-- Attachment #1: Type: text/plain, Size: 315 bytes --]

Thanks, I pushed the first patch (the second whitespace fixing one is not
essential for now,
but I'll keep it around and probably join with other whitespace problems in
that file).

João

On Wed, Nov 9, 2022 at 8:03 AM Brian Leung <leungbk@posteo.net> wrote:

> Friendly ping.
>


-- 
João Távora

[-- Attachment #2: Type: text/html, Size: 702 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-11-11 15:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-21  6:42 bug#58677: eglot: Filter events according to FileSystemWatcher.kind Brian Leung
     [not found] ` <handler.58677.B.166633454616996.ack@debbugs.gnu.org>
2022-10-21  8:02   ` bug#58677: [PATCH] " Brian Leung
2022-11-09  8:02     ` Brian Leung
2022-11-11 15:29       ` João Távora

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.