Quellcode durchsuchen

Fix xwwp-follow-link quit behaviour with Helm completion backend

When using helm and `C-g`, the Helm backend candidate function returns nil instead of propagating the `quit` signal which prevents the `xwwp-follow-link` cleanup to happen on `C-g` (the links stay highlighted) . This commit makes the Helm candidate function behave like the other ones by raising `quit` if it returns nil.
Qiantan Hong vor 5 Jahren
Ursprung
Commit
0f820c6a33
2 geänderte Dateien mit 16 neuen und 17 gelöschten Zeilen
  1. 10 10
      xwwp-follow-link-helm.el
  2. 6 7
      xwwp-follow-link.el

+ 10 - 10
xwwp-follow-link-helm.el

@@ -55,16 +55,16 @@
                                           (with-current-buffer "*helm-xwwp*"
                                             (add-hook 'helm-move-selection-after-hook update-fn nil t)))
             nil t)
-  (helm :sources
-        (helm-make-source "Xwidget Plus" 'helm-source-sync
-                          :candidates collection
-                          :action action
-                          :filtered-candidate-transformer (lambda (candidates _)
-                                                            (oset backend candidates candidates)
-                                                            (funcall update-fn)
-                                                            candidates))
-        :prompt prompt
-        :buffer "*helm-xwwp*"))
+  (or (helm :sources
+            (helm-make-source "Xwidget Plus" 'helm-source-sync
+              :candidates collection
+              :action action
+              :filtered-candidate-transformer (lambda (candidates _)
+                                                (oset backend candidates candidates)
+                                                (funcall update-fn)
+                                                candidates))
+            :prompt prompt
+            :buffer "*helm-xwwp*") (signal 'quit nil)))
 
 (provide 'xwwp-follow-link-helm)
 ;;; xwwp-follow-link-helm.el ends here

+ 6 - 7
xwwp-follow-link.el

@@ -217,13 +217,12 @@ browser."
   (let* ((xwidget (xwidget-webkit-current-session))
          (links (xwwp-follow-link-prepare-links links)))
     (oset xwwp-follow-link-completion-backend-instance collection links)
-    (unwind-protect
-        (condition-case nil
-            (xwwp-follow-link-read xwwp-follow-link-completion-backend-instance
-                                   "Link: " links
-                                   (apply-partially #'xwwp-follow-link-trigger-action xwidget)
-                                   (apply-partially #'xwwp-follow-link-update xwidget))
-          (quit (xwwp-follow-link-cleanup xwidget))))
+    (condition-case nil
+        (xwwp-follow-link-read xwwp-follow-link-completion-backend-instance
+                               "Link: " links
+                               (apply-partially #'xwwp-follow-link-trigger-action xwidget)
+                               (apply-partially #'xwwp-follow-link-update xwidget))
+      (quit (xwwp-follow-link-cleanup xwidget)))
     (oset xwwp-follow-link-completion-backend-instance collection nil)))
 
 ;;;###autoload