unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 23798@debbugs.gnu.org
Subject: bug#23798: 25.0.90; Underscore for emphasis in Info?
Date: Sat, 18 Jun 2016 23:53:17 -0700 (PDT)	[thread overview]
Message-ID: <3129ea6b-50bf-48e6-b3d0-b180828dfc5c@default> (raw)
In-Reply-To: <<8337o9aogg.fsf@gnu.org>>

> > C-h i h n
> > Why are there underscores surrounding the text "please don't"?
> 
> That's how Info renders @emph.
> 
> > They don't cause that text to be rendered any differently.  Emacs has
> > had faces for quite some time now.  Why not use a specific face for
> > this?  Is this vestigial?  Does it really serve a purpose?
> 
> Because no one wrote code to implement that.

Then please consider this report as an enhancement request for that.

Below is a patch for one simple possibility.  It uses face `info-emphasis'
to highlight emphasized single words, such as _foobar_.

Trying to emphasize more than single words can lead to trouble: there
are places where it won't do the right thing, and readers can lose
information (since the underscores are hidden).

If the regexp is "_\\([^_]+\\)_", for instance, then it can continue
across newlines and is more likely to cause trouble than if it is
"_\\([^_\n]+\\)_" (unrelated underscores are mistaken as emphasizing).

But even the latter causes trouble in a node such as (elisp) `Symbol
Type', where there is this line:

     +-*/_~!@$%^&=:<>{}  ; A symbol named `+-*/_~!@$%^&=:<>{}'.

Even just matching words possibly separated by whitespace can lead
to trouble.  E.g., for regexp "_\\(\\(\\sw\\|[[:space:]]\\)+\\)_"
node (elisp) `Sequence Functions' is screwed up because of this code
there:

    (seq-let (_ a _ b) '(1 2 3 4)
      (list a b))

Similarly, trying to fontifie emphasized symbol names instead of
just words can be problematic.

Whatever matching is used, even just single words, there could be
some Info text that is problematic.  For instance, a Lisp example
might use _foo_ and foo as symbol names.  The fontification hides
the underscores, so that both become the same name, foo.

Still, I think fontifying only single words is pretty good.  If you
are worried about this you could add an option for such highlighting.

Is there any other kind of emphasis that is used?  For example,
does Info use double underscore for stronger emphasis, e.g.,
__abc__?  I couldn't find any such in the Emacs or Elisp manuals.


diff -u info.el info-patched.el
--- info.el	2016-06-18 22:48:10.795523400 -0700
+++ info-patched.el	2016-06-18 23:26:36.084378400 -0700
@@ -132,6 +132,12 @@
   :version "22.1"
   :group 'info)
 
+(defface info-emphasis
+  '((t (:inherit italic)))
+  "*Face for emphasized text (enclosed with underscores)."
+  :version "25.1"
+  :group 'info)
+
 (defcustom Info-fontify-visited-nodes t
   "Non-nil to fontify references to visited nodes in `info-xref-visited' face."
   :version "22.1"
@@ -4717,6 +4723,16 @@
 		  (put-text-property (match-beginning 1) (match-end 1)
 				     'invisible t)))))))
 
+      ;; Fontify emphasis: _..._
+      (goto-char (point-min))
+      (when (and font-lock-mode  not-fontified-p)
+        (while (re-search-forward "_\\(\\sw+\\)_" nil t)
+          (add-text-properties (match-beginning 0) (1+ (match-beginning 0))
+                               '(invisible t front-sticky nil rear-nonsticky t))
+          (add-text-properties (1- (match-end 0)) (match-end 0)
+                               '(invisible t front-sticky nil rear-nonsticky t))
+          (put-text-property (match-beginning 1) (match-end 1) 'font-lock-face 'info-emphasis)))
+
       ;; Fontify titles
       (goto-char (point-min))
       (when (and font-lock-mode not-fontified-p)





       reply	other threads:[~2016-06-19  6:53 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <<d3ea8bac-f3aa-48ec-a9f4-ff83f76bb393@default>
     [not found] ` <<8337o9aogg.fsf@gnu.org>
2016-06-19  6:53   ` Drew Adams [this message]
2016-06-19 15:09     ` bug#23798: 25.0.90; Underscore for emphasis in Info? Eli Zaretskii
2019-06-25 12:53       ` Lars Ingebrigtsen
2019-06-28 12:32         ` Andy Moreton
2019-06-28 13:04           ` Lars Ingebrigtsen
     [not found] <<<<<<d3ea8bac-f3aa-48ec-a9f4-ff83f76bb393@default>
     [not found] ` <<<<<<8337o9aogg.fsf@gnu.org>
     [not found]   ` <<<<<3129ea6b-50bf-48e6-b3d0-b180828dfc5c@default>
     [not found]     ` <<<<<83wpll8bbi.fsf@gnu.org>
     [not found]       ` <<<<7648aec5-f939-4da3-8d4c-9ea03799c0db@default>
     [not found]         ` <<<<83mvmh87dl.fsf@gnu.org>
     [not found]           ` <<<1def2f0a-ed4f-4d6b-a735-ed4272189f68@default>
     [not found]             ` <<<5fb65302-d814-4e9d-83aa-c53516f15bcb@default>
     [not found]               ` <<<83poqxtgvh.fsf@gnu.org>
     [not found]                 ` <<0f1d535c-cb35-41a3-8f33-456a1e4566a5@default>
     [not found]                   ` <<83oa6htg7l.fsf@gnu.org>
2016-07-01 17:43                     ` Drew Adams
     [not found] <<<<<d3ea8bac-f3aa-48ec-a9f4-ff83f76bb393@default>
     [not found] ` <<<<<8337o9aogg.fsf@gnu.org>
     [not found]   ` <<<<3129ea6b-50bf-48e6-b3d0-b180828dfc5c@default>
     [not found]     ` <<<<83wpll8bbi.fsf@gnu.org>
     [not found]       ` <<<7648aec5-f939-4da3-8d4c-9ea03799c0db@default>
     [not found]         ` <<<83mvmh87dl.fsf@gnu.org>
     [not found]           ` <<1def2f0a-ed4f-4d6b-a735-ed4272189f68@default>
     [not found]             ` <<5fb65302-d814-4e9d-83aa-c53516f15bcb@default>
     [not found]               ` <<83poqxtgvh.fsf@gnu.org>
2016-07-01 17:30                 ` Drew Adams
2016-07-01 17:34                   ` Eli Zaretskii
     [not found] <<<<d3ea8bac-f3aa-48ec-a9f4-ff83f76bb393@default>
     [not found] ` <<<<8337o9aogg.fsf@gnu.org>
     [not found]   ` <<<3129ea6b-50bf-48e6-b3d0-b180828dfc5c@default>
     [not found]     ` <<<83wpll8bbi.fsf@gnu.org>
     [not found]       ` <<7648aec5-f939-4da3-8d4c-9ea03799c0db@default>
     [not found]         ` <<83mvmh87dl.fsf@gnu.org>
2016-06-19 19:29           ` Drew Adams
2016-07-01 16:36             ` Drew Adams
2016-07-01 17:20               ` Eli Zaretskii
2016-07-02 20:59             ` Drew Adams
2016-07-03  3:34               ` Eli Zaretskii
2016-07-06 22:35                 ` John Wiegley
2016-07-06 22:52                   ` Drew Adams
     [not found] <<<d3ea8bac-f3aa-48ec-a9f4-ff83f76bb393@default>
     [not found] ` <<<8337o9aogg.fsf@gnu.org>
     [not found]   ` <<3129ea6b-50bf-48e6-b3d0-b180828dfc5c@default>
     [not found]     ` <<83wpll8bbi.fsf@gnu.org>
2016-06-19 16:23       ` Drew Adams
2016-06-19 16:34         ` Eli Zaretskii
2016-06-19  0:12 Drew Adams
2016-06-19  2:42 ` Eli Zaretskii

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3129ea6b-50bf-48e6-b3d0-b180828dfc5c@default \
    --to=drew.adams@oracle.com \
    --cc=23798@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.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).