Skip to content

Commit fd7dd00

Browse files
committed
[FIX] Display message instead of error on TAB
1 parent dc8bd43 commit fd7dd00

4 files changed

+14
-13
lines changed

Diff for: syncthing-constants.el

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
(defconst syncthing-day-seconds (* 1 60 60 24))
1212
(defconst syncthing-hour-seconds (* 1 60 60))
1313
(defconst syncthing-min-seconds (* 1 60))
14+
(defconst syncthing-msg-cant-edit-buffer
15+
"You can not edit this part of the Syncthing buffer")
1416

1517
;; Docstrings from Syncthing (MPL-2.0)
1618
;; https://www.fsf.org/blogs/licensing/mpl-2.0-release

Diff for: syncthing-errors.el

-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77

88
(define-error 'syncthing-error "Generic syncthing error")
99

10-
(define-error 'syncthing-error-cant-edit-buffer
11-
"You can not edit this part of the Syncthing buffer"
12-
'syncthing-error)
13-
1410
(define-error 'syncthing-error-cant-authenticate
1511
"Failed to authenticate, check the token!"
1612
'syncthing-error)

Diff for: syncthing-keyboard-tests.el

+10-8
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
(require 'widget)
1010

1111
(require 'syncthing-common)
12+
(require 'syncthing-constants)
1213
(require 'syncthing-errors)
1314
(require 'syncthing-keyboard)
1415

@@ -34,14 +35,15 @@
3435
"Throw an error when interacting with a non-widget."
3536
(syncthing-ert-cleanup)
3637
(with-temp-buffer
37-
(let (called)
38-
(condition-case err
39-
(syncthing--newline 1) ; Move into the button area first
40-
(syncthing-error
41-
(setq called t)
42-
(should (string= (error-message-string err)
43-
(get 'syncthing-error-cant-edit-buffer
44-
'error-message)))))
38+
(let (called args)
39+
(advice-add 'message
40+
:override
41+
(lambda (&rest largs) (setq called t) (setq args largs)))
42+
(syncthing--newline 1) ; Move into the button area first
43+
(advice-remove 'message
44+
(lambda (&rest largs) (setq called t) (setq args largs)))
45+
(should called)
46+
(should (string= (caddr args) syncthing-msg-cant-edit-buffer))
4547
(should called))))
4648

4749
(ert-deftest syncthing-keyboard-tab-fold-all ()

Diff for: syncthing-keyboard.el

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
(require 'wid-edit)
1010

1111
(require 'syncthing-common)
12+
(require 'syncthing-constants)
1213
(require 'syncthing-draw)
1314
(require 'syncthing-errors)
1415
(require 'syncthing-state)
@@ -39,7 +40,7 @@ Argument POS Incoming EVENT position."
3940
(let ((button (syncthing--get-widget pos)))
4041
(if button
4142
(widget-apply-action button event)
42-
(signal 'syncthing-error-cant-edit-buffer nil))))
43+
(message "%s: %s" syncthing-prefix syncthing-msg-cant-edit-buffer))))
4344

4445
(defun syncthing--tab (&rest _)
4546
"TAB handler.

0 commit comments

Comments
 (0)