Subject: bug#58774: 29.0.50; [WISH]: Let us make EWW browse WWW Org files correctly

From: Jean Louis <[email-masked]>
Date: Wed, 26 Oct 2022 16:42:06 +0300

* Rudolf Adamkovič via "Bug reports for GNU Emacs, the Swiss army knife of text editors <[email-masked]> [2022-10-26 16:10]:
> So, I evaluated
> 
>   (add-to-list 'mailcap-mime-data
>                (list "org"
>                  (cons 'viewer 'org-mode)
>                  (cons 'type "text/x-org")))
> 
> but it did not work.  What the hack!
> 
> To satisfy my curiosity, I decided to look at the source code.

Thank you for understanding!

> TL;DR EWW hard-codes a couple of MIME types.
> 
> You could improve the situation in various ways.
> 
> For example, you could
> 
> (1) patch EWW to expose the eww-content-type for the user to use, or
> (2) patch EWW to look up MIME for not just the PDF.

Thank you for understanding. You have given me pointers what to do, my
personal case is closed, though I am not the one who knows how to
properly patch it, and I do not see yet that there is consensus, as
few people did not understand about user preferences and rather speak
how EWW should even take care of security issues for user instead of
giving user freedom.

I have done following to make it work personally:

(defvar eww-content-type nil)
(put 'eww-content-type 'permanent-local t)
;;; in eww-render I put:
;;; (setq eww-content-type content-type)

(defun rcd-eww-content-type ()
  (cond ((string-match-p "text/x-org" (car eww-content-type)) (org-mode))
	 (t (eww-mode))))

It is not working best, help me if you know how. I wish normal
eww-mode when it is not org-mode.

(add-hook 'eww-after-render-hook 'rcd-eww-content-type)

And now I can browse Org files from within Emacs.

Video is here:
https://gnu.support/images/gnu-emacs/2022/10/2022-10-26/2022-10-26-16:35:20.ogv

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/