Skip to content

Commit e6f4010

Browse files
authored
Dispatch smart-eolp case to smart-org (#607)
Dispatch smart-eolp case to smart-org When Hyperbole context in org-mode should not be active, drop to later handlers in hkey-alist i.e. possibly smart-org handler.
1 parent ad04a25 commit e6f4010

File tree

3 files changed

+65
-3
lines changed

3 files changed

+65
-3
lines changed

ChangeLog

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
2024-11-16 Mats Lidell <[email protected]>
2+
3+
* test/hsys-org-tests.el (hsys-org--meta-return-on-end-of-line): Add test
4+
case for eol action in org-mode.
5+
6+
* hui-mouse.el (hkey-alist): Guard action-key-eol-function from acting
7+
when we should delegate to org-mode.
8+
19
2024-11-13 Bob Weiner <[email protected]>
210

311
* hywiki.el (hywiki-maybe-dehighlight-page-name,

hui-mouse.el

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
;; Author: Bob Weiner
44
;;
55
;; Orig-Date: 04-Feb-89
6-
;; Last-Mod: 19-Aug-24 at 22:17:10 by Bob Weiner
6+
;; Last-Mod: 15-Nov-24 at 23:01:31 by Mats Lidell
77
;;
88
;; SPDX-License-Identifier: GPL-3.0-or-later
99
;;
@@ -298,7 +298,9 @@ Its default value is `smart-scroll-down'. To disable it, set it to
298298
. ((funcall (key-binding (kbd "RET"))) . (funcall (key-binding (kbd "RET")))))
299299
;;
300300
;; If at the end of a line (eol), invoke the associated Smart Key handler EOL handler.
301-
((smart-eolp)
301+
((and (smart-eolp)
302+
(not (and (funcall hsys-org-mode-function)
303+
(not (equal hsys-org-enable-smart-keys t)))))
302304
. ((funcall action-key-eol-function) . (funcall assist-key-eol-function)))
303305
;;
304306
;; Handle any Org mode-specific contexts but give priority to Hyperbole

test/hsys-org-tests.el

+53-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
;; Author: Mats Lidell <[email protected]>
44
;;
55
;; Orig-Date: 23-Apr-21 at 20:55:00
6-
;; Last-Mod: 31-Jul-24 at 01:46:48 by Bob Weiner
6+
;; Last-Mod: 16-Nov-24 at 09:45:51 by Mats Lidell
77
;;
88
;; SPDX-License-Identifier: GPL-3.0-or-later
99
;;
@@ -225,6 +225,58 @@ This is independent of the setting of `hsys-org-enable-smart-keys'."
225225
(hsys-org--agenda-tags-string => ":tag"))
226226
(should (string= "agenda-func" (hsys-org-get-agenda-tags #'agenda-func)))))
227227

228+
(ert-deftest hsys-org--meta-return-on-end-of-line ()
229+
"Verify end-of-line behaves as `org-mode' when smart keys not enabled."
230+
(dolist (v '(nil :buttons))
231+
(let ((hsys-org-enable-smart-keys v))
232+
;;; One line no return
233+
(with-temp-buffer
234+
(org-mode)
235+
(insert "* h1")
236+
(goto-char 1)
237+
(end-of-line)
238+
(with-mock
239+
(mock (hsys-org-meta-return) => t)
240+
(should (equal hsys-org-enable-smart-keys v)) ; Ert traceability
241+
(should (action-key))))
242+
;;; Two lines
243+
(with-temp-buffer
244+
(org-mode)
245+
(insert "* h1\n* h2\n")
246+
(goto-char 1)
247+
(end-of-line)
248+
(with-mock
249+
(mock (hsys-org-meta-return) => t)
250+
(should (equal hsys-org-enable-smart-keys v)) ; Ert traceability
251+
(should (action-key))))))
252+
(let ((hsys-org-enable-smart-keys t)
253+
(v t))
254+
;;; One line no return
255+
;; At end of line is also end of file so smart-eolp filters out
256+
;; this as a Hyperbole context and org instead picks it
257+
;; up. Possibly a confusing behavior!? Should eof only be when
258+
;; action is below last visible line to avoid this case?
259+
(with-temp-buffer
260+
(org-mode)
261+
(insert "* h1")
262+
(goto-char 1)
263+
(end-of-line)
264+
(with-mock
265+
(mock (hsys-org-meta-return) => t)
266+
(should (equal hsys-org-enable-smart-keys v)) ; Ert traceability
267+
(should (action-key))))
268+
;;; Two lines
269+
;; Hyperbole context is active and smart scroll is triggered.
270+
(with-temp-buffer
271+
(org-mode)
272+
(insert "* h1\n* h2\n")
273+
(goto-char 1)
274+
(end-of-line)
275+
(with-mock
276+
(mock (smart-scroll-up) => t)
277+
(should (equal hsys-org-enable-smart-keys v)) ; Ert traceability
278+
(should (action-key))))))
279+
228280
(provide 'hsys-org-tests)
229281

230282
;; This file can't be byte-compiled without the `el-mock' package

0 commit comments

Comments
 (0)