emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/org-transclusion 1a6671c4ff: add:inhibit-read-only: fix


From: ELPA Syncer
Subject: [elpa] externals/org-transclusion 1a6671c4ff: add:inhibit-read-only: fix:Org export errors with read-only
Date: Sat, 25 Dec 2021 05:57:38 -0500 (EST)

branch: externals/org-transclusion
commit 1a6671c4ffb515271296ed3f2526d183caa6c278
Author: Noboru Ota <me@nobiot.com>
Commit: Noboru Ota <me@nobiot.com>

    add:inhibit-read-only: fix:Org export errors with read-only
    
    Some Org exports backends (e.g. texinfo) use org-babel, which does not work 
when
    part of the buffer is read-only andoutputs an error message.
    
    Add `org-transclusion-inhibit-read-only` function and add it locally to
    `org-export-before-processing-hook`. It temporarily inhibits read-only for 
the
    buffer for export.
    
    With this, `manual-gen.el` for make is no longer needed, replaced with an
    Elisp expression instead.
---
 docs/Makefile             |  3 ++-
 docs/manual-gen.el        | 18 ------------------
 docs/org-transclusion.org |  1 -
 org-transclusion.el       | 17 ++++++++++++++++-
 4 files changed, 18 insertions(+), 21 deletions(-)

diff --git a/docs/Makefile b/docs/Makefile
index b12b794ecf..7acd7e8dce 100644
--- a/docs/Makefile
+++ b/docs/Makefile
@@ -13,7 +13,8 @@ run: html install clear
 
 manual:
        @printf "\n\n### Generating manual .texi and .info files \n\n"
-       $(EMACS) --batch -L ../ --file org-transclusion.org -l manual-gen.el
+       $(EMACS) --batch -L ../ --file org-transclusion.org \
+                 --eval="(progn (require 
'org-transclusion)(org-transclusion-add-all)(org-texinfo-export-to-info))"
 
 html:
        @printf "\n\n### Generating manual .html files \n\n"
diff --git a/docs/manual-gen.el b/docs/manual-gen.el
deleted file mode 100644
index 6622bf58f8..0000000000
--- a/docs/manual-gen.el
+++ /dev/null
@@ -1,18 +0,0 @@
-;;; -*- lexical-binding: t; -*-
-
-;; Copyright (C) 2021  Free Software Foundation, Inc.
-
-;;; Commentary:
-
-;; A helper to generate user manual for Org-transclusion
-
-
-(require 'org-transclusion)
-
-;; Need to fix this
-;; Currently it does not work
-(org-transclusion-add-all)
-
-(let ((inhibit-read-only t))
-  (org-texinfo-export-to-info))
-
diff --git a/docs/org-transclusion.org b/docs/org-transclusion.org
index a3e67e32f8..e35347918f 100644
--- a/docs/org-transclusion.org
+++ b/docs/org-transclusion.org
@@ -1,6 +1,5 @@
 #+title: Org-transclusion User Manual
 #+author: Noboru Ota <me@nobiot.com>
-#+modified: 2021-12-24T193446
 #+language: en
 #+export_file_name: org-transclusion.texi
 #+texinfo_dir_category: Emacs
diff --git a/org-transclusion.el b/org-transclusion.el
index ec6a8503e1..4c05513a3b 100644
--- a/org-transclusion.el
+++ b/org-transclusion.el
@@ -17,7 +17,7 @@
 
 ;; Author: Noboru Ota <me@nobiot.com>
 ;; Created: 10 Oct 2020
-;; Last modified: 24 December 2021
+;; Last modified: 25 December 2021
 
 ;; URL: https://github.com/nobiot/org-transclusion
 ;; Keywords: org-mode, transclusion, writing
@@ -325,6 +325,8 @@ and variables."
   (add-hook 'after-save-hook #'org-transclusion-after-save-buffer nil t)
   (add-hook 'kill-buffer-hook #'org-transclusion-before-kill nil t)
   (add-hook 'kill-emacs-hook #'org-transclusion-before-kill nil t)
+  (add-hook 'org-export-before-processing-hook
+            #'org-transclusion-inhibit-read-only nil t) 
   (org-transclusion-yank-excluded-properties-set)
   (org-transclusion-load-extensions-maybe))
 
@@ -337,6 +339,8 @@ This function also removes all the transclusions in the 
current buffer."
   (remove-hook 'after-save-hook #'org-transclusion-after-save-buffer t)
   (remove-hook 'kill-buffer-hook #'org-transclusion-before-kill t)
   (remove-hook 'kill-emacs-hook #'org-transclusion-before-kill t)
+  (remove-hook 'org-export-before-processing-hook
+               #'org-transclusion-inhibit-read-only nil t)
   (org-transclusion-yank-excluded-properties-remove))
 
 ;;;###autoload
@@ -1695,6 +1699,17 @@ When DEMOTE is non-nil, demote."
             (org-transclusion-promote-adjust-after)))
         (goto-char pos)))))
 
+;;-----------------------------------------------------------------------------
+;;;; Functions to support Org-export
+
+(defun org-transclusion-inhibit-read-only (&rest _args)
+  "Set `inhibit-read-only' to t for Org export functions.
+Org export may need the buffer not to contain read-only elements.
+This function is meant to be added to
+`org-export-before-processing-hook' to temporarily inhibit
+read-only."
+  (setq-local inhibit-read-only t))
+
 ;;-----------------------------------------------------------------------------
 ;;;; Functions for extensions
 ;;   It's based on `org-modules'



reply via email to

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