all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
Cc: lennart.borgman.073@student.lu.se, monnier@iro.umontreal.ca,
	emacs-devel@gnu.org
Subject: RE: info faces for strings and quotations
Date: Thu, 7 Oct 2004 00:13:42 -0700	[thread overview]
Message-ID: <FDELKNEBLPKKDCEBEJCBAECFCIAA.drew.adams@oracle.com> (raw)
In-Reply-To: <87llej138a.fsf@mail.jurta.org>

[-- Attachment #1: Type: text/plain, Size: 813 bytes --]

Great ideas. Patch attached, in case you want to try it.

 - Drew

-----Original Message-----
From: Juri Linkov [mailto:juri@jurta.org]

1. With the same reason to be similar to quotes in programming modes
I suggest to inherit new Info faces from corresponding standard faces
by default:

(defface info-quoted-name               ; For `...'
  '((t (:inherit font-lock-constant-face)))
  "Face used for quoted names (`...') in `info'."
  :group 'info)

(defface info-string                    ; For "..."
  '((t (:inherit font-lock-string-face)))
  "Face used for strings (\"...\") in `info'."
  :group 'info)


2. Quotes highlighted in titles are not a problem.  Just place the code
for quote fontification above the title fontification to override the
`font-lock-face' property with quote faces by title faces.


[-- Attachment #2: diff-info-highlight-quotations-third.txt --]
[-- Type: text/plain, Size: 3377 bytes --]

diff -c "c:/emacs-21.3.50/lisp/info.el" "c:/drews-lisp-20/info-w-quotes-third.el"
*** c:/emacs-21.3.50/lisp/info.el	Mon Jul 26 09:42:06 2004
--- c:/drews-lisp-20/info-w-quotes-third.el	Thu Oct  7 00:10:04 2004
***************
*** 65,70 ****
--- 65,87 ----
  The Lisp code is executed when the node is selected.")
  (put 'Info-enable-active-nodes 'risky-local-variable t)
  
+ (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)
+ 
+ (defface info-quoted-name               ; For `...'
+   '((t (:inherit font-lock-constant-face)))
+   "Face used for quoted names (`...') in `info'."
+   :group 'info)
+ 
+ (defface info-string                    ; For "..."
+   '((t (:inherit font-lock-string-face)))
+   "Face used for strings (\"...\") in `info'."
+   :group 'info)
+ 
  (defface info-node
    '((((class color) (background light)) :foreground "brown" :weight bold :slant italic)
      (((class color) (background dark)) :foreground "white" :weight bold :slant italic)
***************
*** 3416,3421 ****
--- 3433,3442 ----
                (skip-chars-backward " \t,")
                (put-text-property (point) header-end 'invisible t)))))
  
+       ;; Fontify `...' and "..."
+       (goto-char (point-min))
+       (when Info-fontify-quotations-flag (info-fontify-quotations))
+ 
        ;; Fontify titles
        (goto-char (point-min))
        (when not-fontified-p
***************
*** 3669,3676 ****
                                 '(font-lock-face info-xref
                                                  mouse-face highlight
                                                  help-echo "mouse-2: go to this URL"))))
- 
        (set-buffer-modified-p nil))))
  \f
  
  ;; When an Info buffer is killed, make sure the associated tags buffer
--- 3690,3719 ----
                                 '(font-lock-face info-xref
                                                  mouse-face highlight
                                                  help-echo "mouse-2: go to this URL"))))
        (set-buffer-modified-p nil))))
+ 
+ 
+ ;; The regexp has these parts: double-quoted string or single-quoted stuff.
+ ;;
+ ;; String has, inside "...", zero or more of these characters:
+ ;;   - any character except \ and "
+ ;;   - \ followed by any character
+ ;;
+ ;; Single-quoted stuff has, inside `...': any character except '
+ ;;
+ (defun info-fontify-quotations ()
+     "Fontify double-quote strings (\"...\") and text between single-quotes (`...')
+ For single-quotes, use face `info-quoted-name'.
+ For double-quotes, use face `info-string'."
+     (while
+         (re-search-forward
+          "\"\\(?:[^\\\"]\\|\\\\\\(?:.\\|[\n]\\)\\)*\"\\|`[^']+'"
+          nil t)
+       (if (eq ?` (aref (match-string 0) 0))
+           (put-text-property (1+ (match-beginning 0)) (1- (match-end 0))
+                              'font-lock-face 'info-quoted-name)
+         (put-text-property (match-beginning 0) (match-end 0)
+                            'font-lock-face 'info-string))))
  \f
  
  ;; When an Info buffer is killed, make sure the associated tags buffer

Diff finished.  Thu Oct 07 00:12:15 2004

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

  reply	other threads:[~2004-10-07  7:13 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-03  7:05 info faces for strings and quotations Drew Adams
2004-10-05  7:15 ` Drew Adams
2004-10-05  7:30   ` Miles Bader
2004-10-06  8:34     ` Matt Hodges
2004-10-05  8:58   ` Drew Adams
2004-10-05 11:43     ` Stefan
2004-10-05 11:56   ` Stefan
2004-10-05 16:11     ` Drew Adams
2004-10-06  2:25       ` Luc Teirlinck
2004-10-06  4:19         ` Drew Adams
2004-10-06  4:28           ` Miles Bader
2004-10-06  7:40             ` Drew Adams
2004-10-06 21:32               ` Drew Adams
2004-10-06  4:53           ` Stefan Monnier
2004-10-06  7:07             ` Drew Adams
2004-10-06 17:07               ` Robert J. Chassell
2004-10-06 21:36                 ` Drew Adams
2004-10-07  5:53                 ` Juri Linkov
2004-10-07  6:53                   ` Drew Adams
2004-10-07 14:58                     ` Stefan Monnier
2004-10-07 15:13                       ` David Kastrup
2004-10-07 17:01                         ` Stefan Monnier
2004-10-08  5:13                           ` Drew Adams
2004-10-07 15:13                       ` Kim F. Storm
2004-10-07 16:35                         ` David Kastrup
2004-10-08  0:33                   ` Luc Teirlinck
2004-10-08 16:04                   ` Richard Stallman
2004-10-08 16:51                     ` Luc Teirlinck
2004-10-09 15:45                       ` Richard Stallman
2004-10-08 20:00                     ` Robert J. Chassell
2004-10-07  5:57               ` Juri Linkov
2004-10-07 15:22               ` w3 mode Camm Maguire
2004-10-07 17:03                 ` Stefan Monnier
2004-10-07 17:25                   ` Camm Maguire
2004-10-07 17:37                     ` Mark Plaksin
2004-10-07 17:45                     ` Kevin Rodgers
2004-10-08 16:05                 ` Richard Stallman
2004-10-08 17:44                   ` David Kastrup
2004-10-07 15:28               ` unexec development Camm Maguire
2004-10-15 14:10                 ` Camm Maguire
2004-10-15 14:35                   ` Jan D.
2004-10-15 21:11                     ` Camm Maguire
2004-10-16 13:52                   ` Richard Stallman
2004-10-06  8:44         ` info faces for strings and quotations Oliver Scholz
2004-10-07  5:55       ` Juri Linkov
2004-10-07  7:13         ` Drew Adams [this message]
  -- strict thread matches above, loose matches on Subject: below --
2004-10-05 16:15 LENNART BORGMAN
2004-10-05 16:28 ` Drew Adams

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=FDELKNEBLPKKDCEBEJCBAECFCIAA.drew.adams@oracle.com \
    --to=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    --cc=lennart.borgman.073@student.lu.se \
    --cc=monnier@iro.umontreal.ca \
    /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.