* info faces for strings and quotations @ 2004-10-03 7:05 Drew Adams 2004-10-05 7:15 ` Drew Adams 0 siblings, 1 reply; 48+ messages in thread From: Drew Adams @ 2004-10-03 7:05 UTC (permalink / raw) I find Info to be a lot more readable with strings ("blah blah toto titi") and quoted names (`my-foobar-function') highlighted in different faces from the rest of the text. What about adding something simple like this to the end of Info-fontify-node - just before (set-buffer-modified-p nil): (goto-char (point-min)) (while (re-search-forward "`\\([^']+\\)'" nil t) (put-text-property (match-beginning 1) (match-end 1) 'face info-quoted-name-face)) (goto-char (point-min)) (while (re-search-forward "\"\\([^\"]+\\)\"" nil t) (put-text-property (match-beginning 1) (match-end 1) 'face info-string-face)) Granted, there are a few Info nodes that get thrown off by this simple matching because of unbalanced double or single quotes. This happens when a node discusses characters like \", \`, and \' or uses this, where the two are nested: `""'. Probably most of these problems could be eliminated by smartening up the regexps. Most of the "rogue" occurrences of these characters are preceded by backslashes: \". Even with these simple regexps, however, 99% of the pages look better, and the text is much more readable, IMO. In particular, it is very helpful that quoted names stand out; the double-quoted strings are less important. To see this at its _worst_, these are the nodes of the Emacs manual that throw off the regexps to some extent: - Glossary - Key (Character) Index - Minor Modes - Init Syntax - Printing and MS-DOS - Cursor Position Information (at the bottom) - TeX Editing Commands - Options Controlling Comments - Etags Regexps - Acknowledgements ^ permalink raw reply [flat|nested] 48+ messages in thread
* RE: info faces for strings and quotations 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 ` (2 more replies) 0 siblings, 3 replies; 48+ messages in thread From: Drew Adams @ 2004-10-05 7:15 UTC (permalink / raw) Cc: Lennart Borgman 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 ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: info faces for strings and quotations 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:56 ` Stefan 2 siblings, 1 reply; 48+ messages in thread From: Miles Bader @ 2004-10-05 7:30 UTC (permalink / raw) Cc: Lennart Borgman, Emacs-Devel "Drew Adams" <drew.adams@oracle.com> writes: > 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: Please do not use the suffix `-face' for face names -- they have their own namespace, so it is redundant. Just use something like (defface info-quoted-name ...) and (defface info-string ...). Thanks, -Miles -- In New York, most people don't have cars, so if you want to kill a person, you have to take the subway to their house. And sometimes on the way, the train is delayed and you get impatient, so you have to kill someone on the subway. [George Carlin] ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: info faces for strings and quotations 2004-10-05 7:30 ` Miles Bader @ 2004-10-06 8:34 ` Matt Hodges 0 siblings, 0 replies; 48+ messages in thread From: Matt Hodges @ 2004-10-06 8:34 UTC (permalink / raw) [-- Attachment #1: Type: text/plain, Size: 512 bytes --] >>>>> Miles Bader writes: > Please do not use the suffix `-face' for face names -- they have > their own namespace, so it is redundant. Just use something like > (defface info-quoted-name ...) and (defface info-string ...). I was going to suggest that an apropos-face command might be useful, but I see that customize-apropos-faces already exists. This is quite slow, at least on my machine, so how about allowing a filter for list-faces-display? Something along the lines of the attached. Thanks, Matt [-- Attachment #2: Patch for faces.el. --] [-- Type: text/plain, Size: 3452 bytes --] *** faces.el 15 Sep 2004 11:48:16 +0100 1.290 --- faces.el 06 Oct 2004 09:22:57 +0100 *************** *** 1136,1150 **** ;; conflict with Lucid, which uses that name differently. (defvar help-xref-stack) ! (defun list-faces-display () "List all faces, using the same sample text in each. The sample text is a string that comes from the variable ! `list-faces-sample-text'." ! (interactive) (let ((faces (sort (face-list) #'string-lessp)) - (face nil) (frame (selected-frame)) disp-frame window face-name) (with-output-to-temp-buffer "*Faces*" (save-excursion (set-buffer standard-output) --- 1136,1157 ---- ;; conflict with Lucid, which uses that name differently. (defvar help-xref-stack) ! (defun list-faces-display (&optional regexp) "List all faces, using the same sample text in each. The sample text is a string that comes from the variable ! `list-faces-sample-text'. With a prefix arg, limit faces to those ! matching REGEXP." ! (interactive (list (and current-prefix-arg ! (read-string "Filter by regexp: ")))) (let ((faces (sort (face-list) #'string-lessp)) (frame (selected-frame)) disp-frame window face-name) + ;; Perhaps filter by regexp + (when regexp + (setq faces (delq nil (mapcar (lambda (f) + (when (string-match regexp + (symbol-name f)) f)) + faces)))) (with-output-to-temp-buffer "*Faces*" (save-excursion (set-buffer standard-output) *************** *** 1157,1165 **** "\\[help-follow] on a face name to customize it\n" "or on its sample text for a description of the face.\n\n"))) (setq help-xref-stack nil) ! (while faces ! (setq face (car faces)) ! (setq faces (cdr faces)) (setq face-name (symbol-name face)) (insert (format "%25s " face-name)) ;; Hyperlink to a customization buffer for the face. Using --- 1164,1170 ---- "\\[help-follow] on a face name to customize it\n" "or on its sample text for a description of the face.\n\n"))) (setq help-xref-stack nil) ! (mapcar (lambda (face) (setq face-name (symbol-name face)) (insert (format "%25s " face-name)) ;; Hyperlink to a customization buffer for the face. Using *************** *** 1187,1192 **** --- 1192,1198 ---- (while (not (eobp)) (insert " ") (forward-line 1)))) + faces) (goto-char (point-min))) (print-help-return-message)) ;; If the *Faces* buffer appears in a different frame, *************** *** 1196,1205 **** (setq disp-frame (if window (window-frame window) (car (frame-list)))) (or (eq frame disp-frame) ! (let ((faces (face-list))) ! (while faces ! (copy-face (car faces) (car faces) frame disp-frame) ! (setq faces (cdr faces))))))) (defun describe-face (face &optional frame) "Display the properties of face FACE on FRAME. --- 1202,1210 ---- (setq disp-frame (if window (window-frame window) (car (frame-list)))) (or (eq frame disp-frame) ! (while faces ! (copy-face (car faces) (car faces) frame disp-frame) ! (setq faces (cdr faces)))))) (defun describe-face (face &optional frame) "Display the properties of face FACE on FRAME. [-- Attachment #3: Type: text/plain, Size: 142 bytes --] _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel ^ permalink raw reply [flat|nested] 48+ messages in thread
* RE: info faces for strings and quotations 2004-10-05 7:15 ` Drew Adams 2004-10-05 7:30 ` Miles Bader @ 2004-10-05 8:58 ` Drew Adams 2004-10-05 11:43 ` Stefan 2004-10-05 11:56 ` Stefan 2 siblings, 1 reply; 48+ messages in thread From: Drew Adams @ 2004-10-05 8:58 UTC (permalink / raw) Cc: Lennart Borgman Sorry, the main regexp should be non-greedy. This: "\"[^\"]*?\\([\\\\]*\\)\"\\|`[^'\n]+'" instead of this: "\"[^\"]*\\([\\\\]*\\)\"\\|`[^'\n]+'" Thanks Lennart. - Drew -----Original Message----- Below is code that highlights "..." and `...' quotations in Info. ... (defun info-fontify-quotations () "..." (goto-char (point-min)) (let ((either-re "\"[^\"]*\\([\\\\]*\\)\"\\|`[^'\n]+'") ...)) ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: info faces for strings and quotations 2004-10-05 8:58 ` Drew Adams @ 2004-10-05 11:43 ` Stefan 0 siblings, 0 replies; 48+ messages in thread From: Stefan @ 2004-10-05 11:43 UTC (permalink / raw) Cc: Lennart Borgman, Emacs-Devel > "\"[^\"]*?\\([\\\\]*\\)\"\\|`[^'\n]+'" ^^^^^^ This is the regexp [\\] (once you remove the quoting related to strings). In a char-range, \ is not special, so [\\] is just like [aa] (expect for the char \ instead of the char a), so it's equivalent to [\] which is equivalent to \\ except it's slower. Just use "\"[^\"]*?\\(\\\\*\\)\"\\|`[^'\n]+'" but I must say that I do not understand this \\(\\\\*\\) business. Stefan ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: info faces for strings and quotations 2004-10-05 7:15 ` Drew Adams 2004-10-05 7:30 ` Miles Bader 2004-10-05 8:58 ` Drew Adams @ 2004-10-05 11:56 ` Stefan 2004-10-05 16:11 ` Drew Adams 2 siblings, 1 reply; 48+ messages in thread From: Stefan @ 2004-10-05 11:56 UTC (permalink / raw) Cc: Lennart Borgman, Emacs-Devel > (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 Never do (nth x (match-data)). Always use (match-beginning N) or (match-end N) instead. Much more readable (and efficient). > p0e (nth 1 (match-data)) ; End of m0 > m1 (match-string 1) ; \* subexp of "...\*" match The code never seems to use `m1' so you can spare this string-allocation. > 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) ; \*" Similary `m2' is never used. > 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)))))))) Why not use (either-re "\"\\([^\\\"]\\|\\\\[\\\"]\\)*\"\\|`[^'\n]+'") and get rid of all this code (i.e. the regexp-matching does the escape-counting for you)? > (if (eq ?` (aref m0 0)) Use (eq ?` (char-after p0b)) and you can get rid of `m0'. > (put-text-property (1+ p0b) (1- p0e) 'face 'info-quoted-name-face) > (put-text-property p0b p0e 'face 'info-string-face))))) Why fontify the interior of `...' but fontify both the interior and the quotes for "..." ? I.e. why not use (put-text-property p0b p0e 'face (if (eq ?` (char-after p0b)) 'info-quoted-name-face 'info-string-face)) or (put-text-property (1+ p0b) (1- p0e) 'face (if (eq ?` (char-after p0b)) 'info-quoted-name-face 'info-string-face)) Is it just because your quoted face is bold and you don't like to see the ` and ' in bold, or is there a deeper reason? Stefan ^ permalink raw reply [flat|nested] 48+ messages in thread
* RE: info faces for strings and quotations 2004-10-05 11:56 ` Stefan @ 2004-10-05 16:11 ` Drew Adams 2004-10-06 2:25 ` Luc Teirlinck 2004-10-07 5:55 ` Juri Linkov 0 siblings, 2 replies; 48+ messages in thread From: Drew Adams @ 2004-10-05 16:11 UTC (permalink / raw) Cc: Lennart Borgman, Emacs-Devel Thanks for lots of good input, Stephan. You made several good points about the implementation, which I'll put into practice immediately. As you know, in my first message, I used just these (separate) simple regexp searches, which didn't take care of escaped "s but worked 99% of the time: (re-search-forward "`\\([^']+\\)'" nil t) (re-search-forward "\"\\([^\"]+\\)\"" nil t) I mentioned the fact that the regexps could be improved, and Lennart was kind enough to do some coding and testing. He came up with something that solved the escaped "s pb, which I tried and sent along to the list (though I mistakenly left off the non-greedy "?"). I sent the updated code because it improved the functionality, taking care of some corner cases. I'll make the implementation changes you suggest. Besides the implementation issues, you asked this question about the _functionality_: Why fontify the interior of `...' but fontify both the interior and the quotes for "..." ? Is it just because your quoted face is bold and you don't like to see the ` and ' in bold, or is there a deeper reason? Good question. That was by design. In most Info files, `...' is used to identify commands, key sequences, filenames and the like; "..." is used (usually) to identify strings in code. I found that not highlighting the single-quotes and highlighting the double-quotes improved readability. Try different combinations of highlighting the quotes (or not), yourself, and see what you think. My second choice would be to not highlight either kind of delimiter. BTW, I didn't test this with a terminal Emacs; I just threw the bold-italic and italic face attributes in there at the last minute to have something for the non-(class color) case. Do you have a suggestion on what to use in that case? (In fact, just before I sent the email, the version I use had face variables with defvar, which is why I used the names *-face -- a no-no nowadays, as Miles pointed out.) The code will be cleaner & leaner thanks to input from Lennart, Miles, and you. So, what do you and others think of the _desirability_ of (optionally) highlighting quoted expressions in Info? - Drew ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: info faces for strings and quotations 2004-10-05 16:11 ` Drew Adams @ 2004-10-06 2:25 ` Luc Teirlinck 2004-10-06 4:19 ` Drew Adams 2004-10-06 8:44 ` info faces for strings and quotations Oliver Scholz 2004-10-07 5:55 ` Juri Linkov 1 sibling, 2 replies; 48+ messages in thread From: Luc Teirlinck @ 2004-10-06 2:25 UTC (permalink / raw) Cc: lennart.borgman.073, monnier, emacs-devel Drew Adams wrote: So, what do you and others think of the _desirability_ of (optionally) highlighting quoted expressions in Info? Info files are essentially plain text with some minimal markup that is intended for navigation, not highlighting. So I believe that there is no way that one can do what you are trying to do completely reliably any more than that it is possible to implement Info-hide-note-references completely reliably. To do that, one would need to base the Emacs Info reader on the XML output format instead of on the Info output format. (Maybe somebody might actually do that some day.) So I would suggest that if any feature like this is added to the Emacs Info reader, that it should be done as a user option, that is off by default. Also, the docstring should explicitly mention that it occasionally can lead to anomalous highlighting. Sincerely, Luc. ^ permalink raw reply [flat|nested] 48+ messages in thread
* RE: info faces for strings and quotations 2004-10-06 2:25 ` Luc Teirlinck @ 2004-10-06 4:19 ` Drew Adams 2004-10-06 4:28 ` Miles Bader 2004-10-06 4:53 ` Stefan Monnier 2004-10-06 8:44 ` info faces for strings and quotations Oliver Scholz 1 sibling, 2 replies; 48+ messages in thread From: Drew Adams @ 2004-10-06 4:19 UTC (permalink / raw) Cc: lennart.borgman.073, monnier, emacs-devel Info highlighting off by default. I can live with that. What do others think? BTW, have you -- have others -- _tried_ the code? Your argument sounds, well, hypothetical. In _practice_, there are only *4* nodes of the Elisp Manual that exhibit any highlighting problem at all, and those pbs are minor. This is a big manual. Yes, it's obvious that there will always be some examples of code in the Info doc (on different programming languages, for instance) that use expressions (e.g. regexp expressions or byte-code examples) that won't highlight 100% correctly. Info highlighting works perfectly 99% of the time, however, including lots of crazy regexp expressions in the Elisp manual (yes, it's surprising). And, the same rare problems can be seen with font-lock highlighting of Emacs Lisp code -- which is presumably one reason we turn off font-lock by default. (Do the doc strings of font-lock functions mention that they "occasionally can lead to anomalous highlighting"? Are we worried about being sued, here, or what?) Some of the rare Info highlighting problems point out things that should really be changed in the Info files themselves, such as ``region'' instead of "region" at node (emacs)Top (highlighted from first ` to first '), or this unnecessary single-quoting of a Lisp sexp at node (elisp)Auto Major Mode: `("\\.gz\\'" FUNCTION t)'. You say that Info markup is "intended for navigation, not highlighting". The `...' convention is explicitly intended to _highlight_ (demarcate, delimit, bring out, set off, draw attention to) commands, key sequences, and perhaps file names. It has absolutely nothing to do with navigating. That's the markup convention I want to exploit here -- that and "..." for strings. This proposal has nothing to do with other, hidden info-file markup; it is all about user-visible "highlighting". Perhaps what you meant was that `...' was not _originally designed_ with an eye to being highlighted. Agreed. But it lends itself to highlighting remarkably well, with no changes needed. Again, I invite you to try it, to see what it does in _practice_. Here is the code, with the latest regexp, which allows escaped chars and newlines inside `...' and "...". (Some Info nodes, like (emacs)Visiting, split a key sequence or command name over two lines.) (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]\\)\\)*\"\\|`\\(?:[^'\\]\\|\\\\\\(?:.\\|[ \n]\\)\\)+'" nil t) (if (eq ?` (aref (match-string 0) 0)) (put-text-property (1+ (match-beginning 0)) (1- (match-end 0)) 'face 'info-quoted-name) (put-text-property (match-beginning 0) (match-end 0) 'face 'info-string)))) Again, to use this, just call `info-fontify-quotations' at the end of `Info-fontify-node' -- add this just before the last line, which is (set-buffer-modified-p nil): (goto-char (point-min)) (when Info-fontify-quotations-p (info-fontify-quotations)) Hoping to hear from more people who have tried the code, regardless of which way your opinion leans. - Drew P.S. FYI, the 4 Elisp-manual nodes that do _not_ highlight 100% correctly are these: - Example Major Modes -- an isolated " (?\") - Index -- an isolated " (" entry in the index) - Auto Major Modes -- the single-quoted Lisp sexp mentioned above - Standard Error -- ' inside "..." inside `...' (`"Symbol's chain of function indirections contains a loop"') -- this too should probably be corrected in the doc itself If the latter two were corrected in the Info files, there would be only *2* nodes of the entire Elisp manual that were not 100% perfect. I don't think we'll be sued. -----Original Message----- From: Luc Teirlinck [mailto:teirllm@dms.auburn.edu] So, what do you and others think of the _desirability_ of (optionally) highlighting quoted expressions in Info? Info files are essentially plain text with some minimal markup that is intended for navigation, not highlighting. So I believe that there is no way that one can do what you are trying to do completely reliably any more than that it is possible to implement Info-hide-note-references completely reliably. To do that, one would need to base the Emacs Info reader on the XML output format instead of on the Info output format. (Maybe somebody might actually do that some day.) So I would suggest that if any feature like this is added to the Emacs Info reader, that it should be done as a user option, that is off by default. Also, the docstring should explicitly mention that it occasionally can lead to anomalous highlighting. ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: info faces for strings and quotations 2004-10-06 4:19 ` Drew Adams @ 2004-10-06 4:28 ` Miles Bader 2004-10-06 7:40 ` Drew Adams 2004-10-06 4:53 ` Stefan Monnier 1 sibling, 1 reply; 48+ messages in thread From: Miles Bader @ 2004-10-06 4:28 UTC (permalink / raw) Cc: lennart.borgman.073, Luc Teirlinck, monnier, emacs-devel "Drew Adams" <drew.adams@oracle.com> writes: > BTW, have you -- have others -- _tried_ the code? Could you send it as a single patch file? That's a good idea any time you submit code for consideration (easier to test, and often less ambiguous). Thanks, -Miles -- `Cars give people wonderful freedom and increase their opportunities. But they also destroy the environment, to an extent so drastic that they kill all social life' (from _A Pattern Language_) ^ permalink raw reply [flat|nested] 48+ messages in thread
* RE: info faces for strings and quotations 2004-10-06 4:28 ` Miles Bader @ 2004-10-06 7:40 ` Drew Adams 2004-10-06 21:32 ` Drew Adams 0 siblings, 1 reply; 48+ messages in thread From: Drew Adams @ 2004-10-06 7:40 UTC (permalink / raw) Cc: lennart.borgman.073, Luc Teirlinck, monnier, emacs-devel [-- Attachment #1: Type: text/plain, Size: 496 bytes --] Here's the patch to info.el that highlights `...' and "...". Sending it as an attachment because my mailer apparently wraps the lines otherwise. - Drew -----Original Message----- From: Miles Bader [mailto:miles@lsi.nec.co.jp] "Drew Adams" <drew.adams@oracle.com> writes: > BTW, have you -- have others -- _tried_ the code? Could you send it as a single patch file? That's a good idea any time you submit code for consideration (easier to test, and often less ambiguous). Thanks, -Miles [-- Attachment #2: diff-info-highlight-quotations.txt --] [-- Type: text/plain, Size: 4007 bytes --] diff -c "c:/emacs-21.3.50/lisp/info.el" "c:/drews-lisp-20/info-w-quotes.el" *** c:/emacs-21.3.50/lisp/info.el Mon Jul 26 09:42:06 2004 --- c:/drews-lisp-20/info-w-quotes.el Tue Oct 5 21:45:12 2004 *************** *** 65,70 **** --- 65,91 ---- 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 + '((((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 + '((((class color) (background light)) :foreground "green4") + (((class color) (background dark)) :foreground "yellow") + (t :slant italic)) + "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) *************** *** 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,3736 ---- '(font-lock-face info-xref mouse-face highlight help-echo "mouse-2: go to this URL")))) ! (goto-char (point-min)) ! (when Info-fontify-quotations-flag (info-fontify-quotations)) (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 `...', one or more of these characters: + ;; - any character except \ and ' + ;; - \ followed by any character + ;; + (if (< emacs-major-version 21) + (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]\\)\\)*\"\\|`\\([^'\\]\\|\\\\\\(.\\|[\n]\\)\\)+'" + nil t) + (if (eq ?` (aref (match-string 0) 0)) + (put-text-property (1+ (match-beginning 0)) (1- (match-end 0)) + 'face info-quoted-name) + (put-text-property (match-beginning 0) (match-end 0) + 'face info-string)))) + (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]\\)\\)*\"\\|`\\(?:[^'\\]\\|\\\\\\(?:.\\|[\n]\\)\\)+'" + nil t) + (if (eq ?` (aref (match-string 0) 0)) + (put-text-property (1+ (match-beginning 0)) (1- (match-end 0)) + 'face 'info-quoted-name) + (put-text-property (match-beginning 0) (match-end 0) + 'face 'info-string))))) \f ;; When an Info buffer is killed, make sure the associated tags buffer [-- Attachment #3: Type: text/plain, Size: 142 bytes --] _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel ^ permalink raw reply [flat|nested] 48+ messages in thread
* RE: info faces for strings and quotations 2004-10-06 7:40 ` Drew Adams @ 2004-10-06 21:32 ` Drew Adams 0 siblings, 0 replies; 48+ messages in thread From: Drew Adams @ 2004-10-06 21:32 UTC (permalink / raw) [-- Attachment #1: Type: text/plain, Size: 451 bytes --] Here's an updated patch, which replaces the previous one. It does everything the previous version did, but also correctly treats some of the common pbs I saw yesterday, such as `\' and `C-\'. In fact, it just allows _any_ character (except ') inside `...'. Sorry about sending two patches. I don't expect to change this again. - Drew From: Drew Adams [mailto:drew.adams@oracle.com] Here's the patch to info.el that highlights `...' and "...". [-- Attachment #2: diff-info-highlight-quotations-second.txt --] [-- Type: text/plain, Size: 3237 bytes --] cd c:/drews-lisp-20/ diff -c "c:/emacs-21.3.50/lisp/info.el" "c:/drews-lisp-20/info-w-quotes-second.el" *** c:/emacs-21.3.50/lisp/info.el Mon Jul 26 09:42:06 2004 --- c:/drews-lisp-20/info-w-quotes-second.el Wed Oct 6 13:51:18 2004 *************** *** 65,70 **** --- 65,91 ---- 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 + '((((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 + '((((class color) (background light)) :foreground "green4") + (((class color) (background dark)) :foreground "yellow") + (t :slant italic)) + "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) *************** *** 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,3721 ---- '(font-lock-face info-xref mouse-face highlight help-echo "mouse-2: go to this URL")))) ! (goto-char (point-min)) ! (when Info-fontify-quotations-flag (info-fontify-quotations)) (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)) + 'face 'info-quoted-name) + (put-text-property (match-beginning 0) (match-end 0) + 'face 'info-string)))) \f ;; When an Info buffer is killed, make sure the associated tags buffer Diff finished at Wed Oct 06 13:51:40 [-- Attachment #3: Type: text/plain, Size: 142 bytes --] _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: info faces for strings and quotations 2004-10-06 4:19 ` Drew Adams 2004-10-06 4:28 ` Miles Bader @ 2004-10-06 4:53 ` Stefan Monnier 2004-10-06 7:07 ` Drew Adams 1 sibling, 1 reply; 48+ messages in thread From: Stefan Monnier @ 2004-10-06 4:53 UTC (permalink / raw) Cc: lennart.borgman.073, Luc Teirlinck, emacs-devel > And, the same rare problems can be seen with font-lock highlighting of Emacs It's actually slightly different: the nature of programming languages implies that there exist an automatic way to unambiguously define what is a correct parse. I.e., font-lock highlighting has bugs, but they can clearly be recognized as such (and often fixed if it matters enough). Also font-lock bugs generally can be worked around by changing the source code because such buffers are generally writable. In Info files, the "..." and `...' syntax is not unambiguous (it is intended to be parsed by humans only), so there is no automatic system that works 100% percent: any fix for a particular case will introduce problems elsewhere. And Info buffers are normally read-only and most Info users will have a hard time finding the Info or Texinfo files to edit them (and they often can't edit them because they don't have the required access rights). Your regexps work great for Info pages describing Elisp code. For Info pages relating to some other language where the convention for escape sequences in strings is significantly different, they may work very poorly. But that's what the config var is for, anyway. I would probably turn it on ;-) Stefan ^ permalink raw reply [flat|nested] 48+ messages in thread
* RE: info faces for strings and quotations 2004-10-06 4:53 ` Stefan Monnier @ 2004-10-06 7:07 ` Drew Adams 2004-10-06 17:07 ` Robert J. Chassell ` (3 more replies) 0 siblings, 4 replies; 48+ messages in thread From: Drew Adams @ 2004-10-06 7:07 UTC (permalink / raw) Cc: lennart.borgman.073, Luc Teirlinck, emacs-devel OK, sure, sure. Programming languages are formal languages, so your point is of course correct, technically. And, if existing font-lock code doesn't do a better job in practice than Info quote highlighting, at least it has the theoretical advantage that it _could_ be made to parse the language as needed. My point was a practical one, about the current state of font-lock code. It is good enough; we live with it; we probably don't want it to spend much more time trying to be more precise. I'd much rather hear about results from practicing with this than arguments of this sort. Or, lets say, in addition to arguments of this sort. I only have the usual info files delivered with Emacs and Cygwin, and, yes, none of them are devoted to examples of APL code...sigh. But, based on your argument about not necessarily being appropriate to other languages than Lisp, I did take a look at some of the 33 standard Info manuals I do have. In fact, I checked them all -- all nodes (the highlighting helps to check them quickly). Many are of course about Emacs and Emacs Lisp packages. Even in those, however, there are examples of code in other languages. I did find the following highlighting problems in all the 33 manuals I checked. I didn't find any pbs in the manuals not mentioned. ------------ CC MODE -- node Text Filling and Line Breaking: `\' (this case isn't treated yet, but perhaps should be) CL -- node Old CL Compatibility: middle of title "The `cl-compat'package" got highlighted as a `...' IDLWAVE -- node Getting Started: same pb as CC Mode (`\') -- node Code Templates: same MH-E -- node Moving Your Mail Around: `"lpr -J '%s'"' (first ' ends `...'; second " starts "...") MESSAGE -- node: Message Actions: lisp quoted sexp -- '(set-window-configuration... EMACS FAQ -- several nodes have `...' or "..." in node titles. These are highlighted. WIDGET -- several nodes have `...' in titles REFTEX -- node fancyref (LaTeX package): `fancyref' in title highlighted VIP -- node New Commands: same pb as CC Mode (`\') -- node Important Keys: same VIPER -- node Emacs Preliminaries: `C-\' (' is considered escaped, so doesn't turn off highlighting) -- node Vi State: same -- node Insert State: same -- node Emacs Related Commands: same -- node New Commands: same pb as CC Mode (`\') -- node Key Index: isolated " -- * "<a-z1-9>P: CALC -- node Arithmetic Tutorial: same pb as CC Mode (`\') -- node Types Tutorial: isolated " from hours, minutes, seconds entries in table, such as 2@ 30' 0" -- node Programming Tutorial: this comment with isolated `: # Save local values (Z `) -- node List Answer 9: same pb as CC Mode (`\') -- node List Tutorial Exercise 13: isolated " -- "Testing, 1, 2, 3 <RET> -- node Types Tutorial Exercise 4: more hours, minutes, seconds entries -- node Programming Tutorial Exercise 8, 9, and 10: isolated ` -- C-x ( Z ` -- node HMS Forms: more hours, minutes, seconds as @ ' and " -- node HMS Formats: more hours, minutes, seconds as @ ' and " -- node Business Days: more hours, minutes, seconds as @ ' and " -- node Polynomials: key sequence `a \' (the ' is considered escaped by the highlighting) -- node More About Embedded Mode: same pb as CC Mode (`\') -- node Customizing Embedded Mode: regexp `"\\'\\|\n$\\|\\$\\$?"' (first ' ends `...' and second " starts "...") -- Calc Summary: isolated ` and " in table of key sequences -- Key Index: same as Calc Summary Note: the Calc manual is very large, has zillions of symbolic and formulaic examples, and deals with the syntaxes of several other languages, including Eqn, Mathematica, and Tex. It includes tabular material and ASCII art. And yes, this manual, in particular, _benefits_ greatly from quoted-name highlighting. I find it very difficult to parse (read) without highlighting. Here are two typical paragraphs of _text_: Quotients of negative-looking values are simplified according to `(-a) / (-b)' to `a / b', `(-a) / (b - c)' to `a / (c - b)', and `(a - b) / (-c)' to `(b - a) / c'. Generic identity matrices (*note Matrix Mode::) are simplified by the following rules: `idn(a) + b' to `a + b' if `b' is provably scalar, or expanded out if `b' is a matrix; `idn(a) + idn(b)' to `idn(a + b)'; `-idn(a)' to `idn(-a)'; `a idn(b)' to `idn(a b)' if `a' is provably scalar, or to `a b' if `a' is provably non-scalar; `idn(a) idn(b)' to `idn(a b)'; analogous simplifications for quotients involving `idn'; and `idn(a)^n' to `idn(a^n)' where `n' is an integer. EMACS LISP INTRO -- a few nodes, such as Top: `...' in titles -- a few nodes, such as Height of label: sexp with ' inside `...': `(apply 'max numbers-list)' -- node beginning-of-buffer complete: same pb as CC Mode (`\') -- node sentence-end: same -- node the-the: unbalanced "s in text: _I duplicate "the'_ TEXINFO -- several nodes, such as The `subsub' Commands, with `...' in title -- node First Line: same pb as CC Mode (`\') -- node Command Syntax: same -- node math: same -- node verb: isolated ' -- @verb{+@'e?`!`{}\+} this? -- node Inserting Accents: @`o -- node Defining Macros: `\PARAM1\' -- the ' is considered escaped - Drew -----Original Message----- From: emacs-devel-bounces+drew.adams=oracle.com@gnu.org [mailto:emacs-devel-bounces+drew.adams=oracle.com@gnu.org]On Behalf Of Stefan Monnier Sent: Tuesday, October 05, 2004 9:53 PM To: Drew Adams Cc: lennart.borgman.073@student.lu.se; Luc Teirlinck; emacs-devel@gnu.org Subject: Re: info faces for strings and quotations > And, the same rare problems can be seen with font-lock highlighting of Emacs It's actually slightly different: the nature of programming languages implies that there exist an automatic way to unambiguously define what is a correct parse. I.e., font-lock highlighting has bugs, but they can clearly be recognized as such (and often fixed if it matters enough). Also font-lock bugs generally can be worked around by changing the source code because such buffers are generally writable. In Info files, the "..." and `...' syntax is not unambiguous (it is intended to be parsed by humans only), so there is no automatic system that works 100% percent: any fix for a particular case will introduce problems elsewhere. And Info buffers are normally read-only and most Info users will have a hard time finding the Info or Texinfo files to edit them (and they often can't edit them because they don't have the required access rights). Your regexps work great for Info pages describing Elisp code. For Info pages relating to some other language where the convention for escape sequences in strings is significantly different, they may work very poorly. But that's what the config var is for, anyway. I would probably turn it on ;-) Stefan _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: info faces for strings and quotations 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 5:57 ` Juri Linkov ` (2 subsequent siblings) 3 siblings, 2 replies; 48+ messages in thread From: Robert J. Chassell @ 2004-10-06 17:07 UTC (permalink / raw) Today's GNU Emacs CVS snapshot, Wed, 2004 Oct 6 16:05 UTC GNU Emacs 21.3.50.6 (i686-pc-linux-gnu, GTK+ Version 2.4.10) in which info.el is patched from Drew's message of Wed, 6 Oct 2004 00:40:07 -0700 started with /usr/local/src/emacs/src/emacs -Q The Info buffer fails to highlight properly when the Info file is produced from a correct Texinfo source. "Drew Adams" <drew.adams@oracle.com> wrote: I did find the following highlighting problems in all the 33 manuals I checked. Regarding the `Introduction to Programming in Emacs Lisp', you mentioned -- a few nodes, such as Height of label: sexp with ' inside `...': `(apply 'max numbers-list)' The regexp failed even though the Texinfo is correct. In Info, we see this: expression is `(apply 'max numbers-list)'. This returns the precise Using the patch, only `apply' is highlighted. The Texinfo source is ...emacs/lispintro/emacs-lisp-intro.texi and is: expression is @code{(apply 'max numbers-list)}. This returns the In addition to the three cases of @code{(apply 'max numbers-list)}, I found nine other case where @code is used with quoted Emacs Lisp expressions. There are also problems with @samp, which also puts single quotes around its arguments, as in The error message can be understood: `Symbol's function definition is void: this'. Only `Symbol' is highlighted. In Texinfo, this is written: The error message can be understood: @samp{Symbol's function definition is void:@: this}. There are six other @samp problems that I found. -- Robert J. Chassell bob@rattlesnake.com GnuPG Key ID: 004B4AC8 http://www.rattlesnake.com http://www.teak.cc ^ permalink raw reply [flat|nested] 48+ messages in thread
* RE: info faces for strings and quotations 2004-10-06 17:07 ` Robert J. Chassell @ 2004-10-06 21:36 ` Drew Adams 2004-10-07 5:53 ` Juri Linkov 1 sibling, 0 replies; 48+ messages in thread From: Drew Adams @ 2004-10-06 21:36 UTC (permalink / raw) [-- Attachment #1.1: Type: text/plain, Size: 3038 bytes --] Thanks, Bob. I'm glad someone played with the code and reported on what it does. The incidents you mention where highlighting was not correct are the kinds of thing I found too. I missed the last incident you mentioned. I did run quickly through all the nodes of 33 manuals late last night, and I probably missed a few others, as well. I wasn't hoping to be exhaustive in my report, but to give a good idea of 1) the relative frequency of problems (small) and 2) the kinds of problems encountered. The problems you mention fall into this class: `...' highlighting does not allow for unescaped enclosed ' marks, as in `foobar 'baz'. Highlighting here will be only around the word (and space) "foobar ". So, in particular, it will fail on single-quoted Lisp sexps with quotes in them, such as `(foobar 'baz)'. I think this is something we can live with. The Info buffer fails to highlight properly when the Info file is produced from a correct Texinfo source... `(apply 'max numbers-list)' Using the patch, only `apply' is highlighted. That's what I reported too. I guess you are confirming this and also reporting that the Info text was correctly generated from Texinfo source. Yes, there is nothing wrong with the Info text -- the highlighting fails on it; that's all. There are also problems with @samp, which also puts single quotes around its arguments, as in `Symbol's function definition is void: this'. Only `Symbol' is highlighted. Yes, for the same reason. I guess you are also saying something about the mapping from Texinfo @samp. Again, there is nothing wrong with the Info text. The highlighting is not very smart, but it works most of the time. Note too that, in this case, it would in fact be more proper (from a doc point of view), to use double-quotes around the English expression that is being discussed -- and in that case the highlighting works as it should. I'm not saying that using @samp is wrong here; I'm just saying that in technical documentation double-quotes would normally be used here. FYI, here is the paragraph you cited, with double-quotes instead of single-quotes, as it would appear highlighted: The error message can be understood: "Symbol's function definition is void: this". The symbol (that is, the word `this') lacks instructions for the computer to carry out. Don't get me wrong -- I'm not suggesting that this Info text needs to be changed, or that any text should be changed just to fit the highlighting code! I'm simply saying: 1) yes, the highlighting code fails on text like this, 2) this particular text would perhaps be better using double-quotes, anyway (for reasons unrelated to highlighting), and 3) if the text used double-quotes there would be no highlighting problem here. Another common case that I reported on last night was backslashes between single-quotes, where the backslashes were not escaping anything. I've fixed the regexp to treat this, and have sent a new patch to the list (separately). Thanks for spending time on this and reporting carefully. - Drew [-- Attachment #1.2: Type: text/html, Size: 5318 bytes --] [-- Attachment #2: Type: text/plain, Size: 142 bytes --] _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: info faces for strings and quotations 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 ` (2 more replies) 1 sibling, 3 replies; 48+ messages in thread From: Juri Linkov @ 2004-10-07 5:53 UTC (permalink / raw) Cc: drew.adams, emacs-devel Apart from being a very useful feature, this also helps to find errors visually in Info manuals. For example, I noticed 1. one backquote missing in emacs-lisp-intro.texi: day alternative for the decision `if it is warm and sunny, then go to the beach, else read a book!''. which should be: day alternative for the decision ``if it is warm and sunny, then go to the beach, else read a book!''. 2. closing paren missing in calc.texi: -to a function are somehow of the wrong type (@cite{@t{tan}([2,3,4])}, +to a function are somehow of the wrong type (@cite{@t{tan}([2,3,4])}), 3. extra backslash in gnus.texi: - (any "mypackage@@somewhere\" - "bugs-mypackage" "mypkg.list") + (any "mypackage@@somewhere" - "bugs-mypackage" "mypkg.list") But OTOH, there are some places where it fails on legitimate constructs. Most serious cases I found where this feature completely fails are 1. (info "(eintr)else") with `"It's a tiger!"'; but when you evaluate `(type-of-animal 'zebra)', you will see `"It's not fierce!"'. 2. (info "(gnus)Group Parameters") where after the first quote on the line if address \"sender\" \"sieve-admin@extundo.com\" { the rest of the node is fontified in string face. While I think this feature is useful enough to be ON by default, expect a lot of bug reports unless these problems are fixed. -- Juri Linkov http://www.jurta.org/emacs/ ^ permalink raw reply [flat|nested] 48+ messages in thread
* RE: info faces for strings and quotations 2004-10-07 5:53 ` Juri Linkov @ 2004-10-07 6:53 ` Drew Adams 2004-10-07 14:58 ` Stefan Monnier 2004-10-08 0:33 ` Luc Teirlinck 2004-10-08 16:04 ` Richard Stallman 2 siblings, 1 reply; 48+ messages in thread From: Drew Adams @ 2004-10-07 6:53 UTC (permalink / raw) Cc: emacs-devel Regarding the two kinds of pb you mention: 1. I think the (sometimes) incorrect treatment of one or more single-quotes inside `...' is something we should not bother to try to fix. Attempts to do so will make for other pbs elsewhere. How can you know which is the quoted name to be highlighted here: xxx`yyy'zzz'www -- yyy'zzz or just yyy? Consider: - `foo' is George's plan... -- we should highlight foo - `(funcall 'foo)' is what I think -- we should highlight (funcall 'foo) Note: font-lock highlighting of even something as simple as `C-x 2' fails, because of the space. (Or, let's say it doesn't fail; it was designed to not highlight this.) 2. The pb of not interpreting " to begin a string if it is escaped (\") is no doubt fixable, at the risk of complicating the regexp. Suggested fixes welcome. Thanks, Drew -----Original Message-----From: Juri Linkov OTOH, there are some places where it fails on legitimate constructs. 1. `"It's a tiger!"'; but when you evaluate `(type-of-animal 'zebra)', you will see `"It's not fierce!"'. 2. if address \"sender\" \"sieve-admin@extundo.com\" { the rest of the node is fontified in string face. While I think this feature is useful enough to be ON by default, expect a lot of bug reports unless these problems are fixed. ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: info faces for strings and quotations 2004-10-07 6:53 ` Drew Adams @ 2004-10-07 14:58 ` Stefan Monnier 2004-10-07 15:13 ` David Kastrup 2004-10-07 15:13 ` Kim F. Storm 0 siblings, 2 replies; 48+ messages in thread From: Stefan Monnier @ 2004-10-07 14:58 UTC (permalink / raw) Cc: Juri Linkov, bob, emacs-devel > 2. The pb of not interpreting " to begin a string if it is escaped (\") is > no doubt fixable, at the risk of complicating the regexp. Suggested fixes > welcome. Prefix the regexp with "\\(^\\|[^\\]\\)\\(\\\\\\\\\\)*". The (match-end) of this regexp is guaranteed to not be preceded by an odd number of backspashes. You can find this regexp used by various major modes for comment-start-skip. Stefan ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: info faces for strings and quotations 2004-10-07 14:58 ` Stefan Monnier @ 2004-10-07 15:13 ` David Kastrup 2004-10-07 17:01 ` Stefan Monnier 2004-10-07 15:13 ` Kim F. Storm 1 sibling, 1 reply; 48+ messages in thread From: David Kastrup @ 2004-10-07 15:13 UTC (permalink / raw) Cc: Juri Linkov, bob, Drew Adams, emacs-devel Stefan Monnier <monnier@iro.umontreal.ca> writes: >> 2. The pb of not interpreting " to begin a string if it is escaped (\") is >> no doubt fixable, at the risk of complicating the regexp. Suggested fixes >> welcome. > > Prefix the regexp with "\\(^\\|[^\\]\\)\\(\\\\\\\\\\)*". The (match-end) of > this regexp is guaranteed to not be preceded by an odd number > of backspashes. > > You can find this regexp used by various major modes for comment-start-skip. If you don't need regexps, it is usually quite faster just to check with (zerop (mod (save-excursion (skip-chars-backward "\\\\")) 2)) whether you have an even number of preceding backslashes. -- David Kastrup, Kriemhildstr. 15, 44793 Bochum ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: info faces for strings and quotations 2004-10-07 15:13 ` David Kastrup @ 2004-10-07 17:01 ` Stefan Monnier 2004-10-08 5:13 ` Drew Adams 0 siblings, 1 reply; 48+ messages in thread From: Stefan Monnier @ 2004-10-07 17:01 UTC (permalink / raw) Cc: Juri Linkov, bob, Drew Adams, emacs-devel > If you don't need regexps, it is usually quite faster just to check with > (zerop (mod (save-excursion (skip-chars-backward "\\\\")) 2)) whether you > have an even number of preceding backslashes. That's true. The "\\(^\\|[^\\]\\)\\(\\\\\\\\\\)*" prefix can slow down regexp searching significantly. Stefan ^ permalink raw reply [flat|nested] 48+ messages in thread
* RE: info faces for strings and quotations 2004-10-07 17:01 ` Stefan Monnier @ 2004-10-08 5:13 ` Drew Adams 0 siblings, 0 replies; 48+ messages in thread From: Drew Adams @ 2004-10-08 5:13 UTC (permalink / raw) [-- Attachment #1: Type: text/plain, Size: 3022 bytes --] This version works well. The fontify function is in line below; the full patch is attached. This seems to do everything the previous version did, plus treat initial \" correctly. Things like this from (ccmode)Indentation Functions are not highlighted now, which is the correct behavior: (\"Hello world!\"); Thanks to everyone who contributed suggestions. I went with David's suggestion for treating initial \". Per Luc's suggestion, I added a note to the doc string of `Info-fontify-quotations-flag' explaining that fontification can never be 100% reliable, that occasional inappropriate highlighting is not a bug, and that highlighting can be turned off. It is now off by default. I won't be working any more on this. I think it is ready for prime time, and I hope the decision will be to add it to Emacs. BTW, with this highlighting, I noticed these additional Info text bugs (the first one I had noticed earlier, but forgot to point out): - (eintr)the-the -- "the' should be "the" - (gnus)Fancy Mail Splitting: (any "mypackage@somewhere\" - "bugs-mypackage" "mypkg.list") -- I'm guessing that the backslash doesn't belong here. - (elisp)Specification List -- `(spec . [(more specs...)])') -- ' is in wrong place. - Drew ;; 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))))) -----Original Message-----From: Stefan, quoting David, replying to Stefan > If you don't need regexps, it is usually quite faster just to check with > (zerop (mod (save-excursion (skip-chars-backward "\\\\")) 2)) whether you > have an even number of preceding backslashes. That's true. The "\\(^\\|[^\\]\\)\\(\\\\\\\\\\)*" prefix can slow down regexp searching significantly. [-- Attachment #2: diff-info-highlight-quotations-fourth.txt --] [-- Type: text/plain, Size: 4215 bytes --] 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)))) \f ;; 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))))) \f ;; When an Info buffer is killed, make sure the associated tags buffer [-- Attachment #3: Type: text/plain, Size: 142 bytes --] _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: info faces for strings and quotations 2004-10-07 14:58 ` Stefan Monnier 2004-10-07 15:13 ` David Kastrup @ 2004-10-07 15:13 ` Kim F. Storm 2004-10-07 16:35 ` David Kastrup 1 sibling, 1 reply; 48+ messages in thread From: Kim F. Storm @ 2004-10-07 15:13 UTC (permalink / raw) Cc: Juri Linkov, bob, Drew Adams, emacs-devel Stefan Monnier <monnier@iro.umontreal.ca> writes: >> 2. The pb of not interpreting " to begin a string if it is escaped (\") is >> no doubt fixable, at the risk of complicating the regexp. Suggested fixes >> welcome. > > Prefix the regexp with "\\(^\\|[^\\]\\)\\(\\\\\\\\\\)*". The (match-end) of > this regexp is guaranteed to not be preceded by an odd number > of backspashes. Wouldn't it be fairly trivial to enhance regex to recognize something like \\\{0,e} meaning an even (possibly zero) number of \'es. (likewise for \{0,o}, meaning an odd number of (or no) \'es ) -- Kim F. Storm <storm@cua.dk> http://www.cua.dk ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: info faces for strings and quotations 2004-10-07 15:13 ` Kim F. Storm @ 2004-10-07 16:35 ` David Kastrup 0 siblings, 0 replies; 48+ messages in thread From: David Kastrup @ 2004-10-07 16:35 UTC (permalink / raw) Cc: Juri Linkov, bob, Stefan Monnier, Drew Adams, emacs-devel storm@cua.dk (Kim F. Storm) writes: > Stefan Monnier <monnier@iro.umontreal.ca> writes: > >>> 2. The pb of not interpreting " to begin a string if it is escaped (\") is >>> no doubt fixable, at the risk of complicating the regexp. Suggested fixes >>> welcome. >> >> Prefix the regexp with "\\(^\\|[^\\]\\)\\(\\\\\\\\\\)*". The (match-end) of >> this regexp is guaranteed to not be preceded by an odd number >> of backspashes. > > Wouldn't it be fairly trivial to enhance regex to recognize something like > > \\\{0,e} > > meaning an even (possibly zero) number of \'es. > > (likewise for \{0,o}, meaning an odd number of (or no) \'es ) That's too ad-hoc. Rather use \{0,,2} and \{1,,2}. Anyway, it does not buy much that I can see here: you still need to make sure that there is no leading \ before the expression in question. -- David Kastrup, Kriemhildstr. 15, 44793 Bochum ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: info faces for strings and quotations 2004-10-07 5:53 ` Juri Linkov 2004-10-07 6:53 ` Drew Adams @ 2004-10-08 0:33 ` Luc Teirlinck 2004-10-08 16:04 ` Richard Stallman 2 siblings, 0 replies; 48+ messages in thread From: Luc Teirlinck @ 2004-10-08 0:33 UTC (permalink / raw) Cc: bob, drew.adams, emacs-devel Juri Linkov wrote: But OTOH, there are some places where it fails on legitimate constructs. That is unavoidable. Info files do not contain enough information to do the job reliably. The .texi source files do but using the .texi files is taboo, because it would not allow the Texinfo language to change independently of Emacs. The XML output format does. Oliver Scholz is working on that. While I think this feature is useful enough to be ON by default, expect a lot of bug reports unless these problems are fixed. That is exactly why the feature should not only be off by default, but that in addition the user should be told that the feature does not aim for perfection and occasionally can result in anomalous fontification. The user has to know that these problems are a known and unavoidable consequence of the heuristic, as opposed to fixable bugs, and that filing a bug report would be futile. The user should know that if he is not willing to live with these problems, he should simply not turn the feature on. Sincerely, Luc. ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: info faces for strings and quotations 2004-10-07 5:53 ` Juri Linkov 2004-10-07 6:53 ` Drew Adams 2004-10-08 0:33 ` Luc Teirlinck @ 2004-10-08 16:04 ` Richard Stallman 2004-10-08 16:51 ` Luc Teirlinck 2004-10-08 20:00 ` Robert J. Chassell 2 siblings, 2 replies; 48+ messages in thread From: Richard Stallman @ 2004-10-08 16:04 UTC (permalink / raw) Cc: bob, drew.adams, emacs-devel Apart from being a very useful feature, this also helps to find errors visually in Info manuals. Thanks for noticing--will you fix them? But OTOH, there are some places where it fails on legitimate constructs. Most serious cases I found where this feature completely fails are 1. (info "(eintr)else") with `"It's a tiger!"'; but when you evaluate `(type-of-animal 'zebra)', you will see `"It's not fierce!"'. What Texinfo code generates that? It looks like someone put @samp around a Lisp string constant. If so, that is incorrect usage; it should be @code, not @samp. ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: info faces for strings and quotations 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 1 sibling, 1 reply; 48+ messages in thread From: Luc Teirlinck @ 2004-10-08 16:51 UTC (permalink / raw) Cc: juri, bob, drew.adams, emacs-devel Richard Stallman wrote: 1. (info "(eintr)else") with `"It's a tiger!"'; but when you evaluate `(type-of-animal 'zebra)', you will see `"It's not fierce!"'. What Texinfo code generates that? It looks like someone put @samp around a Lisp string constant. If so, that is incorrect usage; it should be @code, not @samp. That text _is_ already in @code. Juri apparently cut and pasted that from an *info* buffer. It is impossible to tell from a .info file whether `abc' was produced by @code{abc} or @samp{abc}. You can see the difference if you view the dvi output. Sincerely, Luc. ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: info faces for strings and quotations 2004-10-08 16:51 ` Luc Teirlinck @ 2004-10-09 15:45 ` Richard Stallman 0 siblings, 0 replies; 48+ messages in thread From: Richard Stallman @ 2004-10-09 15:45 UTC (permalink / raw) Cc: juri, bob, drew.adams, emacs-devel That text _is_ already in @code. I was misremembering the difference, sorry. ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: info faces for strings and quotations 2004-10-08 16:04 ` Richard Stallman 2004-10-08 16:51 ` Luc Teirlinck @ 2004-10-08 20:00 ` Robert J. Chassell 1 sibling, 0 replies; 48+ messages in thread From: Robert J. Chassell @ 2004-10-08 20:00 UTC (permalink / raw) Apart from being a very useful feature, this also helps to find errors visually in Info manuals. Thanks for noticing--will you fix them? I already fixed the typos in the intro. It is a useful tool for that. `"It's a tiger!"'; but when you evaluate `(type-of-animal 'zebra)', you will see `"It's not fierce!"'. What Texinfo code generates that? It looks like someone put @samp around a Lisp string constant. If so, that is incorrect usage; it should be @code, not @samp. It is @code. That is what makeinfo produces for Info. In a Web browser such as Emacs W3, Emacs W3M, or Firefox, or when printed, you see only the double quotes. -- Robert J. Chassell bob@rattlesnake.com GnuPG Key ID: 004B4AC8 http://www.rattlesnake.com http://www.teak.cc ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: info faces for strings and quotations 2004-10-06 7:07 ` Drew Adams 2004-10-06 17:07 ` Robert J. Chassell @ 2004-10-07 5:57 ` Juri Linkov 2004-10-07 15:22 ` w3 mode Camm Maguire 2004-10-07 15:28 ` unexec development Camm Maguire 3 siblings, 0 replies; 48+ messages in thread From: Juri Linkov @ 2004-10-07 5:57 UTC (permalink / raw) Cc: lennart.borgman.073, teirllm, monnier, emacs-devel "Drew Adams" <drew.adams@oracle.com> writes: > EMACS FAQ -- several nodes have `...' or "..." in node titles. These are > highlighted. > > WIDGET -- several nodes have `...' in titles > > REFTEX -- node fancyref (LaTeX package): `fancyref' in title highlighted 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. -- Juri Linkov http://www.jurta.org/emacs/ ^ permalink raw reply [flat|nested] 48+ messages in thread
* w3 mode 2004-10-06 7:07 ` Drew Adams 2004-10-06 17:07 ` Robert J. Chassell 2004-10-07 5:57 ` Juri Linkov @ 2004-10-07 15:22 ` Camm Maguire 2004-10-07 17:03 ` Stefan Monnier 2004-10-08 16:05 ` Richard Stallman 2004-10-07 15:28 ` unexec development Camm Maguire 3 siblings, 2 replies; 48+ messages in thread From: Camm Maguire @ 2004-10-07 15:22 UTC (permalink / raw) Greetings! Before getting into the details, I notice in general that w3 mode works much better in xemacs. Is this generally known, or do I have a problem in my local setup? Take care, -- Camm Maguire camm@enhanced.com ========================================================================== "The earth is but one country, and mankind its citizens." -- Baha'u'llah ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: w3 mode 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-08 16:05 ` Richard Stallman 1 sibling, 1 reply; 48+ messages in thread From: Stefan Monnier @ 2004-10-07 17:03 UTC (permalink / raw) Cc: emacs-devel > Greetings! Before getting into the details, I notice in general that > w3 mode works much better in xemacs. Is this generally known, or do I > have a problem in my local setup? IIRC W3 was developed on XEmacs (Emacs didn't have image support at that time), so it's no surprise it works better there, especially since there hasn't been much work put into W3 development recently (e.g. since Emacs provides support for images). Stefan ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: w3 mode 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 0 siblings, 2 replies; 48+ messages in thread From: Camm Maguire @ 2004-10-07 17:25 UTC (permalink / raw) Cc: emacs-devel Greetings, and thanks for the reply! So I take it that no one is actively working on this, or some other web mode, for GNU emacs at present? Just wondering. Take care, Stefan Monnier <monnier@iro.umontreal.ca> writes: > > Greetings! Before getting into the details, I notice in general that > > w3 mode works much better in xemacs. Is this generally known, or do I > > have a problem in my local setup? > > IIRC W3 was developed on XEmacs (Emacs didn't have image support at that > time), so it's no surprise it works better there, especially since there > hasn't been much work put into W3 development recently (e.g. since Emacs > provides support for images). > > > Stefan > > > -- Camm Maguire camm@enhanced.com ========================================================================== "The earth is but one country, and mankind its citizens." -- Baha'u'llah ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: w3 mode 2004-10-07 17:25 ` Camm Maguire @ 2004-10-07 17:37 ` Mark Plaksin 2004-10-07 17:45 ` Kevin Rodgers 1 sibling, 0 replies; 48+ messages in thread From: Mark Plaksin @ 2004-10-07 17:37 UTC (permalink / raw) Camm Maguire <camm@enhanced.com> writes: > Greetings, and thanks for the reply! > > So I take it that no one is actively working on this, or some other > web mode, for GNU emacs at present? Just wondering. Emacs-w3m is a nice web browser for Emacs. It uses w3m. http://emacs-w3m.namazu.org/ ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: w3 mode 2004-10-07 17:25 ` Camm Maguire 2004-10-07 17:37 ` Mark Plaksin @ 2004-10-07 17:45 ` Kevin Rodgers 1 sibling, 0 replies; 48+ messages in thread From: Kevin Rodgers @ 2004-10-07 17:45 UTC (permalink / raw) Camm Maguire wrote: > So I take it that no one is actively working on this, or some other > web mode, for GNU emacs at present? Just wondering. Definitely not; http://emacs-w3m.namazu.org/ -- Kevin Rodgers ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: w3 mode 2004-10-07 15:22 ` w3 mode Camm Maguire 2004-10-07 17:03 ` Stefan Monnier @ 2004-10-08 16:05 ` Richard Stallman 2004-10-08 17:44 ` David Kastrup 1 sibling, 1 reply; 48+ messages in thread From: Richard Stallman @ 2004-10-08 16:05 UTC (permalink / raw) Cc: emacs-devel Greetings! Before getting into the details, I notice in general that w3 mode works much better in xemacs. That is so vague that it cannot be of any help. If you state a specific behavior that you don't like, maybe we can improve it. ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: w3 mode 2004-10-08 16:05 ` Richard Stallman @ 2004-10-08 17:44 ` David Kastrup 0 siblings, 0 replies; 48+ messages in thread From: David Kastrup @ 2004-10-08 17:44 UTC (permalink / raw) Cc: Camm Maguire, emacs-devel Richard Stallman <rms@gnu.org> writes: > Greetings! Before getting into the details, I notice in general that > w3 mode works much better in xemacs. > > That is so vague that it cannot be of any help. > If you state a specific behavior that you don't like, > maybe we can improve it. For what value of "we"? AFAIR, w3 development is pretty stalled, and code that deals with Emacs-21 images is more or less just present in the CVS version (available from Savannah), maybe in the last unofficial tarball as well. Since w3 does not appear to be developed actively any more, it is unclear who could do just what about the situation, and why. -- David Kastrup, Kriemhildstr. 15, 44793 Bochum ^ permalink raw reply [flat|nested] 48+ messages in thread
* unexec development 2004-10-06 7:07 ` Drew Adams ` (2 preceding siblings ...) 2004-10-07 15:22 ` w3 mode Camm Maguire @ 2004-10-07 15:28 ` Camm Maguire 2004-10-15 14:10 ` Camm Maguire 3 siblings, 1 reply; 48+ messages in thread From: Camm Maguire @ 2004-10-07 15:28 UTC (permalink / raw) Cc: gcl-devel Greetings! Currently, GCL and programs built on top of it (maxima,acl2,axiom), use emacs' unexec by default to save intermediary and final system images. Compiled code is loaded and relocated dynamically at runtime, stored in an expanding .data section via sbrk, and finally dumped with unexec. I would like to extend this functionality if possible to include compiled code which references symbols in external shared libs opened again dynamically at runtime via dlopen. Loading and relocating is straightforward, but somehow I'd need to have unexec write a new relocation record into the final image for each symbol for use by ld.so. Does this sound of interest to emacs too? Does this trigger any ideas as to a possibly better approach? Take care, -- Camm Maguire camm@enhanced.com ========================================================================== "The earth is but one country, and mankind its citizens." -- Baha'u'llah ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: unexec development 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-16 13:52 ` Richard Stallman 0 siblings, 2 replies; 48+ messages in thread From: Camm Maguire @ 2004-10-15 14:10 UTC (permalink / raw) Cc: gcl-devel Greetings! Just another ping on this issue. Is anyone working on unexec anymore? Does anyone have interest in doing so? Take care, Camm Maguire <camm@enhanced.com> writes: > Greetings! Currently, GCL and programs built on top of it > (maxima,acl2,axiom), use emacs' unexec by default to save intermediary > and final system images. Compiled code is loaded and relocated > dynamically at runtime, stored in an expanding .data section via sbrk, > and finally dumped with unexec. > > I would like to extend this functionality if possible to include > compiled code which references symbols in external shared libs opened > again dynamically at runtime via dlopen. Loading and relocating is > straightforward, but somehow I'd need to have unexec write a > new relocation record into the final image for each symbol for use by > ld.so. > > Does this sound of interest to emacs too? Does this trigger any ideas > as to a possibly better approach? > > Take care, > -- > Camm Maguire camm@enhanced.com > ========================================================================== > "The earth is but one country, and mankind its citizens." -- Baha'u'llah > > > _______________________________________________ > Emacs-devel mailing list > Emacs-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-devel > > > -- Camm Maguire camm@enhanced.com ========================================================================== "The earth is but one country, and mankind its citizens." -- Baha'u'llah ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: unexec development 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 1 sibling, 1 reply; 48+ messages in thread From: Jan D. @ 2004-10-15 14:35 UTC (permalink / raw) Cc: gcl-devel, emacs-devel > Greetings! Just another ping on this issue. Is anyone working on > unexec anymore? Does anyone have interest in doing so? > Can you describe what the benefits for Emacs would be? Or why you want this. Jan D. > Camm Maguire <camm@enhanced.com> writes: > >> Greetings! Currently, GCL and programs built on top of it >> (maxima,acl2,axiom), use emacs' unexec by default to save intermediary >> and final system images. Compiled code is loaded and relocated >> dynamically at runtime, stored in an expanding .data section via sbrk, >> and finally dumped with unexec. >> >> I would like to extend this functionality if possible to include >> compiled code which references symbols in external shared libs opened >> again dynamically at runtime via dlopen. Loading and relocating is >> straightforward, but somehow I'd need to have unexec write a >> new relocation record into the final image for each symbol for use by >> ld.so. >> >> Does this sound of interest to emacs too? Does this trigger any ideas >> as to a possibly better approach? >> >> Take care, >> -- >> Camm Maguire camm@enhanced.com >> ====================================================================== >> ==== >> "The earth is but one country, and mankind its citizens." -- >> Baha'u'llah >> >> >> _______________________________________________ >> Emacs-devel mailing list >> Emacs-devel@gnu.org >> http://lists.gnu.org/mailman/listinfo/emacs-devel >> >> >> > > -- > Camm Maguire camm@enhanced.com > ======================================================================= > === > "The earth is but one country, and mankind its citizens." -- > Baha'u'llah > > > _______________________________________________ > Emacs-devel mailing list > Emacs-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-devel ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: Re: unexec development 2004-10-15 14:35 ` Jan D. @ 2004-10-15 21:11 ` Camm Maguire 0 siblings, 0 replies; 48+ messages in thread From: Camm Maguire @ 2004-10-15 21:11 UTC (permalink / raw) Cc: gcl-devel, emacs-devel Greetings, and thanks for your reply! "Jan D." <jan.h.d@swipnet.se> writes: > > Greetings! Just another ping on this issue. Is anyone working on > > unexec anymore? Does anyone have interest in doing so? > > > > Can you describe what the benefits for Emacs would be? Or why you > want this. > Well, the benefits for emacs might not accrue in the immediate future. To my very limited understanding, emacs only byte-compiles code loaded into and executed from its heap. GCL can compile, load, and execute native code this way. In principle at least, emacs might want to do likewise at some point in the future for performance reasons. I agree it is far from pressing. But the GCL compiler is written in lisp and probably would work for emacs without too much work. In such a setup, it makes sense that a user might want to compile and load code into their heap which references external functions in shared libraries which could be dlopened at runtime. All is well until the unexec, when the mapping from the heap to the dlopened shared library is lost, as the start address of the latter is not reliable.. Perhaps one might say to just relink by hand when the saved image is restarted. This is indeed a possibility. But at least in the case of gcl, this cycle of compile,load,save,restart occurs many times in the course of building a particular application. There should be no reason we couldn't push the relinking work onto ld.so, with the added advantage that the binary could be prelinked and thus accelerated at the end. Doing this in GCL would be to essentially duplicate the functionality of ld.so. As an aside, I notice that even without this, gcl images cannot be prel at present, and I assume the same is for emacs, as the images are formed by unexec. This must be related to the lack of initialization of some elf section I'd think. Something else that could be addressed at the same time. Take care, > Jan D. > > > Camm Maguire <camm@enhanced.com> writes: > > > >> Greetings! Currently, GCL and programs built on top of it > >> (maxima,acl2,axiom), use emacs' unexec by default to save intermediary > >> and final system images. Compiled code is loaded and relocated > >> dynamically at runtime, stored in an expanding .data section via sbrk, > >> and finally dumped with unexec. > >> > >> I would like to extend this functionality if possible to include > >> compiled code which references symbols in external shared libs opened > >> again dynamically at runtime via dlopen. Loading and relocating is > >> straightforward, but somehow I'd need to have unexec write a > >> new relocation record into the final image for each symbol for use by > >> ld.so. > >> > >> Does this sound of interest to emacs too? Does this trigger any ideas > >> as to a possibly better approach? > >> > >> Take care, > >> -- > >> Camm Maguire camm@enhanced.com > >> ====================================================================== > >> ==== > >> "The earth is but one country, and mankind its citizens." -- > >> Baha'u'llah > >> > >> > >> _______________________________________________ > >> Emacs-devel mailing list > >> Emacs-devel@gnu.org > >> http://lists.gnu.org/mailman/listinfo/emacs-devel > >> > >> > >> > > > > -- > > Camm Maguire camm@enhanced.com > > ======================================================================= > > === > > "The earth is but one country, and mankind its citizens." -- > > Baha'u'llah > > > > > > _______________________________________________ > > Emacs-devel mailing list > > Emacs-devel@gnu.org > > http://lists.gnu.org/mailman/listinfo/emacs-devel > > > > _______________________________________________ > Gcl-devel mailing list > Gcl-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/gcl-devel > > > -- Camm Maguire camm@enhanced.com ========================================================================== "The earth is but one country, and mankind its citizens." -- Baha'u'llah ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: unexec development 2004-10-15 14:10 ` Camm Maguire 2004-10-15 14:35 ` Jan D. @ 2004-10-16 13:52 ` Richard Stallman 1 sibling, 0 replies; 48+ messages in thread From: Richard Stallman @ 2004-10-16 13:52 UTC (permalink / raw) Cc: gcl-devel, emacs-devel We're not doing any work to extend unexec for Emacs's sake. However, it would not be objectionable to extend it for GCL's sake. ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: info faces for strings and quotations 2004-10-06 2:25 ` Luc Teirlinck 2004-10-06 4:19 ` Drew Adams @ 2004-10-06 8:44 ` Oliver Scholz 1 sibling, 0 replies; 48+ messages in thread From: Oliver Scholz @ 2004-10-06 8:44 UTC (permalink / raw) Cc: lennart.borgman.073, monnier, emacs-devel Luc Teirlinck <teirllm@dms.auburn.edu> writes: [...] > Info files are essentially plain text with some minimal markup that is > intended for navigation, not highlighting. So I believe that there is > no way that one can do what you are trying to do completely reliably > any more than that it is possible to implement > Info-hide-note-references completely reliably. To do that, one would > need to base the Emacs Info reader on the XML output format instead of > on the Info output format. Indeed. You need more information in the markup to do this in a reliable way. (A side effect of this would be that you can also use font-lock for code examples.) > (Maybe somebody might actually do that some day.) There was another longish thread on this issue here about a year ago, in which I participated extensively. Well, this is about rendering XML ... I regard it as part of the word processing framework. The half-finished XML parser with which I am working (an implementation of SSAX in Elisp) is written with rendering info XML in mind in that it allows for partial on-demand parsing (which is necessary for files as large as the Emacs manual). Oliver -- Oliver Scholz 15 Vendémiaire an 213 de la Révolution Ostendstr. 61 Liberté, Egalité, Fraternité! 60314 Frankfurt a. M. ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: info faces for strings and quotations 2004-10-05 16:11 ` Drew Adams 2004-10-06 2:25 ` Luc Teirlinck @ 2004-10-07 5:55 ` Juri Linkov 2004-10-07 7:13 ` Drew Adams 1 sibling, 1 reply; 48+ messages in thread From: Juri Linkov @ 2004-10-07 5:55 UTC (permalink / raw) Cc: lennart.borgman.073, monnier, emacs-devel "Drew Adams" <drew.adams@oracle.com> writes: > In most Info files, `...' is used to identify commands, key > sequences, filenames and the like; "..." is used (usually) to > identify strings in code. I found that not highlighting the > single-quotes and highlighting the double-quotes improved > readability. I guess this is the same reason why in programming modes like Emacs Lisp mode single-quotes are not highlighted while double-quotes are. 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) -- Juri Linkov http://www.jurta.org/emacs/ ^ permalink raw reply [flat|nested] 48+ messages in thread
* RE: info faces for strings and quotations 2004-10-07 5:55 ` Juri Linkov @ 2004-10-07 7:13 ` Drew Adams 0 siblings, 0 replies; 48+ messages in thread From: Drew Adams @ 2004-10-07 7:13 UTC (permalink / raw) Cc: lennart.borgman.073, monnier, emacs-devel [-- 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 ^ permalink raw reply [flat|nested] 48+ messages in thread
* Re: info faces for strings and quotations
@ 2004-10-05 16:15 LENNART BORGMAN
2004-10-05 16:28 ` Drew Adams
0 siblings, 1 reply; 48+ messages in thread
From: LENNART BORGMAN @ 2004-10-05 16:15 UTC (permalink / raw)
Cc: Drew Adams, Emacs-Devel
----- Original Message -----
From: Stefan <monnier@iro.umontreal.ca>
Date: Tuesday, October 5, 2004 1:56 pm
Subject: Re: info faces for strings and quotations
> Why not use (either-re "\"\\([^\\\"]\\|\\\\[\\\"]\\)*\"\\|`[^'\n]+'")
> and get rid of all this code (i.e. the regexp-matching does the
> escape-counting for you)?
I have never heard of either-re, is that something in the CVS-version?
I did not notice match-beginning/end, thanks!
- Lennart
^ permalink raw reply [flat|nested] 48+ messages in thread
* RE: info faces for strings and quotations 2004-10-05 16:15 LENNART BORGMAN @ 2004-10-05 16:28 ` Drew Adams 0 siblings, 0 replies; 48+ messages in thread From: Drew Adams @ 2004-10-05 16:28 UTC (permalink / raw) Cc: Emacs-Devel `either-re' was just my renamed version of your variable `rr'. I was trying to make the name say what the regexp represented. - Drew -----Original Message----- From: LENNART BORGMAN [mailto:lennart.borgman.073@student.lu.se] > Why not use (either-re "\"\\([^\\\"]\\|\\\\[\\\"]\\)*\"\\|`[^'\n]+'") > and get rid of all this code (i.e. the regexp-matching does the > escape-counting for you)? I have never heard of either-re, is that something in the CVS-version? ^ permalink raw reply [flat|nested] 48+ messages in thread
end of thread, other threads:[~2004-10-16 13:52 UTC | newest] Thread overview: 48+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 -- strict thread matches above, loose matches on Subject: below -- 2004-10-05 16:15 LENNART BORGMAN 2004-10-05 16:28 ` Drew Adams
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.