From: "T.V Raman" <raman@google.com>
To: rpluim@gmail.com
Cc: eliz@gnu.org, raman@google.com, emacs-devel@gnu.org
Subject: Re: Faces for strong, emph and friends in Info?
Date: Mon, 8 Apr 2024 15:02:28 -0700 [thread overview]
Message-ID: <26132.26996.471153.564625@google.com> (raw)
In-Reply-To: <87o7ajssgp.fsf@gmail.com>
Applied your patch, works like a charm!
Wish I had asked for this a long time ago -- it's a huge time-saver
when using speech output.
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
> --
--
--
next prev parent reply other threads:[~2024-04-08 22:02 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-08 14:49 Faces for strong, emph and friends in Info? T.V Raman
2024-04-08 14:59 ` Eli Zaretskii
2024-04-08 16:57 ` Robert Pluim
2024-04-08 17:28 ` T.V Raman
2024-04-08 18:06 ` [External] : " Drew Adams
2024-04-08 18:27 ` Eli Zaretskii
2024-04-08 19:32 ` [External] : " Drew Adams
2024-04-09 9:01 ` Robert Pluim
2024-04-09 9:56 ` Eli Zaretskii
2024-04-10 16:11 ` Robert Pluim
2024-04-10 16:17 ` T.V Raman
2024-04-10 16:27 ` Robert Pluim
2024-04-10 16:53 ` Eli Zaretskii
2024-04-11 12:59 ` Robert Pluim
2024-04-11 14:10 ` T.V Raman
2024-04-10 16:51 ` Eli Zaretskii
2024-04-08 22:02 ` T.V Raman [this message]
2024-04-08 22:29 ` T.V Raman
2024-04-09 1:47 ` [External] : " Drew Adams
2024-04-09 2:23 ` T.V Raman
2024-04-09 4:22 ` Eli Zaretskii
2024-04-09 1:35 ` T.V Raman
2024-04-09 4:21 ` Eli Zaretskii
2024-04-09 13:29 ` T.V Raman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=26132.26996.471153.564625@google.com \
--to=raman@google.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=rpluim@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.