all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#40788: 28.0.50; Error running timer ‘custom-magic-reset’
@ 2020-04-23  5:10 David Ponce
  2020-04-23 17:39 ` David PONCE
  0 siblings, 1 reply; 7+ messages in thread
From: David Ponce @ 2020-04-23  5:10 UTC (permalink / raw)
  To: 40788

Hello,

Here is the recipe for an error I encounter when using customize with
2 windows in the same frame:

emacs -Q
M-x pop-to-buffer RET *Message*
M-x customize-variable RET blink-cursor-alist

At this point the *scratch* buffer is on top window and the customize
buffer on bottom.

Click on 'INS' button and insert a new Key/Value pair
Clict on 'State' button, then 'Set for Current Session'

Then click somewhere in the *scratch* buffer, then click on the 'DEL'
button in the customize buffer to delete the value previously entered.

At this point custom try to redraw the 'State' button in the *scratch*
buffer instead of the customize buffer! In this case, because the
*scratch* buffer is shorter than the position of the State button, it
fails with the error:

Error running timer ‘custom-magic-reset’: (args-out-of-range #<buffer
*scratch*> #<marker (moves after insertion) at 287 in *Customize Option:
Blink Cursor Alist*> #<marker at 294 in *Customize Option: Blink Cursor
Alist*>)

This error can be severe because, if in place of the *scratch* buffer
you were editing a file big enough to include the position of the 'State'
button, the 'State' button is drawn in your file without you realizing it!
And if you ever realize it, this change cannot be undone!

Thanks!

In GNU Emacs 28.0.50 (build 32, x86_64-pc-linux-gnu, GTK+ Version 3.24.13, cairo version 1.16.0)
  of 2020-04-23 built
Repository revision: 7b15cc3ebb45e50ac5faf3bbc2a813afffdaa418
Repository branch: master
Windowing system distributor 'Fedora Project', version 11.0.12006000
System Description: Fedora 31 (KDE Plasma)

Recent messages:
Mark set
Creating customization items...
Creating customization items ...done
Creating customization setup...done
Mark set
Beginning of buffer
Mark set [2 times]
scroll-up-command: End of buffer

Configured using:
  'configure --prefix=/home/dponce --with-cairo
  PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig'

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

Important settings:
   value of $LC_TIME: fr_FR.utf8
   value of $LANG: fr_FR.UTF-8
   locale-coding-system: utf-8-unix

Major mode: Messages

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
   buffer-read-only: 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
format-spec rfc822 mml mml-sec password-cache epa derived epg epg-config
gnus-util rmail rmail-loaddefs text-property-search mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail
rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils vc-git
diff-mode easy-mmode bug-reference eieio-opt cl-extra seq speedbar
ezimage dframe cl-print debug backtrace find-func cus-theme eieio-custom
cl-seq eieio byte-opt bytecomp byte-compile cconv eieio-core cl-macs gv
eieio-loaddefs wid-browse tree-widget thingatpt help-fns radix-tree
help-mode cus-edit easymenu cus-start cus-load wid-edit time-date subr-x
cl-loaddefs cl-lib 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 loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote threads dbusbind
inotify lcms2 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 98994 16077)
  (symbols 48 10003 1)
  (strings 32 26548 2003)
  (string-bytes 1 811951)
  (vectors 16 14342)
  (vector-slots 8 182195 11344)
  (floats 8 43 119)
  (intervals 56 4061 0)
  (buffers 992 16))





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#40788: 28.0.50; Error running timer ‘custom-magic-reset’
  2020-04-23  5:10 bug#40788: 28.0.50; Error running timer ‘custom-magic-reset’ David Ponce
@ 2020-04-23 17:39 ` David PONCE
  2020-04-24 11:56   ` Robert Pluim
  0 siblings, 1 reply; 7+ messages in thread
From: David PONCE @ 2020-04-23 17:39 UTC (permalink / raw)
  To: 40788

Hello again,

Below is a possible patch that seems to have fixed the issue for me.
But I am not sure the approach is correct 

Thanks!

diff --git a/installs/emacs/lisp/cus-edit.el b/emacs.d/cus-edit.el
index d3d17fd..eec7ef0 100644
--- a/installs/emacs/lisp/cus-edit.el
+++ b/emacs.d/cus-edit.el
@@ -2217,9 +2217,16 @@ and `face'."
;; commands like `M-u' (that work on a region in the buffer)
;; will upcase the wrong part of the buffer, since more text has
;; been inserted before point.
- (run-with-idle-timer 0.0 nil #'custom-magic-reset widget)
+ (run-with-idle-timer 0.0 nil #'custom-magic-reset-async (current-buffer) widget)
(apply 'widget-default-notify widget args))))

+(defun custom-magic-reset-async (buffer widget)
+ "Redraw the :custom-magic property of WIDGET.
+Called asynchronously thru an idle timer, ensure redrawing will happen in the
+origin custom BUFFER."
+ (set-buffer buffer)
+ (custom-magic-reset widget))
+
(defun custom-redraw (widget)
"Redraw WIDGET with current settings."
(let ((line (count-lines (point-min) (point)))







^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#40788: 28.0.50; Error running timer ‘custom-magic-reset’
  2020-04-23 17:39 ` David PONCE
@ 2020-04-24 11:56   ` Robert Pluim
  2020-04-24 15:56     ` David Ponce
  0 siblings, 1 reply; 7+ messages in thread
From: Robert Pluim @ 2020-04-24 11:56 UTC (permalink / raw)
  To: David PONCE; +Cc: 40788

>>>>> On Thu, 23 Apr 2020 19:39:26 +0200 (CEST), David PONCE <da_vid@orange.fr> said:

    David> Hello again,
    David> Below is a possible patch that seems to have fixed the issue for me.
    David> But I am not sure the approach is correct 

Rather than defining a new function, you can add an argument to the
existing one. Something like (untested)

diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el
index d3d17fda7a..93012b134f 100644
--- a/lisp/cus-edit.el
+++ b/lisp/cus-edit.el
@@ -2102,11 +2102,12 @@ custom-magic-value-create
 	(insert " "))
       (widget-put widget :children children))))
 
-(defun custom-magic-reset (widget)
+(defun custom-magic-reset (widget &optional buffer)
   "Redraw the :custom-magic property of WIDGET."
-  (let ((magic (widget-get widget :custom-magic)))
-    (when magic
-      (widget-value-set magic (widget-value magic)))))
+  (with-current-buffer (or buffer (current-buffer))
+    (let ((magic (widget-get widget :custom-magic)))
+      (when magic
+        (widget-value-set magic (widget-value magic))))))
 
 ;;; The `custom' Widget.
 
@@ -2217,7 +2218,7 @@ custom-notify
       ;; commands like `M-u' (that work on a region in the buffer)
       ;; will upcase the wrong part of the buffer, since more text has
       ;; been inserted before point.
-      (run-with-idle-timer 0.0 nil #'custom-magic-reset widget)
+      (run-with-idle-timer 0.0 nil #'custom-magic-reset widget (current-buffer))
       (apply 'widget-default-notify widget args))))
 
 (defun custom-redraw (widget)





^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#40788: 28.0.50; Error running timer ‘custom-magic-reset’
  2020-04-24 11:56   ` Robert Pluim
@ 2020-04-24 15:56     ` David Ponce
  2020-07-21  8:39       ` Robert Pluim
  0 siblings, 1 reply; 7+ messages in thread
From: David Ponce @ 2020-04-24 15:56 UTC (permalink / raw)
  To: Robert Pluim; +Cc: 40788

On 24/04/2020 13:56, Robert Pluim wrote:
>>>>>> On Thu, 23 Apr 2020 19:39:26 +0200 (CEST), David PONCE <da_vid@orange.fr> said:
> 
>      David> Hello again,
>      David> Below is a possible patch that seems to have fixed the issue for me.
>      David> But I am not sure the approach is correct
> 
> Rather than defining a new function, you can add an argument to the
> existing one. Something like (untested)

Hi Robert,

Sure, your patch is better :-)
I tested it, and I confirm it fixes the issue :-)
I also tested the below variant, because it seems to me that it is not
necessary to set the buffer when magic is nil, as there is nothing to do.

Please feel free to apply which version looks better to you.
Thanks!

diff --git a/home/dponce/installs/emacs/lisp/cus-edit.el b/cus-edit.el
index d3d17fd..490d905 100644
--- a/home/dponce/installs/emacs/lisp/cus-edit.el
+++ b/cus-edit.el
@@ -2102,11 +2102,12 @@ and `face'."
  	(insert " "))
        (widget-put widget :children children))))
  
-(defun custom-magic-reset (widget)
+(defun custom-magic-reset (widget &optional buffer)
    "Redraw the :custom-magic property of WIDGET."
    (let ((magic (widget-get widget :custom-magic)))
      (when magic
-      (widget-value-set magic (widget-value magic)))))
+      (with-current-buffer (or buffer (current-buffer))
+        (widget-value-set magic (widget-value magic))))))
  
  ;;; The `custom' Widget.
  
@@ -2217,7 +2218,7 @@ and `face'."
        ;; commands like `M-u' (that work on a region in the buffer)
        ;; will upcase the wrong part of the buffer, since more text has
        ;; been inserted before point.
-      (run-with-idle-timer 0.0 nil #'custom-magic-reset widget)
+      (run-with-idle-timer 0.0 nil #'custom-magic-reset widget (current-buffer))
        (apply 'widget-default-notify widget args))))
  
  (defun custom-redraw (widget)





^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#40788: 28.0.50; Error running timer ‘custom-magic-reset’
  2020-04-24 15:56     ` David Ponce
@ 2020-07-21  8:39       ` Robert Pluim
  2020-07-21 14:20         ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Robert Pluim @ 2020-07-21  8:39 UTC (permalink / raw)
  To: David Ponce; +Cc: 40788

>>>>> On Fri, 24 Apr 2020 17:56:42 +0200, David Ponce <da_vid@orange.fr> said:

    David> On 24/04/2020 13:56, Robert Pluim wrote:
    >>>>>>> On Thu, 23 Apr 2020 19:39:26 +0200 (CEST), David PONCE <da_vid@orange.fr> said:
    David> Hello again,
    David> Below is a possible patch that seems to have fixed the issue for me.
    David> But I am not sure the approach is correct
    >> Rather than defining a new function, you can add an argument to the
    >> existing one. Something like (untested)

    David> Hi Robert,

    David> Sure, your patch is better :-)
    David> I tested it, and I confirm it fixes the issue :-)
    David> I also tested the below variant, because it seems to me that it is not
    David> necessary to set the buffer when magic is nil, as there is nothing to do.

    David> Please feel free to apply which version looks better to you.
    David> Thanks!

Thanks for testing. Eli, would this be OK to go into emacs-27 ? The
bug causes unintended changes to buffers unrelated to customize.

    David> diff --git a/home/dponce/installs/emacs/lisp/cus-edit.el b/cus-edit.el
    David> index d3d17fd..490d905 100644
    David> --- a/home/dponce/installs/emacs/lisp/cus-edit.el
    David> +++ b/cus-edit.el
    David> @@ -2102,11 +2102,12 @@ and `face'."
    David>  	(insert " "))
    David>        (widget-put widget :children children))))
    David>  -(defun custom-magic-reset (widget)
    David> +(defun custom-magic-reset (widget &optional buffer)
    David>    "Redraw the :custom-magic property of WIDGET."
    David>    (let ((magic (widget-get widget :custom-magic)))
    David>      (when magic
    David> -      (widget-value-set magic (widget-value magic)))))
    David> +      (with-current-buffer (or buffer (current-buffer))
    David> +        (widget-value-set magic (widget-value magic))))))
    David>    ;;; The `custom' Widget.
    David>  @@ -2217,7 +2218,7 @@ and `face'."
    David>        ;; commands like `M-u' (that work on a region in the buffer)
    David>        ;; will upcase the wrong part of the buffer, since more text has
    David>        ;; been inserted before point.
    David> -      (run-with-idle-timer 0.0 nil #'custom-magic-reset widget)
    David> +      (run-with-idle-timer 0.0 nil #'custom-magic-reset widget (current-buffer))
    David>        (apply 'widget-default-notify widget args))))
    David>    (defun custom-redraw (widget)







^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#40788: 28.0.50; Error running timer ‘custom-magic-reset’
  2020-07-21  8:39       ` Robert Pluim
@ 2020-07-21 14:20         ` Eli Zaretskii
  2020-07-21 14:39           ` Robert Pluim
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2020-07-21 14:20 UTC (permalink / raw)
  To: Robert Pluim; +Cc: da_vid, 40788

> From: Robert Pluim <rpluim@gmail.com>
> Date: Tue, 21 Jul 2020 10:39:26 +0200
> Cc: 40788@debbugs.gnu.org
> 
>     David> Please feel free to apply which version looks better to you.
>     David> Thanks!
> 
> Thanks for testing. Eli, would this be OK to go into emacs-27 ? The
> bug causes unintended changes to buffers unrelated to customize.

Yes, OK.

Thanks.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#40788: 28.0.50; Error running timer ‘custom-magic-reset’
  2020-07-21 14:20         ` Eli Zaretskii
@ 2020-07-21 14:39           ` Robert Pluim
  0 siblings, 0 replies; 7+ messages in thread
From: Robert Pluim @ 2020-07-21 14:39 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: da_vid, 40788

>>>>> On Tue, 21 Jul 2020 17:20:11 +0300, Eli Zaretskii <eliz@gnu.org> said:

    >> From: Robert Pluim <rpluim@gmail.com>
    >> Date: Tue, 21 Jul 2020 10:39:26 +0200
    >> Cc: 40788@debbugs.gnu.org
    >> 
    David> Please feel free to apply which version looks better to you.
    David> Thanks!
    >> 
    >> Thanks for testing. Eli, would this be OK to go into emacs-27 ? The
    >> bug causes unintended changes to buffers unrelated to customize.

    Eli> Yes, OK.

Done as 4db3235fd8

Closing.

Thanks

Robert








^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-07-21 14:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-23  5:10 bug#40788: 28.0.50; Error running timer ‘custom-magic-reset’ David Ponce
2020-04-23 17:39 ` David PONCE
2020-04-24 11:56   ` Robert Pluim
2020-04-24 15:56     ` David Ponce
2020-07-21  8:39       ` Robert Pluim
2020-07-21 14:20         ` Eli Zaretskii
2020-07-21 14:39           ` Robert Pluim

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.