[Top][All Lists]

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

Re: org-src.el begin_src/end_src fontification may have been broken rece

From: Ted Zlatanov
Subject: Re: org-src.el begin_src/end_src fontification may have been broken recently
Date: Mon, 13 Jun 2011 10:36:28 -0500
User-agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.50 (gnu/linux)

On Mon, 13 Jun 2011 10:05:44 +0200 Štěpán Němec <address@hidden> wrote: 

ŠN> Ted Zlatanov <address@hidden> writes:
>> I'd say a mistake shouldn't break Gnus' article display :)  Can that be
>> fixed in org.el or in Gnus?  It seems to me org.el is the right place.

ŠN> What is there to fix in org.el? In Org, when you use some bogus
ŠN> delimiter like #+begin_src:, the block simply won't work. If Gnus
ŠN> article display is broken, it should obviously be fixed in Gnus, no?

It throws an error during fontification, which is much harder to find
and debug than a normal error.  IMHO it should warn but not error out.

Also as I mentioned a valid mode that's not installed,
e.g. `haskell-mode', will also throw the error.  So it's not just a
matter of syntax.

It seems to me that org.el should be the one to avoid throwing an
error.  I could be wrong; if so we can use Eric's fix below.

ŠN> BTW, if you can't remember the correct delimiters, why don't you make
ŠN> yourself a template/skeleton or something? (In Org, typing `<s' and
ŠN> pressing TAB will give you that, see (info "(org)Easy Templates").)

Oh, I have ;)  The problem happens when the syntax is incorrect.  Here's
what I use, which picks up the mode automatically.

#+begin_src lisp
(defun tzz-copy-mode (mode)
   ((member mode '("emacs-lisp"))
   (t "text")))

(defun tzz-copy-region-with-mode-property (beg end)
  (interactive "r")
  (let ((text (buffer-substring beg end))
        (mode (symbol-name major-mode)))
      (insert text)
      (goto-char (point-min))
      (insert "#+begin_src"
              (if (string-match "\\(.+\\)-mode" mode)
                  (concat " " (tzz-copy-mode (match-string 1 mode)))
      (goto-char (point-max))
      (insert "\n"
      (copy-region-as-kill (point-min) (point-max)))))

On Mon, 13 Jun 2011 07:38:31 -0700 Eric Schulte <address@hidden> wrote: 

ES> I have the following altered function definition in my personal
ES> configuration which fixes (well, papers over) the problem.
#+begin_src emacs-lisp
  (defun mm-display-org-inline (handle)
    "Show an Org mode text from HANDLE inline."
    (condition-case nil
        (mm-display-inline-fontify handle 'org-mode)
      (error (mm-insert-part handle))))

ES> It is not clear to me why Org-mode fontification would only throw errors
ES> when called from `mm-display-inline-fontify'.

I'm OK with your fix but also wonder if org.el should be throwing errors
during fontification.  Julien, since you added this to Gnus, can you
please decide on the best place to fix it?


reply via email to

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