all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Mauro Aranda <maurooaranda@gmail.com>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 45623@debbugs.gnu.org
Subject: bug#45623: 28.0.50; widget-backward sometimes skips one widget
Date: Mon, 04 Jan 2021 09:41:12 -0300	[thread overview]
Message-ID: <5ff30ceb.1c69fb81.db5ba.99bf@mx.google.com> (raw)
In-Reply-To: <8735zh57ij.fsf@gnus.org> (message from Lars Ingebrigtsen on Mon, 04 Jan 2021 11:19:32 +0100)

[-- Attachment #1: Type: text/plain, Size: 563 bytes --]

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Mauro Aranda <maurooaranda@gmail.com> writes:
>
>> I don't understand why that call to backward-char is there.  Does anyone
>> know of a situation where it is useful?
>
> If point is just after a button, it makes C-M-i not going to that
> button, but the previous one?  But that doesn't really sound like
> something you'd want, either?
>
> So, no, I don't see any situation where it would useful -- looks like a
> misfeature to me.

Agreed.  So, any objections to installing this patch and see if
something breaks?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Patch --]
[-- Type: text/x-patch, Size: 2153 bytes --]

From 86c211725ab39ddfc569a16fefd0db6724651b43 Mon Sep 17 00:00:00 2001
From: Mauro Aranda <maurooaranda@gmail.com>
Date: Sun, 3 Jan 2021 11:27:02 -0300
Subject: [PATCH] Don't skip widgets when moving backward

* lisp/wid-edit.el (widget-move): Remove code that caused
widget-backward to skip a previous adjacent widget when moving
backward from the start of a widget.  (Bug#45623)

* test/lisp/wid-edit-tests.el (widget-test-widget-backward): New test.
---
 lisp/wid-edit.el            |  1 -
 test/lisp/wid-edit-tests.el | 22 ++++++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
index f920130226..8b10d71dcb 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -1204,7 +1204,6 @@ widget-move
 ARG may be negative to move backward.
 When the second optional argument is non-nil,
 nothing is shown in the echo area."
-  (or (bobp) (> arg 0) (backward-char))
   (let ((wrapped 0)
 	(number arg)
 	(old (widget-tabable-at)))
diff --git a/test/lisp/wid-edit-tests.el b/test/lisp/wid-edit-tests.el
index 35235c6566..f2e8c321f5 100644
--- a/test/lisp/wid-edit-tests.el
+++ b/test/lisp/wid-edit-tests.el
@@ -301,4 +301,26 @@ widget-test-option-can-handle-inlinable-choice
       (should child)
       (should (equal (widget-value widget) '((1 "One")))))))
 
+(ert-deftest widget-test-widget-backward ()
+  "Test that `widget-backward' works OK."
+  (with-temp-buffer
+    (widget-insert "Testing.\n\n")
+    (dolist (el '("First" "Second" "Third"))
+      (widget-create 'push-button el))
+    (widget-insert "\n")
+    (goto-char (point-min))
+    (use-local-map widget-keymap)
+    (widget-setup)
+    ;; Check that moving from the widget's start works.
+    (widget-forward 3)
+    (should (string= "Third" (widget-value (widget-at))))
+    (widget-backward 1)
+    (should (string= "Second" (widget-value (widget-at))))
+    ;; Check that moving from inside the widget works.
+    (goto-char (point-min))
+    (widget-forward 3)
+    (forward-char)
+    (widget-backward 1)
+    (should (string= "Second" (widget-value (widget-at))))))
+
 ;;; wid-edit-tests.el ends here
-- 
2.29.2


  reply	other threads:[~2021-01-04 12:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-03 14:16 bug#45623: 28.0.50; widget-backward sometimes skips one widget Mauro Aranda
2021-01-04 10:19 ` Lars Ingebrigtsen
2021-01-04 12:41   ` Mauro Aranda [this message]
2021-01-04 12:47     ` Lars Ingebrigtsen
2021-01-04 13:19       ` Mauro Aranda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5ff30ceb.1c69fb81.db5ba.99bf@mx.google.com \
    --to=maurooaranda@gmail.com \
    --cc=45623@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.