From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: [bug] Fontification of bold and italics Date: Fri, 14 Mar 2014 15:44:53 +0100 Message-ID: <8738iksuu2.fsf@bzg.ath.cx> References: <86fvn6gncq.fsf@somewhere.org> <87pplqozk9.fsf@bzg.ath.cx> <86wqfxul0b.fsf@somewhere.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50574) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WOTMP-0001CD-Jv for emacs-orgmode@gnu.org; Fri, 14 Mar 2014 10:45:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WOTMJ-0000tv-G1 for emacs-orgmode@gnu.org; Fri, 14 Mar 2014 10:45:21 -0400 Received: from plane.gmane.org ([80.91.229.3]:58642) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WOTMJ-0000tI-1h for emacs-orgmode@gnu.org; Fri, 14 Mar 2014 10:45:15 -0400 Received: from public by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WOTMH-00049P-4X for emacs-orgmode@gnu.org; Fri, 14 Mar 2014 15:45:13 +0100 In-Reply-To: <86wqfxul0b.fsf@somewhere.org> (Sebastien Vauban's message of "Fri, 14 Mar 2014 11:34:12 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Sebastien Vauban Cc: public-emacs-orgmode-mXXj517/zsQ@plane.gmane.org --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Hi Sébastien, can you test this patch against maint for a while and report problems? Thanks! --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=fix-org-emphasis.patch diff --git a/lisp/org.el b/lisp/org.el index 0186674..c4c3199 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -4099,7 +4099,12 @@ After a match, the match groups contain these elements: ;; set this option proved cumbersome. See this message/thread: ;; http://article.gmane.org/gmane.emacs.orgmode/68681 (defvar org-emphasis-regexp-components - '(" \t('\"{" "- \t.,:!?;'\")}\\" " \t\r\n,\"'" "." 1) + '(" \t('\"{" ; allowed as pre-match + "- \t.,:!?;'\")}\\" ; allowed as post-match + " \t\r\n,\"" ; forbidden border + "." ; allowed content + 1 ; max number of newlines + ) "Components used to build the regular expression for emphasis. This is a list with five entries. Terminology: In an emphasis string like \" *strong word* \", we call the initial space PREMATCH, the final @@ -5668,24 +5673,30 @@ The time stamps may be either active or inactive.") "Run through the buffer and add overlays to emphasized strings." (let (rtn a) (while (and (not rtn) (re-search-forward org-emph-re limit t)) - (if (not (= (char-after (match-beginning 3)) - (char-after (match-beginning 4)))) - (progn - (setq rtn t) - (setq a (assoc (match-string 3) org-emphasis-alist)) - (font-lock-prepend-text-property (match-beginning 2) (match-end 2) - 'face - (nth 1 a)) - (and (nth 2 a) - (org-remove-flyspell-overlays-in - (match-beginning 0) (match-end 0))) - (add-text-properties (match-beginning 2) (match-end 2) - '(font-lock-multiline t org-emphasis t)) - (when org-hide-emphasis-markers - (add-text-properties (match-end 4) (match-beginning 5) - '(invisible org-link)) - (add-text-properties (match-beginning 3) (match-end 3) - '(invisible org-link))))) + (let* ((border (char-after (match-beginning 3))) + (bre (regexp-quote (char-to-string border)))) + (if (and (not (= border (char-after (match-beginning 4)))) + (not (save-match-data + (string-match (concat bre ".*" bre) + (replace-regexp-in-string + "\n" " " + (substring (match-string 2) 1 -1)))))) + (progn + (setq rtn t) + (setq a (assoc (match-string 3) org-emphasis-alist)) + (font-lock-prepend-text-property (match-beginning 2) (match-end 2) + 'face + (nth 1 a)) + (and (nth 2 a) + (org-remove-flyspell-overlays-in + (match-beginning 0) (match-end 0))) + (add-text-properties (match-beginning 2) (match-end 2) + '(font-lock-multiline t org-emphasis t)) + (when org-hide-emphasis-markers + (add-text-properties (match-end 4) (match-beginning 5) + '(invisible org-link)) + (add-text-properties (match-beginning 3) (match-end 3) + '(invisible org-link)))))) (goto-char (1+ (match-beginning 0)))) rtn)) --=-=-= Content-Type: text/plain -- Bastien --=-=-=--