emacs-devel
[Top][All Lists]
Advanced

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

Re: [elpa] main 2ec80977e1: * elpa-packages (dired-preview): New package


From: Philip Kaludercic
Subject: Re: [elpa] main 2ec80977e1: * elpa-packages (dired-preview): New package
Date: Tue, 11 Jul 2023 16:58:29 +0000

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>>> I saw 'rx' a couple of times.  I find it harder to use than the strings.
>>> Though this is not a strong argument against it, I know.
>>
>> In this case, it would be
>>
>> --8<---------------cut here---------------start------------->8---
>> (rx "." (or "mkv" "webm" "mp4" "mp3" "ogg" "m4a"
>>          "gz" "zst" "tar" "xz" "rar" "zip"
>>          "iso" "epub" "pdf"))
>> --8<---------------cut here---------------end--------------->8---
>>
>> which seems fine to me?  Fewer escape-sequences.
>>
>>>>            "\\(mkv\\|webm\\|mp4\\|mp3\\|ogg\\|m4a"
>>>>            "\\|gz\\|zst\\|tar\\|xz\\|rar\\|zip"
>>>>            "\\|iso\\|epub\\|pdf\\)")
>>>>    "Regular expression of file type extensions to not preview."
>>>> -  :group 'dired-preview
>>>>    :type 'string)
>
> BTW, you can most of the benefit here by using `regexp-opt` instead:
>
>     (concat "\\."
>             (regexp-opt "mkv" "webm" "mp4" "mp3" "ogg" "m4a"
>                         "gz" "zst" "tar" "xz" "rar" "zip"
>                         "iso" "epub" "pdf"))

Of course, modulo

--8<---------------cut here---------------start------------->8---
Debugger entered--Lisp error: (wrong-number-of-arguments (1 . 2) 15)
  regexp-opt("mkv" "webm" "mp4" "mp3" "ogg" "m4a" "gz" "zst" "tar" "xz" "rar" 
"zip" "iso" "epub" "pdf")
  (concat "\\." (regexp-opt "mkv" "webm" "mp4" "mp3" "ogg" "m4a" "gz" "zst" 
"tar" "xz" "rar" "zip" "iso" "epub" "pdf"))
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  command-execute(eval-last-sexp)
--8<---------------cut here---------------end--------------->8---

Obviously, one would just have to wrap the arguments in the list but
that together with the separate concat makes it less comfortable than
`rx' to me.  But worth mentioning!



reply via email to

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