[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: always text/plain on ASCII text
In [emacs-w3m:13081]
On Thu, 24 Jan 2019 06:08:05 -0500, Boruch Baum wrote:
> Katsumi-san,
> I made an attempt to create a defcustom for the variable. The following
> seemed good but fails to match. Any ideas?
> (defcustom my-test nil
First of all, please don't use defcutom for w3m-content-type-alist
because its default value inherits the value of mailcap-mime-data
that inherits the contents of user's ~/.mailcap file. So, the
default value will vary and the use of defcustom is unsuitable with
it (I've made mailcap-mime-data defcustom'd in Emacs mistakenly
once before but withdrawn).
Anyway, there are three reasons your custom type mismatching.
1. emacs-w3m bug
(defvar w3m-content-type-alist
[...]
("application/x-bzip2" "\\.bz2\\'" nil nil nil)
("application/x-gzip" "\\.gz\\'" nil nil nil)))
Maybe those `nil' nil nil' should be fixed to `nil nil'.
2. Too much parens
(group :tag "External command and parameters\n" :indent 16
(string :format "Command: %v")
(repeat :tag "Command parameters"
(string :format "Command parameter: %v\n")))
This matches ("command" ("param"..)), not ("command" "param"..).
3. No `nil' choice in the 2nd, 3rd, and 4th items
Here is a version that works. Try:
(setq my-test
(assoc-delete-all "\\`application/x-[bg]zip2?\\'"
(copy-sequence w3m-content-type-alist)
(lambda (a b) (string-match b a))))
and M-x customize-option RET my-test RET.
(defcustom my-test nil
"doc string"
:group 'w3m
:type
'(repeat
(group
:indent 12
(string :tag "Mimetype")
(radio (const nil) (string :tag "Regexp of suffix"))
(choice :tag "Method" :indent 16
(const nil)
(function :tag "Lisp function")
(cons :tag "External command and parameters\n" :indent 16
(string :format "Command: %v")
(repeat :tag "Command parameters"
(radio :format "\n%v"
(const file) (const url) string))))
(choice :tag "Override"
(const nil)
(function :tag "Lisp function" :format "Lisp function: %v\n")
(string :tag "Content type" :format "Content type: %v\n\n")))))