Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
2025-04-07 Mats Lidell <matsl@gnu.org>

* hui-mouse.el (hkey-alist): Accept M-RET with vertico for all vertico input.

* test/MANIFEST: Add hui-mouse-tests.el

* test/hui-mouse-tests.el (hui-mouse-tests--hkey-alist): Verify a
predicate setting leads to the proper action.
(hui-mouse-tests--hkey-get-action): Helper that gets primary action
and assist action from hkey-alist for the predicates in effect.

2025-04-06 Mats Lidell <matsl@gnu.org>

* test/hy-test-helpers.el (hy-test-run-failing-flag): Set to non-nil to
Expand Down
5 changes: 2 additions & 3 deletions hui-mouse.el
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 04-Feb-89
;; Last-Mod: 22-Feb-25 at 16:18:02 by Bob Weiner
;; Last-Mod: 16-Mar-25 at 00:15:09 by Mats Lidell
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
Expand Down Expand Up @@ -256,8 +256,7 @@ Its default value is `smart-scroll-down'. To disable it, set it to
;; If in the minibuffer and reading an argument with vertico
;; run the vertico command on {M-RET} which accepts the first
;; line of minibuffer input, rather than any candidate.
((and hargs:reading-type
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m fine with everything here except the first line. We’ll have to think about how this could impact other things, i.e. the above line was put there for a reason.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can hargs:reading-type and vertico-mode be non-nil at the same time? If I remember correct they can not so the check on hargs:reading-type effectively ignores vertico reading the input.

Anyway I'm far from sure here. Could be a case where vertico is prompting for input where we want the action key to kick in instead? So I added a test case for hkey-alist so we can verify that different scenarios are handled properly. If we can identify the case we can add tests for that so we can verify that both scenarios works as expected.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we just add an appropriate check for whether the vertico-mode variable is true or not and dispatch as needed (defer to vertico) rather than touching the hargs:reading-type clause?

(> (minibuffer-depth) 0)
((and (> (minibuffer-depth) 0)
(eq (selected-window) (minibuffer-window))
(not (bound-and-true-p ivy-mode))
(and (bound-and-true-p vertico-mode)
Expand Down
1 change: 1 addition & 0 deletions test/MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ hpath-tests.el - unit tests for hpath
hsettings-test.el - unit tests for hsettings
hsys-org-tests.el - hsys-org tests
hui-mini-tests.el - hui-mini tests
hui-mouse-tests.el - hui-mouse tests
hui-register-tests.el - test for hui-register
hui-select-tests.el - hui-select tests
hui-tests.el - tests for hui.el Hyperbole UI
Expand Down
71 changes: 71 additions & 0 deletions test/hui-mouse-tests.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
;;; hui-mouse-tests.el --- unit tests for hui-mouse -*- lexical-binding: t; -*-
;;
;; Author: Mats Lidell
;;
;; Orig-Date: 15-Mar-25 at 22:39:37
;; Last-Mod: 16-Mar-25 at 01:14:39 by Mats Lidell
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
;; Copyright (C) 2025 Free Software Foundation, Inc.
;; See the "HY-COPY" file for license information.
;;
;; This file is part of GNU Hyperbole.

;;; Commentary:
;;
;; Unit tests for "../hui-mouse.el".

;;; Code:

(require 'ert)
(require 'el-mock)

(defun hui-mouse-tests--hkey-get-action ()
"Return the action given by the predicate that is true.
See `hkey-execute' for where this type of lookup is used."
(let ((hkey-forms hkey-alist)
pred-value hkey-actions hkey-form pred)
(while (and (null pred-value) (setq hkey-form (car hkey-forms)))
(if (setq hkey-actions (cdr hkey-form)
pred (car hkey-form)
pred-value (hypb:eval-debug pred))
nil
(setq hkey-forms (cdr hkey-forms))))
hkey-actions))

;; FIXME: Add more predicate cases from hkey-alist.
(ert-deftest hui-mouse-tests--hkey-alist ()
"Verify that given predicate values triggers the proper action."
;; Treemacs
(let ((major-mode 'treemacs-mode))
(should (equal (hui-mouse-tests--hkey-get-action)
(cons '(smart-treemacs) '(smart-treemacs)))))

;; dired-sidebar-mode
(let ((major-mode 'dired-sidebar-mode))
(should (equal (hui-mouse-tests--hkey-get-action)
(cons '(smart-dired-sidebar) '(smart-dired-sidebar)))))

;; Vertico
(defvar ivy-mode)
(defvar vertico-mode)
(let ((ivy-mode nil)
(vertico-mode t))
(mocklet (((minibuffer-depth) => 1)
((selected-window) => t)
((minibuffer-window) => t)
(vertico--command-p => t))
(should (equal (hui-mouse-tests--hkey-get-action)
(cons '(vertico-exit-input) '(vertico-exit-input)))))))

(provide 'hui-mouse-tests)

;; This file can't be byte-compiled without the `el-mock' package
;; which is not a dependency of Hyperbole.
;;
;; Local Variables:
;; no-byte-compile: t
;; End:

;;; hui-mouse-tests.el ends here