diff -c "c:/emacs-21.3.50/lisp/info.el" "c:/drews-lisp-20/info-w-quotes-fourth.el" *** c:/emacs-21.3.50/lisp/info.el Mon Jul 26 09:42:06 2004 --- c:/drews-lisp-20/info-w-quotes-fourth.el Thu Oct 7 21:30:04 2004 *************** *** 65,70 **** --- 65,94 ---- The Lisp code is executed when the node is selected.") (put 'Info-enable-active-nodes 'risky-local-variable t) + (defcustom Info-fontify-quotations-flag nil + "*Non-nil means `info' fontifies text between quotes. + This applies to double-quote strings (\"...\") and text between + single-quotes (`...'). + + Note: This fontification can never be 100% reliable. It aims to + be useful in most Info texts, but it can occasionally result in + fontification that you might not expect. This is not a bug; it is + part of the design to be able to appropriately fontify a great + variety of texts. Set this flag to nil if you do not find this + fontification useful." + :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 **** --- 3440,3449 ---- (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)))) ;; When an Info buffer is killed, make sure the associated tags buffer --- 3697,3733 ---- '(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 ' + ;; + ;; The regexp matches `...' or "...". The latter case also includes + ;; pseudo-strings that start with \". The second branch of the + ;; conditional tests this: if that is the match, then it moves past + ;; the \. + (defun info-fontify-quotations () + "Fontify text between double-quotes (\"...\") and single-quotes (`...') + For single-quotes, use face `info-quoted-name'. + For double-quotes, use face `info-string'." + (while (re-search-forward ; Match `...' or "..." + "\"\\(?:[^\\\"]\\|\\\\\\(?:.\\|[\n]\\)\\)*\"\\|`[^']+'" + nil t) + (cond ((eq ?` (aref (match-string 0) 0)) + (put-text-property (1+ (match-beginning 0)) (1- (match-end 0)) + 'font-lock-face 'info-quoted-name)) + ((and (goto-char (match-beginning 0)) ; "...": If preceded by \, skip it + (= 1 (mod (save-excursion (skip-chars-backward "\\\\")) 2))) + (forward-char 1)) + ((goto-char (match-end 0)) ; "..." not preceded by \ + (put-text-property (match-beginning 0) (match-end 0) + 'font-lock-face 'info-string))))) ;; When an Info buffer is killed, make sure the associated tags buffer