GNU bug report logs - #45623
28.0.50; widget-backward sometimes skips one widget

Previous Next

Package: emacs;

Reported by: Mauro Aranda <maurooaranda <at> gmail.com>

Date: Sun, 3 Jan 2021 14:17:01 UTC

Severity: normal

Tags: fixed

Found in version 28.0.50

Done: Mauro Aranda <maurooaranda <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 45623 in the body.
You can then email your comments to 45623 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#45623; Package emacs. (Sun, 03 Jan 2021 14:17:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Mauro Aranda <maurooaranda <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 03 Jan 2021 14:17:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Mauro Aranda <maurooaranda <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.0.50; widget-backward sometimes skips one widget
Date: Sun, 03 Jan 2021 11:16:01 -0300
Starting from emacs -Q:

1. Eval the following code:
(require 'wid-edit)

(defun test-widget-backward ()
  (interactive)
  (switch-to-buffer "*Widget Test*")
  (kill-all-local-variables)
  (let ((inhibit-read-only t))
    (erase-buffer))
  (remove-overlays)
  (widget-insert "Testing widget movement commands.\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))

2. C-u 3 C-i to move to the start of the button labeled Third:

3. C-M-i to run the widget-backward command.

Point moves to the start of the button labeled First, not to the
start of the button labeled Second.  I expected point to move to the
start of the button labeled Second.


If instead I use buttons from button.el, moving point with
backward-button (the analogous to widget-backward) behaves as I
expected.


The very first line of widget-move is:
(or (bobp) (> arg 0) (backward-char))

That backward-char moves point from the third button to the second
button before starting to look for the previous widget, so that's the
reason point ends up at the start of the first button.

I don't understand why that call to backward-char is there.  Does anyone
know of a situation where it is useful?


In GNU Emacs 28.0.50 (build 8, x86_64-pc-linux-gnu, GTK+ Version 3.22.30, cairo version 1.15.10)
 of 2021-01-03 built on tbb-desktop
Repository revision: 825b4ec338e82869dc656c7041ab2483b6c22479
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12008000
System Description: Ubuntu 18.04.5 LTS

Configured features:
XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND DBUS GSETTINGS GLIB NOTIFY
INOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE HARFBUZZ ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS PDUMPER

Important settings:
  value of $LC_MONETARY: es_AR.UTF-8
  value of $LC_NUMERIC: es_AR.UTF-8
  value of $LC_TIME: es_AR.UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Fundamental

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml easymenu mml-sec epa derived epg epg-config gnus-util rmail
rmail-loaddefs auth-source cl-seq eieio eieio-core cl-macs
eieio-loaddefs password-cache json map text-property-search time-date
subr-x seq byte-opt gv bytecomp byte-compile cconv mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail
rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils wid-edit
cl-loaddefs cl-lib iso-transl tooltip eldoc electric uniquify ediff-hook
vc-hooks lisp-float-type mwheel term/x-win x-win term/common-win x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list replace
newcomment text-mode elisp-mode lisp-mode prog-mode register page
tab-bar menu-bar rfn-eshadow isearch timer select scroll-bar mouse
jit-lock font-lock syntax facemenu font-core term/tty-colors frame
minibuffer cl-generic cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite charscript charprop case-table epa-hook jka-cmpr-hook help
simple abbrev obarray cl-preloaded nadvice button loaddefs faces
cus-face macroexp files window text-properties overlay sha1 md5 base64
format env code-pages mule custom widget hashtable-print-readable
backquote threads dbusbind inotify dynamic-setting system-font-setting
font-render-setting cairo move-toolbar gtk x-toolkit x multi-tty
make-network-process emacs)

Memory information:
((conses 16 54440 9138)
 (symbols 48 7084 1)
 (strings 32 19227 1450)
 (string-bytes 1 632153)
 (vectors 16 12046)
 (vector-slots 8 168478 8434)
 (floats 8 23 47)
 (intervals 56 240 0)
 (buffers 984 12))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45623; Package emacs. (Mon, 04 Jan 2021 10:20:02 GMT) Full text and rfc822 format available.

Message #8 received at 45623 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Mauro Aranda <maurooaranda <at> gmail.com>
Cc: 45623 <at> debbugs.gnu.org
Subject: Re: bug#45623: 28.0.50; widget-backward sometimes skips one widget
Date: Mon, 04 Jan 2021 11:19:32 +0100
Mauro Aranda <maurooaranda <at> 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.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45623; Package emacs. (Mon, 04 Jan 2021 12:42:01 GMT) Full text and rfc822 format available.

Message #11 received at 45623 <at> debbugs.gnu.org (full text, mbox):

From: Mauro Aranda <maurooaranda <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 45623 <at> debbugs.gnu.org
Subject: Re: bug#45623: 28.0.50; widget-backward sometimes skips one widget
Date: Mon, 04 Jan 2021 09:41:12 -0300
[Message part 1 (text/plain, inline)]
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Mauro Aranda <maurooaranda <at> 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?

[0001-Don-t-skip-widgets-when-moving-backward.patch (text/x-patch, inline)]
From 86c211725ab39ddfc569a16fefd0db6724651b43 Mon Sep 17 00:00:00 2001
From: Mauro Aranda <maurooaranda <at> 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


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45623; Package emacs. (Mon, 04 Jan 2021 12:48:01 GMT) Full text and rfc822 format available.

Message #14 received at 45623 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Mauro Aranda <maurooaranda <at> gmail.com>
Cc: 45623 <at> debbugs.gnu.org
Subject: Re: bug#45623: 28.0.50; widget-backward sometimes skips one widget
Date: Mon, 04 Jan 2021 13:47:42 +0100
Mauro Aranda <maurooaranda <at> gmail.com> writes:

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

Go ahead.

We've had some of the same issues with TAB/BACKTAB with button.el
buttons (and eww links) -- the edge cases where two buttons touch each
other have been under-scrutinised, although I hope I got all of them the
last time.  *crosses fingers*

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45623; Package emacs. (Mon, 04 Jan 2021 13:20:02 GMT) Full text and rfc822 format available.

Message #17 received at 45623 <at> debbugs.gnu.org (full text, mbox):

From: Mauro Aranda <maurooaranda <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 45623 <at> debbugs.gnu.org
Subject: Re: bug#45623: 28.0.50; widget-backward sometimes skips one widget
Date: Mon, 04 Jan 2021 10:19:38 -0300
tags 45623 fixed
close 45623
quit


Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Mauro Aranda <maurooaranda <at> gmail.com> writes:
>
>> Agreed.  So, any objections to installing this patch and see if
>> something breaks?
>
> Go ahead.

Thanks; done.




Added tag(s) fixed. Request was from Mauro Aranda <maurooaranda <at> gmail.com> to control <at> debbugs.gnu.org. (Mon, 04 Jan 2021 13:20:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 45623 <at> debbugs.gnu.org and Mauro Aranda <maurooaranda <at> gmail.com> Request was from Mauro Aranda <maurooaranda <at> gmail.com> to control <at> debbugs.gnu.org. (Mon, 04 Jan 2021 13:20:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 02 Feb 2021 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 139 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.