[Top][All Lists]

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

Re: selectively disabling HTML rendering?

From: Emanuel Berg
Subject: Re: selectively disabling HTML rendering?
Date: Wed, 08 Apr 2015 02:06:45 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Mike Small <> writes:

> Is there an easy way to selectively disable HTML
> rendering, dependent upon header info? I've come up
> with the following, which does what I want, but
> I don't like its chances across emacs upgrades:

You don't have to worry about that. Upgrades are to
fix things and add new things, they are not supposed
to break existing code which adhere to general good
practices - normal, everyday code that is good tend
to stay that way across upgrades.

It is rather like this: if the upgrade breaks your
code, either it is a bug from their side which you
should report, or you did something really unorthodox
and you should identify what and analyze why you made
it that way, and how you can make it better.

> (defun mms-gnus-mime-display-alternative (handle)
>   "My own function for displaying mime multipart/alternative articles in Gnus
> Use by placing in gnus-mime-multipart-functions.
> Beware when upgrading. Some of this is copied out of and makes assumptions 
> about
> gnus-mime-display-part from version 5.13 of Gnus.  It also bypasses 
> gnus-mime-display-multipart-as-mixed and 
> gnus-mime-display-multipart-alternative-as-mixed."
>   (let ((id (1+ (length gnus-article-mime-handle-alist)))
>       (mm-discouraged-alternatives
>        (if (string= (get-text-property 0 'from (car handle))
>                     "")
>            (list "text/html")
>          mm-discouraged-alternatives)))
>     (push (cons id handle) gnus-article-mime-handle-alist)
>     (gnus-mime-display-alternative (cdr handle) nil
> nil id)))

OK, you don't need to say it is your own function,
those are very common in the Emacs world. Also, you
should mention all arguments - in uppercase, in the
order they appear - in the docstring: i.e, you should
say HANDLE is used to... Also, "Lisp symbols" (all
function and variable names) should appear `quoted'.
If you do this (both issues), and then use help to
bring up the on-line help for this function, you'll
understand why.

You can use this function to verify. Invoke (and
ignore all things that relate to packages) and do as
it says, then invoke again to confirm:

    (defun check-pack-style ()
      (checkdoc-current-buffer t) ; TAKE-NOTES
      (message "Style check done.") )

The docstring should mention what the function does
rather than get into details what it might break etc.
In particular the hard-coded ""
should be mentioned.

The idea as such is close to over-engineering - how
about to just open the message as "not HTML", then
have a key assigned to HTML-ize it?

underground experts united

reply via email to

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