Subject: bug#68915: Request to include a couple of packages in GNU ELPA

From: Stefan Monnier <[email-masked]>
Date: Sun, 04 Feb 2024 11:24:01 -0500

>>> I would like to propose a couple of my packages for inclusion in GNU
>>> ELPA. They are:
>>>
>>> 1) consult-hoogle: https://codeberg.org/rahguzar/consult-hoogle
>>> It allows the use of hoogle search engine for haskell programming
>>> language from Emacs using the interfaces provided by consult package.
>>>
>>> 2) filechooser.el: https://codeberg.org/rahguzar/filechooser
>>> It implements the backend D-bus methods for xdg filechooser and can be
>>> used to provide an Emacs based file selection interface for applications
>>> such as web browsers which support using xdg desktop portals for this
>>> purpose.

Thanks, added.

>>> Please let me know of any suggestions and if I need to change anything.

For both of those packages, it'd be nice to add a `.gitignore` with
something like:

    *.elc
    
    # ELPA-generated files
    /consult-hoogle-autoloads.el
    /consult-hoogle-pkg.el

For `consult-hoogle` I suggest you add a `.elpaignore` so as to prevent
the large PNG files to make their way into the tarball, since they're so
much larger than the rest of the package and they're not really useful
in `~/.emacs.d/elpa`.

For `filechooser.el`, I see you bumped into the fact that `bytecomp.el`
doesn't keep track of those functions defined within a `let`, so you
refrained from using #' to refer to those functions.

The better solution is to send a patch for `bytecomp.el`, of course, but
in this specific case you could workaround the problem with something
like the (guaranteed 100% untested) patch below.  It's not very pretty,
so I recommend you look into that `bytecomp.el` patch 🙂.

        Stefan

diff --git a/filechooser.el b/filechooser.el
index cc96386112..7df375807c 100644
--- a/filechooser.el
+++ b/filechooser.el
@@ -417,21 +417,23 @@ is used, othewise the selected frame is used. PROMPT and DIR are as in
         names))))
 
 ;;; Dired based selection
-(let (marked unmarked timer)
-  (defun filechooser--adjust-selection-buffer ()
-    (when (buffer-live-p (cdr filechooser--selection))
-      (with-current-buffer (cdr filechooser--selection)
-        (cl-callf cl-set-difference (cdr dired-directory) unmarked :test #'equal)
-        (when marked
-          (cl-callf nreverse (cdr dired-directory))
-          (dolist (file marked)
-            (cl-pushnew file (cdr dired-directory) :test #'equal))
-          (cl-callf nreverse (cdr dired-directory)))
-        (revert-buffer)))
-    (setq marked nil unmarked nil timer nil))
-
-  (defun filechooser--process-changed-marks (beg end length)
-    "Deal with change in mark from BEG to END with LENGTH."
+(defalias 'filechooser--process-changed-marks
+  (let (marked unmarked timer)
+    (lambda (beg end length)
+      "Deal with change in mark from BEG to END with LENGTH."
+      (cl-flet
+          ((adjust-selection-buffer ()
+             (when (buffer-live-p (cdr filechooser--selection))
+               (with-current-buffer (cdr filechooser--selection)
+                 (cl-callf cl-set-difference (cdr dired-directory) unmarked :test #'equal)
+                 (when marked
+                   (cl-callf nreverse (cdr dired-directory))
+                   (dolist (file marked)
+                     (cl-pushnew file (cdr dired-directory) :test #'equal))
+                   (cl-callf nreverse (cdr dired-directory)))
+                 (revert-buffer)))
+             (setq marked nil unmarked nil timer nil)))
+
     (when (and (derived-mode-p 'dired-mode)
                (eq length 0) (eq (1+ beg) end)
                (not (invisible-p (1- (pos-eol)))))
@@ -444,7 +446,7 @@ is used, othewise the selected frame is used. PROMPT and DIR are as in
           (push (dired-get-filename nil t) unmarked))
         (unless timer
           (setq timer (run-with-timer
-                       0.2 nil 'filechooser--adjust-selection-buffer)))))))
+                       0.2 nil #'adjust-selection-buffer)))))))))
 
 (defun filechooser-dired (&optional dir filters)
   "Select some files using Dired.
@@ -474,7 +476,7 @@ editing session. FILTERS are in the format of `filechooser-filters'."
                  (jit-lock-mode t))
                (push overriding-map emulation-mode-map-alists)
                (add-hook 'window-buffer-change-functions apply-filters)
-               (add-hook 'after-change-functions 'filechooser--process-changed-marks)
+               (add-hook 'after-change-functions #'filechooser--process-changed-marks)
                (setq filechooser--filters (append filechooser-filters filters))
                (other-window 1)
                (dired (or dir default-directory))
@@ -484,7 +486,7 @@ editing session. FILTERS are in the format of `filechooser-filters'."
                    (cdr dired-directory))))
       (cl-callf2 delq overriding-map emulation-mode-map-alists)
       (remove-hook 'window-buffer-change-functions apply-filters)
-      (remove-hook 'after-change-functions 'filechooser--process-changed-marks)
+      (remove-hook 'after-change-functions #'filechooser--process-changed-marks)
       (kill-buffer (cdr filechooser--selection))
       (setcdr filechooser--selection nil)
       (dolist (buf (match-buffers `(derived-mode . dired-mode) (frame-parameter nil 'buffer-list)))