From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.devel Subject: RE: info faces for strings and quotations Date: Tue, 5 Oct 2004 00:15:42 -0700 Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1096960602 20267 80.91.229.6 (5 Oct 2004 07:16:42 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 5 Oct 2004 07:16:42 +0000 (UTC) Cc: Lennart Borgman Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Oct 05 09:16:31 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CEjYk-0003W0-00 for ; Tue, 05 Oct 2004 09:16:30 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CEjfN-00086t-FQ for ged-emacs-devel@m.gmane.org; Tue, 05 Oct 2004 03:23:21 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CEjfD-00085C-TO for emacs-devel@gnu.org; Tue, 05 Oct 2004 03:23:12 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CEjfD-00084l-7U for emacs-devel@gnu.org; Tue, 05 Oct 2004 03:23:11 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CEjfD-00084b-3T for emacs-devel@gnu.org; Tue, 05 Oct 2004 03:23:11 -0400 Original-Received: from [141.146.126.228] (helo=agminet01.oracle.com) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.34) id 1CEjY4-0000DN-HU for emacs-devel@gnu.org; Tue, 05 Oct 2004 03:15:48 -0400 Original-Received: from rgmgw3.us.oracle.com (rgmgw3.us.oracle.com [138.1.191.12]) by agminet01.oracle.com (Switch-3.1.4/Switch-3.1.0) with ESMTP id i957FkYZ026984; Tue, 5 Oct 2004 00:15:46 -0700 Original-Received: from rgmgw3.us.oracle.com (localhost [127.0.0.1]) by rgmgw3.us.oracle.com (Switch-3.1.4/Switch-3.1.0) with ESMTP id i957FkHT027942; Tue, 5 Oct 2004 01:15:46 -0600 Original-Received: from dradamslap (dhcp-amer-csvpn-gw2-141-144-81-47.vpn.oracle.com [141.144.81.47]) by rgmgw3.us.oracle.com (Switch-3.1.4/Switch-3.1.0) with SMTP id i957FjrF027921; Tue, 5 Oct 2004 01:15:45 -0600 Original-To: "Emacs-Devel" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 In-Reply-To: Importance: Normal X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:27918 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:27918 Below is code that highlights "..." and `...' quotations in Info. The minor display pbs I mentioned earlier (escaped quotes) have been eliminated, with input from Lennart Borgman. The only Info nodes in the Emacs manual that still display with slight problems are these: - Acknowledgements - Etags Regexps - Glossary (very minor) These remaining display problems are because of isolated " characters. For instance, in node Acknowledgements, this appears, which turns on highlighting until the next " in the node: Torbjo"rn Einarsson contributed the... And this appears in Glossary, which highlights only between the first ` and the first ': ASCII printing character ASCII printing characters include letters, digits, space, and these punctuation characters: `!@#$%^& *()_-+=|\~` {}[]:;"' <>,.?/'. The Etags Regexps pb is similar to the Glossary pb. Nothing to be done about this. And as I say, I found only three such occurrences in the entire Emacs manual. I also went through the entire Elisp manual, and found only 7 nodes where there were (similar) problems: Compilation Functions, Example Major Modes, Auto Major Mode, Imenu, Regexp Example, Standard Errors, and Index. So, I'm proposing these changes to `info.el': 1. Add these user options (or equivalent), for the quotation highlight faces and for turning this highlighting on/off: (defface info-quoted-name-face ; For `...' '((((class color) (background light)) :foreground "red3") (((class color) (background dark)) :foreground "white") (t :weight bold :slant italic)) "Face used for quoted names (`...') in `info'." :group 'info) (defface info-string-face ; For "..." '((((class color) (background light)) :foreground "green3") (((class color) (background dark)) :foreground "yellow") (t :slant italic)) "Face used for strings (\"...\") in `info'." :group 'info) (defcustom Info-fontify-quotations-flag t "*Non-nil means `info' fontifies text between quotes. This applies to double-quote strings (\"...\") and text between single-quotes (`...')." :type 'boolean :group 'info) Note: Whatever colors are picked, I think `info-quoted-name-face' should stand out more than `info-string-face'. 2. Add this function (or equivalent) to `info.el': (defun info-fontify-quotations () "Fontify double-quote strings (\"...\") and text between single-quotes (`...') For single-quotes, use `info-quoted-name-face'. For double-quotes, use `info-string-face'." (goto-char (point-min)) (let (;; double-quote strings: "...", "...\", "...\\", etc.; m1=\* ;; or single-quote strings: `...' (either-re "\"[^\"]*\\([\\\\]*\\)\"\\|`[^'\n]+'") ;; ", \", \\", \\\" etc.; m2=\* (dblquote-re "\\([\\\\]*\\)\"") m0 p0b p0e ; Whole match: `...' or "..." m1 p1b p1e ; \* subexp of "...\*" match m2 p2b p2e ; \* subexp of "...\*" match escaped-dblquote-p) (while (re-search-forward either-re nil t) (setq m0 (match-string 0) ; Whole match string p0b (nth 0 (match-data)) ; Beginning of m0 p0e (nth 1 (match-data)) ; End of m0 m1 (match-string 1) ; \* subexp of "...\*" match p1b (nth 2 (match-data)) ; Beginning of m1 p1e (nth 3 (match-data))) ; End of m2 (when (equal (char-after p0b) ?\") ; double-quote string: "..." (when (> p1e p1b) ; May be escaped: \ inside "...\*" (when (= (mod (- p1e p1b) 2) 1) ; Escaped (odd number of backslashes: \", \\\",...) (setq escaped-dblquote-p t) (while escaped-dblquote-p (if (not (re-search-forward dblquote-re nil t)) ; Look for \*" (setq escaped-dblquote-p nil) ; No \*" (setq m2 (match-string 0) ; \*" p2b (nth 0 (match-data)) ; Beginning of \*": \ or " p2e (nth 1 (match-data)) ; End of \*": " p0e p2e) ; Update pointer (if (= p2e p2b) (setq escaped-dblquote-p nil) ; Not escaped - ", \\", \\\\", etc. (when (= (mod (- p2e p2b) 2) 1) (setq escaped-dblquote-p nil)))))))) (if (eq ?` (aref m0 0)) (put-text-property (1+ p0b) (1- p0e) 'face 'info-quoted-name-face) (put-text-property p0b p0e 'face 'info-string-face))))) 3. Call `info-fontify-quotations' at the end of `Info-fontify-node' -- add this just before the last line, (set-buffer-modified-p nil): (goto-char (point-min)) (when Info-fontify-quotations-p (info-fontify-quotations)) Could others please try this and see if you think it should be added. Thanks, Drew