Achim Gratz <[email protected]> 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).
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 ()
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."
--
Bastien