Re: [PATCH] avoid loading major modes when exporting to file

2021-05-03 Thread Bastien
Hi Timothy,

Timothy  writes:

> I haven't responded to this concern, because I haven't been able to
> conceive of a single situation where loading the normal-mode for the
> exported file could be desirable.

Well, I could not come up with it either.

Applied in master with commit ec6d1df9b, together with tiny changes in
the commit message.

Thanks!

-- 
 Bastien



Re: [PATCH] avoid loading major modes when exporting to file

2021-05-01 Thread Timothy


Bastien  writes:

> This even be "auto-mode-alist" instead of "(auto-mode-alist nil)".

Ah, it can indeed.

> I'm still unsure the patch is correct: what if people *need* major
> mode initialization before any contents is exported to a file?

I haven't responded to this concern, because I haven't been able to
conceive of a single situation where loading the normal-mode for the
exported file could be desirable.

>> I think the commit description is pretty thorough, so give that a look.
>> TLDR; it makes `org-export-to-file' behave a bit more nicely.
>
> I find it useful to have a small description of the change and why it
> is needed in the body of the email, when a patch is attached.

I think I may have been become overly used to how convenient mu4e is for
showing patches inline .

For the sake of anyone just looking at the Email body, here's what I
considered to be an informative commit message, subtly reworded:

Currently, when `org-export-to-file' is called it activated the major
mode for that file type based on `auto-mode-alist'. This can be mildly
annoying in various ways as loading the major mode:
1. makes the export take longer
2. can produce unwanted "noise" while initialising, namely warnings and
   errors related to the mode itself
3. can produce spurious files like an .auctex-auto folder

By locally binding `auctex-auto' to nil all of these undesirable
behaviours can be avoided.

--
Timothy



Re: [PATCH] avoid loading major modes when exporting to file

2021-05-01 Thread Bastien
Hi Timothy,

Timothy  writes:

> Another little patch, this time a one-liner.

This even be "auto-mode-alist" instead of "(auto-mode-alist nil)".

I'm still unsure the patch is correct: what if people *need* major
mode initialization before any contents is exported to a file?

> I think the commit description is pretty thorough, so give that a look.
> TLDR; it makes `org-export-to-file' behave a bit more nicely.

I find it useful to have a small description of the change and why it
is needed in the body of the email, when a patch is attached.

Otherwise, you can configure git send-mail to send a patch to the list
as an email and then we can discuss the explanation part that you can
add after the change log part.

Thanks,

-- 
 Bastien



[PATCH] avoid loading major modes when exporting to file

2021-03-31 Thread Timothy

Hello,

Another little patch, this time a one-liner.
I think the commit description is pretty thorough, so give that a look.
TLDR; it makes `org-export-to-file' behave a bit more nicely.

--
Timothy

>From eb9d7c038dbb9e7a4b89edf61db83a31dda27170 Mon Sep 17 00:00:00 2001
From: TEC 
Date: Wed, 31 Mar 2021 23:16:58 +0800
Subject: [PATCH] ox: don't load a major-mode when exporting to file

* lisp/ox.el (org-export-to-file): Prior to this, when
`org-export-to-file' was called it activated the major mode for that
file type based on `auto-mode-alist'.  This can be mildly annoying in
various ways as loading the major mode (1) makes the export take
longer, (2) can produce unwanted "noise" while initialising, namely
warnings and errors related to the mode itself, (3) can produce spurious
files like an .auctex-auto folder.  By locally binding `auctex-auto' to
nil all of these undesirable behaviours can be avoided.
---
 lisp/ox.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/ox.el b/lisp/ox.el
index f705bc83a..96d2866dd 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -6388,7 +6388,8 @@   (defun org-latex-export-to-latex
   (declare (indent 2))
   (if (not (file-writable-p file)) (error "Output file not writable")
 (let ((ext-plist (org-combine-plists `(:output-file ,file) ext-plist))
-	  (encoding (or org-export-coding-system buffer-file-coding-system)))
+	  (encoding (or org-export-coding-system buffer-file-coding-system))
+  (auto-mode-alist nil))
   (if async
   (org-export-async-start
 	  `(lambda (file)
-- 
2.30.1