all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Manuel Giraud via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 61734@debbugs.gnu.org
Subject: bug#61734: 30.0.50; [PATCH] Defaults to zero for image-dired--number-of-thumbnails
Date: Thu, 23 Feb 2023 21:17:55 +0100	[thread overview]
Message-ID: <87zg94gmq4.fsf@ledu-giraud.fr> (raw)
In-Reply-To: <878rgoid4e.fsf@ledu-giraud.fr> (Manuel Giraud's message of "Thu,  23 Feb 2023 17:02:25 +0100")

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

Manuel Giraud <manuel@ledu-giraud.fr> writes:

> Hi,
>
> Here is a patch to avoid "wrong type error" upon comparision to zero of
> image-dired--number-of-thumbnails.  How to reproduce:
>
>     - Do not have an existing *image-dired* buffer
>     - Hit 'C-t a' (image-dired-display-thumbs-append) on an image file
>       from Dired

Maybe this new version can go in too.  It updates the thumbnails counter
when removing a thumbnail.  What is not updated though is the number of
the image which is assign with a text-property at insertion...  So it is
not complete but an improvement nevertheless.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Defaults-to-zero-for-image-dired-number-of-thumbnail.patch --]
[-- Type: text/x-patch, Size: 1450 bytes --]

From 04a3bc1cf9b3c2685c3edba1e0f792d8f28de6b2 Mon Sep 17 00:00:00 2001
From: Manuel Giraud <manuel@ledu-giraud.fr>
Date: Thu, 23 Feb 2023 16:42:48 +0100
Subject: [PATCH] Defaults to zero for image-dired--number-of-thumbnails
 (bug#61734)

* lisp/image/image-dired.el (image-dired--number-of-thumbnails):
Defaults to zero to avoid wrong type error down the line.
(image-dired-delete-char): Update thumbnails counter upon deletion.
---
 lisp/image/image-dired.el | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lisp/image/image-dired.el b/lisp/image/image-dired.el
index 8e2a75a418f..2c2968b1b49 100644
--- a/lisp/image/image-dired.el
+++ b/lisp/image/image-dired.el
@@ -546,7 +546,7 @@ image-dired--line-up-with-method
         (t
          (image-dired-line-up-dynamic))))
 
-(defvar-local image-dired--number-of-thumbnails nil)
+(defvar-local image-dired--number-of-thumbnails 0)
 
 ;;;###autoload
 (defun image-dired-display-thumbs (&optional arg append do-not-pop)
@@ -1127,9 +1127,11 @@ image-dired-delete-char
   "Remove current thumbnail from thumbnail buffer and line up."
   (interactive nil image-dired-thumbnail-mode)
   (let ((inhibit-read-only t))
-    (delete-char 1))
+    (delete-char 1)
+    (cl-decf image-dired--number-of-thumbnails))
   (let ((pos (point)))
     (image-dired--line-up-with-method)
+    (image-dired--update-header-line)
     (goto-char pos)))
 
 (defun image-dired-line-up ()
-- 
2.39.1


[-- Attachment #3: Type: text/plain, Size: 18 bytes --]

-- 
Manuel Giraud

  reply	other threads:[~2023-02-23 20:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-23 16:02 bug#61734: 30.0.50; [PATCH] Defaults to zero for image-dired--number-of-thumbnails Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-23 20:17 ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-02-24  9:35   ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-27 13:20     ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-27 13:59       ` Eli Zaretskii
2023-02-27 16:20         ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-28 13:26           ` Eli Zaretskii
2023-02-28 13:31             ` Manuel Giraud via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-28 14:23               ` Eli Zaretskii

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=87zg94gmq4.fsf@ledu-giraud.fr \
    --to=bug-gnu-emacs@gnu.org \
    --cc=61734@debbugs.gnu.org \
    --cc=manuel@ledu-giraud.fr \
    /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.