emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] avoid loading major modes when exporting to file
@ 2021-03-31 15:25 Timothy
  2021-05-01 16:52 ` Bastien
  0 siblings, 1 reply; 4+ messages in thread
From: Timothy @ 2021-03-31 15:25 UTC (permalink / raw)
  To: org-mode-email

[-- Attachment #1: Type: text/plain, Size: 201 bytes --]


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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ox-don-t-load-a-major-mode-when-exporting-to-file.patch --]
[-- Type: text/x-patch, Size: 1406 bytes --]

From eb9d7c038dbb9e7a4b89edf61db83a31dda27170 Mon Sep 17 00:00:00 2001
From: TEC <tec@tecosaur.com>
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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] avoid loading major modes when exporting to file
  2021-03-31 15:25 [PATCH] avoid loading major modes when exporting to file Timothy
@ 2021-05-01 16:52 ` Bastien
  2021-05-01 17:26   ` Timothy
  0 siblings, 1 reply; 4+ messages in thread
From: Bastien @ 2021-05-01 16:52 UTC (permalink / raw)
  To: Timothy; +Cc: org-mode-email

Hi Timothy,

Timothy <tecosaur@gmail.com> 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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] avoid loading major modes when exporting to file
  2021-05-01 16:52 ` Bastien
@ 2021-05-01 17:26   ` Timothy
  2021-05-03 17:25     ` Bastien
  0 siblings, 1 reply; 4+ messages in thread
From: Timothy @ 2021-05-01 17:26 UTC (permalink / raw)
  To: Bastien; +Cc: org-mode-email


Bastien <bzg@gnu.org> 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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] avoid loading major modes when exporting to file
  2021-05-01 17:26   ` Timothy
@ 2021-05-03 17:25     ` Bastien
  0 siblings, 0 replies; 4+ messages in thread
From: Bastien @ 2021-05-03 17:25 UTC (permalink / raw)
  To: Timothy; +Cc: org-mode-email

Hi Timothy,

Timothy <tecosaur@gmail.com> 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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-05-03 17:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-31 15:25 [PATCH] avoid loading major modes when exporting to file Timothy
2021-05-01 16:52 ` Bastien
2021-05-01 17:26   ` Timothy
2021-05-03 17:25     ` Bastien

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).