unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* elpa-admin patch for current ImageMagick
@ 2022-11-04 13:00 Stephen Leake
  2022-11-04 15:17 ` Stefan Monnier
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen Leake @ 2022-11-04 13:00 UTC (permalink / raw)
  To: emacs-devel

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

In testing my elpa packages, I run 'make build/<pkg>', which is failing
due to the ImageMagick call in elpaa--string-width, because my version
of ImageMagick requires using the "magick" driver. The attached patch
fixes that.

github also ran into this: https://github.com/aheckmann/gm/issues/684

One possibility is to choose a different option during ImageMagick
install, to install the old executables (including "convert"), but
patching the lisp seems more reliable, and more future-proof.

Ok to commit?

-- 
-- Stephe

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: elpa-admin.diff --]
[-- Type: text/x-patch, Size: 2325 bytes --]

diff --git a/elpa-admin.el b/elpa-admin.el
index f4a33a2e27..cdbfaa61b3 100644
--- a/elpa-admin.el
+++ b/elpa-admin.el
@@ -872,22 +872,25 @@ SPECS is the list of package specifications."
 (defun elpaa--string-width (str)
   "Determine string width in pixels of STR."
   (with-temp-buffer
-    ;; Current (2021) ImageMagick recommends using the "magick"
-    ;; driver, rather than "convert" directly, but Debian doesn't
-    ;; provide it yet.
-    (elpaa--call (current-buffer)
-                 "convert" "-debug" "annotate" "xc:" "-font" "DejaVu-Sans"
-                 "-pointsize" "110" "-annotate" "0" str "null:")
-    (goto-char (point-min))
-    (if (not (re-search-forward "Metrics:.*?width: \\([0-9]+\\)"))
-        (error "Could not determine string width")
-      (let ((width (string-to-number (match-string 1))))
-        ;; This test aims to catch the case where the font is missing,
-        ;; but it seems it only works in some cases :-(
-        (if (and (> (string-width str) 0) (not (> width 0)))
-            (progn (message "convert:\n%s" (buffer-string))
-                   (error "Could not determine string width"))
-          width)))))
+    ;; ImageMagick 7.1.0 or later requires using the "magick" driver,
+    ;; rather than "convert" directly, but Debian doesn't provide it
+    ;; yet (2021).
+    (let ((args
+           (append (list (current-buffer))
+                   (if (executable-find "magick") '("magick" "convert") '("convert"))
+                   (list "-debug" "annotate" "xc:" "-font" "DejaVu-Sans"
+                         "-pointsize" "110" "-annotate" "0" str "null:"))))
+      (apply #'elpaa--call args)
+      (goto-char (point-min))
+      (if (not (re-search-forward "Metrics:.*?width: \\([0-9]+\\)"))
+          (error "Could not determine string width")
+        (let ((width (string-to-number (match-string 1))))
+          ;; This test aims to catch the case where the font is missing,
+          ;; but it seems it only works in some cases :-(
+          (if (and (> (string-width str) 0) (not (> width 0)))
+              (progn (message "convert:\n%s" (buffer-string))
+                     (error "Could not determine string width"))
+            width))))))
 
 (defun elpaa--make-badge (file left right)
   "Make badge svg FILE with LEFT and RIGHT string."

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

* Re: elpa-admin patch for current ImageMagick
  2022-11-04 13:00 elpa-admin patch for current ImageMagick Stephen Leake
@ 2022-11-04 15:17 ` Stefan Monnier
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2022-11-04 15:17 UTC (permalink / raw)
  To: Stephen Leake; +Cc: emacs-devel

> Ok to commit?

Please do,


        Stefan




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

end of thread, other threads:[~2022-11-04 15:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-04 13:00 elpa-admin patch for current ImageMagick Stephen Leake
2022-11-04 15:17 ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).