emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [bug] Fontification of bold and italics
@ 2014-02-26 10:49 Sebastien Vauban
  2014-03-13 16:04 ` Bastien
  0 siblings, 1 reply; 8+ messages in thread
From: Sebastien Vauban @ 2014-02-26 10:49 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hello,

With recent Org, sentences such as [1]:

--8<---------------cut here---------------start------------->8---
Explanation *answers the question "why?"*: show *why* the facts make sense.

Explanation *makes people /care/*, so they are more motivated about learning
more. "Why would I want to do /that/?"
--8<---------------cut here---------------end--------------->8---

are badly fontified. Tested with a minimal Emacs file.

See http://screencast.com/t/Qcx60vU3.

Best regards,
  Seb

[1] From the excellent book "The art of explanation" (Lee LeFever).

-- 
Sebastien Vauban

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [bug] Fontification of bold and italics
  2014-02-26 10:49 [bug] Fontification of bold and italics Sebastien Vauban
@ 2014-03-13 16:04 ` Bastien
  2014-03-14 10:34   ` Sebastien Vauban
  0 siblings, 1 reply; 8+ messages in thread
From: Bastien @ 2014-03-13 16:04 UTC (permalink / raw)
  To: Sebastien Vauban; +Cc: public-emacs-orgmode-mXXj517/zsQ



Hi Sébastien,

"Sebastien Vauban" <sva-news-D0wtAvR13HarG/iDocfnWg@public.gmane.org>
writes:

> With recent Org, sentences such as [1]:
>
> Explanation *answers the question "why?"*: show *why* the facts make sense.
>
> Explanation *makes people /care/*, so they are more motivated about learning
> more. "Why would I want to do /that/?"
>
> are badly fontified. Tested with a minimal Emacs file.

I vaguely remember this is a side-effect of another choice we made on
purpose, but if you can bisect and find the commit, I'd be interested.

-- 
 Bastien

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [bug] Fontification of bold and italics
  2014-03-13 16:04 ` Bastien
@ 2014-03-14 10:34   ` Sebastien Vauban
  2014-03-14 14:44     ` Bastien
  0 siblings, 1 reply; 8+ messages in thread
From: Sebastien Vauban @ 2014-03-14 10:34 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hi Bastien,

Bastien wrote:
> Sebastien Vauban writes:
>
>> With recent Org, sentences such as [1]:
>>
>> Explanation *answers the question "why?"*: show *why* the facts make sense.
>>
>> Explanation *makes people /care/*, so they are more motivated about learning
>> more. "Why would I want to do /that/?"
>>
>> are badly fontified. Tested with a minimal Emacs file.
>
> I vaguely remember this is a side-effect of another choice we made on
> purpose, but if you can bisect and find the commit, I'd be interested.

--8<---------------cut here---------------start------------->8---
f21150f1853180f63741083e427ef4e6bec1ea52 is the first bad commit
commit f21150f1853180f63741083e427ef4e6bec1ea52
Author: Bastien Guerry <bzg-whniv8GeeGkdnm+yROfE0A@public.gmane.org>
Date:   Fri Jan 3 11:16:14 2014 +0100

    org.el (org-do-emphasis-faces): Fix false positives handling

    * org.el (org-do-emphasis-faces): Handle false positives by
    restarting the re-search one char after the beginning of the
    match, not one char before its ending.

    Before this fix, consider this buffer

    ** Headline
      - *Bold* non-bold
      - *Bold* non-bold

    The first false positive is "** Headline\n  - *Bold*"

    Starting the search again from the last "*" will skip
    the "*Bold*" string.  Starting again at "* Headline" will
    find it.
--8<---------------cut here---------------end--------------->8---

Best regards,
  Seb

-- 
Sebastien Vauban

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [bug] Fontification of bold and italics
  2014-03-14 10:34   ` Sebastien Vauban
@ 2014-03-14 14:44     ` Bastien
  2014-03-14 15:04       ` Sebastien Vauban
                         ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Bastien @ 2014-03-14 14:44 UTC (permalink / raw)
  To: Sebastien Vauban; +Cc: public-emacs-orgmode-mXXj517/zsQ

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

Hi Sébastien,

can you test this patch against maint for a while and
report problems?

Thanks!


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: fix-org-emphasis.patch --]
[-- Type: text/x-diff, Size: 2874 bytes --]

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))
 

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


-- 
 Bastien

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [bug] Fontification of bold and italics
  2014-03-14 14:44     ` Bastien
@ 2014-03-14 15:04       ` Sebastien Vauban
  2014-03-14 15:09       ` Sebastien Vauban
  2014-03-17  1:19       ` Bastien
  2 siblings, 0 replies; 8+ messages in thread
From: Sebastien Vauban @ 2014-03-14 15:04 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Bastien wrote:
> can you test this patch against maint for a while and
> report problems?

I'll do. Thanks!

Best regards,
  Seb

-- 
Sebastien Vauban

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [bug] Fontification of bold and italics
  2014-03-14 14:44     ` Bastien
  2014-03-14 15:04       ` Sebastien Vauban
@ 2014-03-14 15:09       ` Sebastien Vauban
  2014-03-14 15:24         ` Bastien
  2014-03-17  1:19       ` Bastien
  2 siblings, 1 reply; 8+ messages in thread
From: Sebastien Vauban @ 2014-03-14 15:09 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Bastien wrote:
> can you test this patch against maint for a while and
> report problems?

A little problem (while it's already better than what's currently in
master):

http://screencast.com/t/55xJRY10UN5

The word "show", in sandwich between 2 expressions in bold, is displayed
in bold, while it shouldn't.

Best regards,
  Seb

-- 
Sebastien Vauban

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [bug] Fontification of bold and italics
  2014-03-14 15:09       ` Sebastien Vauban
@ 2014-03-14 15:24         ` Bastien
  0 siblings, 0 replies; 8+ messages in thread
From: Bastien @ 2014-03-14 15:24 UTC (permalink / raw)
  To: Sebastien Vauban; +Cc: public-emacs-orgmode-mXXj517/zsQ



Sebastien Vauban <sva-news-D0wtAvR13HarG/iDocfnWg@public.gmane.org>
writes:

> A little problem (while it's already better than what's currently in
> master):
>
> http://screencast.com/t/55xJRY10UN5
>
> The word "show", in sandwich between 2 expressions in bold, is displayed
> in bold, while it shouldn't.

For that you need to remove the " character from characters that are
forbidden as border chars (check `org-emphasis-regexp-components'
docstring.)

HTH,

-- 
 Bastien

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [bug] Fontification of bold and italics
  2014-03-14 14:44     ` Bastien
  2014-03-14 15:04       ` Sebastien Vauban
  2014-03-14 15:09       ` Sebastien Vauban
@ 2014-03-17  1:19       ` Bastien
  2 siblings, 0 replies; 8+ messages in thread
From: Bastien @ 2014-03-17  1:19 UTC (permalink / raw)
  To: Sebastien Vauban; +Cc: public-emacs-orgmode-mXXj517/zsQ



Hi Sébastien,

Bastien <bzg@gnu.org> writes:

> can you test this patch against maint for a while and
> report problems?

I've pushed this patch.  Thanks for reporting any slowdown.

-- 
 Bastien

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-03-17  1:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-26 10:49 [bug] Fontification of bold and italics Sebastien Vauban
2014-03-13 16:04 ` Bastien
2014-03-14 10:34   ` Sebastien Vauban
2014-03-14 14:44     ` Bastien
2014-03-14 15:04       ` Sebastien Vauban
2014-03-14 15:09       ` Sebastien Vauban
2014-03-14 15:24         ` Bastien
2014-03-17  1:19       ` Bastien

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).