From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.bugs Subject: bug#23798: 25.0.90; Underscore for emphasis in Info? Date: Sat, 18 Jun 2016 23:53:17 -0700 (PDT) Message-ID: <3129ea6b-50bf-48e6-b3d0-b180828dfc5c@default> References: <> <<8337o9aogg.fsf@gnu.org>> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1466319268 29053 80.91.229.3 (19 Jun 2016 06:54:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 19 Jun 2016 06:54:28 +0000 (UTC) Cc: 23798@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jun 19 08:54:14 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bEWcX-0001CV-7B for geb-bug-gnu-emacs@m.gmane.org; Sun, 19 Jun 2016 08:54:13 +0200 Original-Received: from localhost ([::1]:37741 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEWcW-0005cM-BG for geb-bug-gnu-emacs@m.gmane.org; Sun, 19 Jun 2016 02:54:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38087) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEWcP-0005cE-M6 for bug-gnu-emacs@gnu.org; Sun, 19 Jun 2016 02:54:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bEWcM-0005jZ-HI for bug-gnu-emacs@gnu.org; Sun, 19 Jun 2016 02:54:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:33217) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEWcM-0005jT-Dq for bug-gnu-emacs@gnu.org; Sun, 19 Jun 2016 02:54:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bEWcM-0005PL-2y for bug-gnu-emacs@gnu.org; Sun, 19 Jun 2016 02:54:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Drew Adams Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 19 Jun 2016 06:54:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23798 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 23798-submit@debbugs.gnu.org id=B23798.146631921920759 (code B ref 23798); Sun, 19 Jun 2016 06:54:02 +0000 Original-Received: (at 23798) by debbugs.gnu.org; 19 Jun 2016 06:53:39 +0000 Original-Received: from localhost ([127.0.0.1]:45554 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bEWby-0005Oi-Uc for submit@debbugs.gnu.org; Sun, 19 Jun 2016 02:53:39 -0400 Original-Received: from aserp1040.oracle.com ([141.146.126.69]:27587) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bEWbw-0005OV-C4 for 23798@debbugs.gnu.org; Sun, 19 Jun 2016 02:53:37 -0400 Original-Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u5J6rRQ9031460 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 19 Jun 2016 06:53:29 GMT Original-Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u5J6rRhR027866 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 19 Jun 2016 06:53:27 GMT Original-Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userv0121.oracle.com (8.13.8/8.13.8) with ESMTP id u5J6rQpB027908; Sun, 19 Jun 2016 06:53:27 GMT In-Reply-To: <<8337o9aogg.fsf@gnu.org>> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9 (901082) [OL 12.0.6744.5000 (x86)] X-Source-IP: userv0021.oracle.com [156.151.31.71] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:119768 Archived-At: > > C-h i h n > > Why are there underscores surrounding the text "please don't"? >=20 > That's how Info renders @emph. >=20 > > 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? >=20 > 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: +-*/_~!@$%^&=3D:<>{} ; A symbol named `+-*/_~!@$%^&=3D:<>{}'. 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=092016-06-18 22:48:10.795523400 -0700 +++ info-patched.el=092016-06-18 23:26:36.084378400 -0700 @@ -132,6 +132,12 @@ :version "22.1" :group 'info) =20 +(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' f= ace." :version "22.1" @@ -4717,6 +4723,16 @@ =09=09 (put-text-property (match-beginning 1) (match-end 1) =09=09=09=09 'invisible t))))))) =20 + ;; 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-nonstic= ky t)) + (add-text-properties (1- (match-end 0)) (match-end 0) + '(invisible t front-sticky nil rear-nonstic= ky 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)