emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Image-conversion shims


From: Lars Ingebrigtsen
Subject: Re: Image-conversion shims
Date: Sun, 29 Sep 2019 13:44:41 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Eli Zaretskii <address@hidden> writes:

>> (setq convert-images-externally t)
>
> That variable's name should start with "image-", IMO, and the same for
> the (confusingly similar) convert-external-images.

Hm...  I moved that variable from image-converter.el to image.el and
slightly renamed it, but apparently forgot to remove it.  Now fixed.

I tried to come up with several variations for the variable name, but
they all sounded even more awkward.

Uhm...  what about...  image-use-external-converter?

> It should also be documented in the user manual (I'd simply move what
> you wrote for the ELisp manual to the user manual, since I see no
> reason to document this in the former).

Makes sense; now done.

> When looking for an installed converter, shouldn't we put ImageMagick
> last?

Yup.

> I also think that using call-process for invoking the converter makes
> the feature less flexible and more "tricky" to maintain.  Already you
> needed to jump through some hoops to support "gm convert".  I think
> using shell-command would have made all this much simpler and more
> straightforward.

It's true that it's simpler, but I've been bitten by corner cases in
escape handling of file names before (and we're dealing with file names
that are under some degree of control by an attacker), so I just think
it's easier to not have to think about those issues at all (i.e., use
call-process).

>> But if that hasn't been computed, then image-mode won't be triggered,
>> and so create-image won't be called.
>
> Maybe we need a new hook?

That would be possible, but would require more work for the user,
possibly.

I was pondering whether something could be done in `set-auto-mode'.  It
already consults a wide number of variables to determine the mode.
Could we add yet another one that's more flexible?

That is, it would be an alist on the form (variable . action) and would
be consulted last in that function as the final fallback.  Like:

(defvar auto-mode-dependent-action-alist
  '((convert-images-externally . image-image-converter-file-alist)))

and the code would be

(dolist (elem auto-mode-dependent-action-alist)
  (when (bound-and-true-p (car elem))
    (let ((alist (cdr elem)))
      ;; Do the same thing as with auto-mode-alist
      ))

It would provide a mechanism for users to switch on/off a group of mode
alist entries with a single setq...

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]