emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Bastien <bzg@altern.org>
To: Achim Gratz <Stromeko@Nexgo.DE>
Cc: emacs-orgmode@gnu.org
Subject: Re: :EXPORT_FILE_NAME: in new exporter possible?
Date: Mon, 25 Mar 2013 16:54:47 +0100	[thread overview]
Message-ID: <87wqsvmq48.fsf@bzg.ath.cx> (raw)
In-Reply-To: <kippa6$q34$1@ger.gmane.org> (Achim Gratz's message of "Mon, 25 Mar 2013 16:09:23 +0100")

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

Achim Gratz <Stromeko@Nexgo.DE> writes:

> As I said, I don't even know why Gnus decides it should treat this mail as
> an Org file.  From the sources of Gnus, it appears that it should only do
> this if the MIME type was text/x-org.  Rainers mail didn't have this MIME
> type nor was it a multipart MIME mail that had such a part, yet Gnus
> triggered the buffer with "Org" as the major mode, which seems to indicate
> that the MIME type must somehow have been inferred.  I can prevent that
> using orgstruct-mode instead, but as I proposed already there should be a
> "safe" variant of org-mode (a derived mode perhaps) that doesn't load any
> axtra files and doesn't run any source blocks.  Of course, Gnus then should
> use this mode (it is only meant for proper fontification anyway, which I
> suppose must be possible without firing a whole major mode).

What about this patch?

The change in Gnus is then trivial (see other patch).


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: org-read-setup-file-conditionnally.patch --]
[-- Type: text/x-patch, Size: 3396 bytes --]

diff --git a/lisp/org.el b/lisp/org.el
index 04a0f20..88f9ea0 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -1266,6 +1266,26 @@ smart            Make point visible, and do insertion/deletion if it is
 	  (const :tag "Show invisible part and do the edit" show)
 	  (const :tag "Be smart and do the right thing" smart)))
 
+(defcustom org-read-setup-file 'ask
+  "Should Org read setup files?
+A setup file can be specified with the #+SETUPFILE keyword.
+When reading someone else Org files, Emacs will try to read
+arbitrary read an arbitrary file on your computer.
+
+The default is to ask users before reading a file.
+Setting this option to 'if-interactive will read the setup
+file when `org-mode' has been called interactively.
+Setting this option to t will always read setup files."
+  :group 'org-startup
+  :version "24.4"
+  :package-version '(Org . "8.0")
+  :type '(choice
+	  (const :tag "Never read a setup file" nil)
+	  (const :tag "Ask before trying to read a setup file" 'ask)
+	  (const :tag "Read a setup file when `org-mode' is called interactively"
+		 'if-interactive)
+	  (const :tag "Always try to read a setup file" t)))
+
 (defcustom org-yank-folded-subtrees t
   "Non-nil means when yanking subtrees, fold them.
 If the kill is a single subtree, or a sequence of subtrees, i.e. if
@@ -4828,8 +4848,10 @@ Support for group tags is controlled by the option
 		     (assoc (car e) org-tag-alist))
 		(push e org-tag-alist))))))))
 
-(defun org-set-regexps-and-options ()
-  "Precompute regular expressions used in the current buffer."
+(defun org-set-regexps-and-options (&optional interactivep)
+  "Precompute regular expressions used in the current buffer.
+If INTERACTIVEP is non-nil, `org-set-regexps-and-options' has
+been called from an interactive call to `org-mode'."
   (when (derived-mode-p 'org-mode)
     (org-set-local 'org-todo-kwd-alist nil)
     (org-set-local 'org-todo-key-alist nil)
@@ -4912,7 +4934,11 @@ Support for group tags is controlled by the option
 		  (setq scripts (read (match-string 2 value)))))
 	     ((and (equal key "SETUPFILE")
 		   ;; Prevent checking in Gnus messages
-		   (not buffer-read-only))
+		   (or (and (eq org-read-setup-file 'if-interactive) interactivep)
+		       (and (eq org-read-setup-file 'ask)
+			    (yes-or-no-p (format "Read setup file %s? " value)))
+		       (eq org-read-setup-file t)
+		       (progn (message "Setup file %s not read" value) (sit-for 2))))
 	      (setq setup-contents (org-file-contents
 				    (expand-file-name
 				     (org-remove-double-quotes value))
@@ -5272,7 +5298,7 @@ The following commands are available:
 	       (if (stringp org-ellipsis) org-ellipsis "..."))))
     (setq buffer-display-table org-display-table))
   (org-set-regexps-and-options-for-tags)
-  (org-set-regexps-and-options)
+  (org-set-regexps-and-options (org-called-interactively-p 'any))
   (when (and org-tag-faces (not org-tags-special-faces-re))
     ;; tag faces set outside customize.... force initialization.
     (org-set-tag-faces 'org-tag-faces org-tag-faces))
@@ -20152,7 +20178,7 @@ This command does many different things, depending on context:
   "Restart Org-mode, to scan again for special lines.
 Also updates the keyword regular expressions."
   (interactive)
-  (org-mode)
+  (call-interactively 'org-mode)
   (message "Org-mode restarted"))
 
 (defun org-kill-note-or-show-branches ()

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: mm-view.el.patch --]
[-- Type: text/x-patch, Size: 524 bytes --]

diff --git a/lisp/mm-view.el b/lisp/mm-view.el
index ac6170a..690402c 100644
--- a/lisp/mm-view.el
+++ b/lisp/mm-view.el
@@ -647,7 +647,9 @@ If MODE is not set, try to find mode automatically."
 
 (defun mm-display-org-inline (handle)
   "Show an Org mode text from HANDLE inline."
-  (mm-display-inline-fontify handle 'org-mode))
+  (mm-display-inline-fontify
+   handle
+   (lambda () (let (org-read-setup-file) (org-mode)))))
 
 (defun mm-display-shell-script-inline (handle)
   "Show a shell script from HANDLE inline."

[-- Attachment #4: Type: text/plain, Size: 14 bytes --]


-- 
 Bastien

  reply	other threads:[~2013-03-25 15:54 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-21 13:06 :EXPORT_FILE_NAME: in new exporter possible? Rainer Stengele
2013-03-21 15:34 ` Eric Abrahamsen
2013-03-21 23:15   ` Andreas Leha
2013-03-21 23:23     ` Bastien
2013-03-25  5:45       ` Bastien
2013-03-25 10:09         ` Achim Gratz
2013-03-25 14:57           ` Bastien
2013-03-25 15:09             ` Achim Gratz
2013-03-25 15:54               ` Bastien [this message]
2013-03-25 16:13                 ` Achim Gratz
2013-03-25 16:57                   ` Bastien
2013-03-25 17:00                     ` Bastien
2013-03-25 17:39                     ` Achim Gratz
2013-03-25 18:52                       ` Bastien
2013-03-22  0:20 ` John Hendy
2013-03-22  7:41   ` Rainer Stengele
2013-03-22 14:51     ` John Hendy
2013-03-22 16:04       ` Rainer Stengele
2013-03-22 18:20         ` Nicolas Goaziou
2013-03-22 14:58     ` Nicolas Goaziou
2013-03-22 15:21       ` Rainer Stengele

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wqsvmq48.fsf@bzg.ath.cx \
    --to=bzg@altern.org \
    --cc=Stromeko@Nexgo.DE \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).