Hi,
When open a png file and toggle display from image to text by C-c C-c, the `image-toggle-display-text` will be called twice in function `image-toggle-display-text`.
The first call is from major mode change hook, in follow line will cause `change-major-mode-hook` be run and it’s `image-toggle-display-text` for image-mode.
image-mode.el:730 (major-mode-restore '(image-mode image-mode-as-text))
The second call is from the direct call at
image-mode.el:736 (image-toggle-display-text)
You can debug-on-entry `image-toggle-display-text` then switch image to text in image-mode by C-c C-c to observe the issue.
And the patch is try to reduce calling for `image-toggle-display-text`.
Best Regards
Lin Sun