emacs-devel
[Top][All Lists]
Advanced

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

Re: Faces for strong, emph and friends in Info?


From: T.V Raman
Subject: Re: Faces for strong, emph and friends in Info?
Date: Mon, 8 Apr 2024 15:29:44 -0700

After  applying the patch, @strong is turning bold, but @emph is still
showing up with '_'.

As an example in node on dabbrevs:
File: emacs.info,  Node: Dabbrev Customization,  Prev: Dynamic Abbrevs,  Up: 
Abbrevs



<cite>
   Normally, dynamic abbrev expansion preserves the case pattern _of the

</cite>

Robert Pluim writes:
 > >>>>> On Mon, 08 Apr 2024 17:59:20 +0300, Eli Zaretskii <eliz@gnu.org> said:
 >     >> info.el defines faces for various structural contructs but there
 >     >> appears to be no info-strong and info-emph -- is that intentional or
 >     >> just a lay-over from the time we didn't have font faces?
 > 
 >     Eli> I think it's just that no one has written the code to show *foo* and
 >     Eli> _foo_ as italics and bold (and hide the _ and * characters).  Of
 >     Eli> course, this will cause some lines be shorter or longer than they 
 > are
 >     Eli> supposed to be, but maybe this is a worthwhile price to pay.
 > 
 >     Eli> Patches welcome.
 > 
 > How robust do you want this to be? (I took a quick look at using
 > font-lock for this, but I donʼt think that supports hiding stuff)
 > 
 > Probably needs (yet another) config variable as well.
 > 
 > 
 > diff --git a/lisp/info.el b/lisp/info.el
 > index 176bc9c0033..14ed026a568 100644
 > --- a/lisp/info.el
 > +++ b/lisp/info.el
 > @@ -4491,6 +4491,16 @@ Info-quoted
 >    '((t :inherit fixed-pitch-serif))
 >    "Face used for quoted elements.")
 >  
 > +(defface Info-strong
 > +  '((t :inherit bold))
 > +  "Face used for *strong* elements."
 > +  :version "30.1")
 > +
 > +(defface Info-emphasis
 > +  '((t :inherit italic))
 > +  "Face used for _emphasis_ elements."
 > +  :version "30.1")
 > +
 >  ;; We deliberately fontify only ‘..’ quoting, and not `..', because
 >  ;; the former can be done much more reliably, i.e. without risking
 >  ;; false positives.
 > @@ -5134,6 +5144,20 @@ Info-fontify-node
 >                  (push (set-marker (make-marker) start)
 >                        paragraph-markers))))))
 >  
 > +      ;; Font-lock *foo* and _foo_ and hide the marker characters.
 > +      (goto-char (point-min))
 > +      (while (re-search-forward "\\([*_]\\)\\([^*_\n]+\\)\\([*_]\\)" nil t)
 > +        (when (string= (match-string 1) (match-string 3))
 > +          (add-text-properties (match-beginning 1) (match-end 1)
 > +                               '(invisible t front-sticky nil 
 > rear-nonsticky t))
 > +          (add-text-properties (match-beginning 3) (match-end 3)
 > +                               '(invisible t front-sticky nil 
 > rear-nonsticky t))
 > +          (put-text-property (match-beginning 2) (match-end 2)
 > +                             'font-lock-face
 > +                             (if (string= (match-string 1) "*")
 > +                                 'Info-strong
 > +                               'Info-emphasis))))
 > +
 >        ;; Refill paragraphs (experimental feature)
 >        (when (and not-fontified-p
 >                   Info-refill-paragraphs
 > 
 > 
 > Robert
 > -- 

-- 

--



reply via email to

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