* Re: How do I setup an extremely simple font-lock mode? [not found] <mailman.6614.1053651042.21513.help-gnu-emacs@gnu.org> @ 2003-05-23 15:03 ` Stefan Monnier 2003-05-23 15:05 ` Stefan Monnier 0 siblings, 1 reply; 9+ messages in thread From: Stefan Monnier @ 2003-05-23 15:03 UTC (permalink / raw) >>>>> "Matt" == Matt Noel <mgn000@mac.com> writes: > (defun pta-mode () > (setq font-lock-defaults '(pta-font-lock-keywords)) > ) Please make it (define-derived-mode pta-mode "PTA" "Major mode to edit PTA logs." (set (make-local-variable 'font-lock-defaults) '(pta-font-lock-keywords))) otherwise, global-font-lock-mode might not work as expected. Stefan ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How do I setup an extremely simple font-lock mode? 2003-05-23 15:03 ` How do I setup an extremely simple font-lock mode? Stefan Monnier @ 2003-05-23 15:05 ` Stefan Monnier 0 siblings, 0 replies; 9+ messages in thread From: Stefan Monnier @ 2003-05-23 15:05 UTC (permalink / raw) Oops... > (define-derived-mode pta-mode "PTA" ^ fundamental-mode > "Major mode to edit PTA logs." > (set (make-local-variable 'font-lock-defaults) > '(pta-font-lock-keywords))) Sorry about this missing argument. Stefan ^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <mailman.6601.1053636524.21513.help-gnu-emacs@gnu.org>]
* Re: How do I setup an extremely simple font-lock mode? [not found] <mailman.6601.1053636524.21513.help-gnu-emacs@gnu.org> @ 2003-05-22 23:58 ` Alex Schroeder 2003-05-23 13:50 ` Barman Brakjoller 2003-05-23 15:02 ` kgold 2 siblings, 0 replies; 9+ messages in thread From: Alex Schroeder @ 2003-05-22 23:58 UTC (permalink / raw) Matt Noel <mgn000@mac.com> writes: > I want to setup a very simple mode for colorizing a log file. All I > need to do is highlight any lines with the string ERROR on them. I've > tried reading the documentation for font-lock but it's not clear how > to do this. > > Could someone point me to a simple example, or send one? See http://www.emacswiki.org/cgi-bin/wiki.pl?CategoryCode -- it has the following section: How to start writing a new major mode: * GenericMode -- for very simple modes including font-locking and comments * DerivedMode -- for new modes very similar to existing modes * SampleMode -- complete elisp example for a real major mode * ModeTutorial -- a tutorial for mode writers Alex. -- http://www.emacswiki.org/cgi-bin/alex.pl ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How do I setup an extremely simple font-lock mode? [not found] <mailman.6601.1053636524.21513.help-gnu-emacs@gnu.org> 2003-05-22 23:58 ` Alex Schroeder @ 2003-05-23 13:50 ` Barman Brakjoller 2003-05-23 15:02 ` kgold 2 siblings, 0 replies; 9+ messages in thread From: Barman Brakjoller @ 2003-05-23 13:50 UTC (permalink / raw) > I want to setup a very simple mode for colorizing a log file. All I > need to do is highlight any lines with the string ERROR on them. I've > tried reading the documentation for font-lock but it's not clear how to > do this. Maybe this is not exacly what you asked for, but to me it seems as if it will solve your problem. From the NEWS file, section Emacs 21.1 changes: *** The new package hi-lock.el provides commands to highlight matches of interactively entered regexps. For example, M-x highlight-regexp RET clearly RET RET will highlight all occurrences of `clearly' using a yellow background face. New occurrences of `clearly' will be highlighted as they are typed. `M-x unhighlight-regexp RET' will remove the highlighting. Any existing face can be used for highlighting and a set of appropriate faces is provided. The regexps can be written into the current buffer in a form that will be recognized the next time the corresponding file is read. There are commands to highlight matches to phrases and to highlight entire lines containing a match. Hope it works for you! ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How do I setup an extremely simple font-lock mode? [not found] <mailman.6601.1053636524.21513.help-gnu-emacs@gnu.org> 2003-05-22 23:58 ` Alex Schroeder 2003-05-23 13:50 ` Barman Brakjoller @ 2003-05-23 15:02 ` kgold 2003-05-23 15:24 ` Bryan W. Lepore 2 siblings, 1 reply; 9+ messages in thread From: kgold @ 2003-05-23 15:02 UTC (permalink / raw) Matt Noel <mgn000@mac.com> writes: > I want to setup a very simple mode for colorizing a log file. All I > need to do is highlight any lines with the string ERROR on them. I've > tried reading the documentation for font-lock but it's not clear how to > do this. Related question. I use log4j as a Java logger. It prefixes each line with DEBUG: INFO: ERROR: WARN: FATAL: Is there a "log4j" mode which colorizes these. -- -- Ken Goldman kgold@watson.ibm.com 914-784-7646 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How do I setup an extremely simple font-lock mode? 2003-05-23 15:02 ` kgold @ 2003-05-23 15:24 ` Bryan W. Lepore 0 siblings, 0 replies; 9+ messages in thread From: Bryan W. Lepore @ 2003-05-23 15:24 UTC (permalink / raw) Cc: help-gnu-emacs i took some lisp from a former lab member and added in particular things - you can see an example on http://people.brandeis.edu/~lepore/dotemacs -bryan ___________________________________________________________________________ Bryan Lepore Brandeis University Petsko/Ringe Laboratory Rosenstiel Basic Medical Sciences Research Center Floor Six MS029 Waltham, MA 02454 http://people.brandeis.edu/~lepore ___________________________________________________________________________ On 23 May 2003, kgold wrote: > > Matt Noel <mgn000@mac.com> writes: > > I want to setup a very simple mode for colorizing a log file. All I > > need to do is highlight any lines with the string ERROR on them. I've > > tried reading the documentation for font-lock but it's not clear how to > > do this. > > Related question. I use log4j as a Java logger. It prefixes each line with > DEBUG: > INFO: > ERROR: > WARN: > FATAL: > Is there a "log4j" mode which colorizes these. > > -- > -- > Ken Goldman kgold@watson.ibm.com 914-784-7646 > _______________________________________________ > Help-gnu-emacs mailing list > Help-gnu-emacs@gnu.org > http://mail.gnu.org/mailman/listinfo/help-gnu-emacs > ^ permalink raw reply [flat|nested] 9+ messages in thread
* How do I setup an extremely simple font-lock mode? @ 2003-05-22 20:47 Matt Noel 2003-05-22 21:11 ` myrkraverk 0 siblings, 1 reply; 9+ messages in thread From: Matt Noel @ 2003-05-22 20:47 UTC (permalink / raw) I want to setup a very simple mode for colorizing a log file. All I need to do is highlight any lines with the string ERROR on them. I've tried reading the documentation for font-lock but it's not clear how to do this. Could someone point me to a simple example, or send one? Thanks. Matt Noel mgn000@yahoo.com or mgn000@mac.com ^ permalink raw reply [flat|nested] 9+ messages in thread
* How do I setup an extremely simple font-lock mode? 2003-05-22 20:47 Matt Noel @ 2003-05-22 21:11 ` myrkraverk 2003-05-23 0:48 ` Matt Noel 0 siblings, 1 reply; 9+ messages in thread From: myrkraverk @ 2003-05-22 21:11 UTC (permalink / raw) Cc: help-gnu-emacs Hi, Matt Noel writes: > I want to setup a very simple mode for colorizing a log file. All I > need to do is highlight any lines with the string ERROR on them. I've > tried reading the documentation for font-lock but it's not clear how to > do this. > > Could someone point me to a simple example, or send one? Here is an example, it doesn't though specify how you use the mode on the log file. Maybe you can edit it to suit your need. ;; This is basically a list of lists with a regular expression and ;; then the font name (or face name). The numbers below refer to \\( ;; ... \\) constructs that mark what part of the re you want ;; highlighted (defconst masp-font-lock-keywords '(("^\\(\\(\\sw\\|\\s_\\)+\\)\\>:?[ \t]*\\(\\sw+\\(\\.[lLwWbBsS]\\)?\\)?" (1 font-lock-function-name-face) (3 font-lock-keyword-face nil t)) ("^\\s +\\(\\(\\sw\\|\\s_\\)+\\(\\.[lLwWbBsS]\\)?\\)" 1 font-lock-keyword-face) ("^\\(\\s-+\\|\\sw+:\\s-+\\)\\(\\\\[a-zA-Z0-9]+\\)" (2 font-lock-constant-face)) ("\\(\\\\\\sw+\\)" (1 font-lock-variable-name-face))) "Additional expressions to highlight in Assembler mode.") (defun masp-mode () ;;... (setq font-lock-defaults '(masp-font-lock-keywords)) ;;... ) Hope this helps, Johann -- This line is left blank intentionally ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: How do I setup an extremely simple font-lock mode? 2003-05-22 21:11 ` myrkraverk @ 2003-05-23 0:48 ` Matt Noel 0 siblings, 0 replies; 9+ messages in thread From: Matt Noel @ 2003-05-23 0:48 UTC (permalink / raw) [-- Attachment #1.1: Type: text/plain, Size: 2424 bytes --] Thanks Johann, if it's of any help to others, here's what I settled on: I made a file named pta-mode.py in my emacs directory, where I keep other lisp files, and put this in it: ;; This is basically a list of lists with a regular expression and ;; then the font name (or face name). The numbers below refer to \\( ;; ... \\) constructs that mark what part of the re you want ;; highlighted (defconst pta-font-lock-keywords '( ("- \\(ERROR\\) - \\w*\\(.*\\)" (1 font-lock-warning-face) (2 font-lock-comment-face)) ("- \\(WARN\\) - \\w*\\(.*\\)" (1 font-lock-type-face) (2 font-lock-comment-face)) ) "Expressions to highlight in PTA mode.") (defun pta-mode () (setq font-lock-defaults '(pta-font-lock-keywords)) ) Then I added this to my .emacs file to load this, and select it for use on all my *.log files (which suits my needs): (autoload 'pta-mode "pta-mode" "PTA log mode." t) (add-to-list 'auto-mode-alist '("\\.log$" . pta-mode)) On Thursday, May 22, 2003, at 02:11 PM, myrkraverk@users.sourceforge.net wrote: > Hi, > > Matt Noel writes: >> I want to setup a very simple mode for colorizing a log file. All I >> need to do is highlight any lines with the string ERROR on them. I've >> tried reading the documentation for font-lock but it's not clear how >> to >> do this. >> >> Could someone point me to a simple example, or send one? > > Here is an example, it doesn't though specify how you use the mode on > the log file. Maybe you can edit it to suit your need. > > ;; This is basically a list of lists with a regular expression and > ;; then the font name (or face name). The numbers below refer to \\( > ;; ... \\) constructs that mark what part of the re you want > ;; highlighted > (defconst masp-font-lock-keywords > '(("^\\(\\(\\sw\\|\\s_\\)+\\)\\>:?[ > \t]*\\(\\sw+\\(\\.[lLwWbBsS]\\)?\\)?" > (1 font-lock-function-name-face) (3 font-lock-keyword-face nil t)) > ("^\\s +\\(\\(\\sw\\|\\s_\\)+\\(\\.[lLwWbBsS]\\)?\\)" 1 > font-lock-keyword-face) > ("^\\(\\s-+\\|\\sw+:\\s-+\\)\\(\\\\[a-zA-Z0-9]+\\)" > (2 font-lock-constant-face)) > ("\\(\\\\\\sw+\\)" > (1 font-lock-variable-name-face))) > "Additional expressions to highlight in Assembler mode.") > > (defun masp-mode () > ;;... > (setq font-lock-defaults '(masp-font-lock-keywords)) > ;;... > ) > > > Hope this helps, > > Johann > > -- > This line is left blank intentionally > > [-- Attachment #1.2: Type: text/enriched, Size: 2555 bytes --] Thanks Johann, if it's of any help to others, here's what I settled on: I made a file named pta-mode.py in my emacs directory, where I keep other lisp files, and put this in it: <fixed><fontfamily><param>Courier New</param>;; This is basically a list of lists with a regular expression and ;; then the font name (or face name). The numbers below refer to \\( ;; ... \\) constructs that mark what part of the re you want ;; highlighted (defconst pta-font-lock-keywords '( ("- \\(ERROR\\) - \\w*\\(.*\\)" (1 font-lock-warning-face) (2 font-lock-comment-face)) ("- \\(WARN\\) - \\w*\\(.*\\)" (1 font-lock-type-face) (2 font-lock-comment-face)) ) "Expressions to highlight in PTA mode.") (defun pta-mode () (setq font-lock-defaults '(pta-font-lock-keywords)) )</fontfamily></fixed> Then I added this to my .emacs file to load this, and select it for use on all my *.log files (which suits my needs): <fixed><fontfamily><param>Courier New</param>(autoload 'pta-mode "pta-mode" "PTA log mode." t) (add-to-list 'auto-mode-alist '("\\.log$" . pta-mode))</fontfamily></fixed> On Thursday, May 22, 2003, at 02:11 PM, myrkraverk@users.sourceforge.net wrote: <excerpt>Hi, Matt Noel writes: <excerpt>I want to setup a very simple mode for colorizing a log file. All I need to do is highlight any lines with the string ERROR on them. I've tried reading the documentation for font-lock but it's not clear how to do this. Could someone point me to a simple example, or send one? </excerpt> Here is an example, it doesn't though specify how you use the mode on the log file. Maybe you can edit it to suit your need. ;; This is basically a list of lists with a regular expression and ;; then the font name (or face name). The numbers below refer to \\( ;; ... \\) constructs that mark what part of the re you want ;; highlighted (defconst masp-font-lock-keywords '(("^\\(\\(\\sw\\|\\s_\\)+\\)\\>:?[ \t]*\\(\\sw+\\(\\.[lLwWbBsS]\\)?\\)?" (1 font-lock-function-name-face) (3 font-lock-keyword-face nil t)) ("^\\s +\\(\\(\\sw\\|\\s_\\)+\\(\\.[lLwWbBsS]\\)?\\)" 1 font-lock-keyword-face) ("^\\(\\s-+\\|\\sw+:\\s-+\\)\\(\\\\[a-zA-Z0-9]+\\)" (2 font-lock-constant-face)) ("\\(\\\\\\sw+\\)" (1 font-lock-variable-name-face))) "Additional expressions to highlight in Assembler mode.") (defun masp-mode () ;;... (setq font-lock-defaults '(masp-font-lock-keywords)) ;;... ) Hope this helps, Johann -- This line is left blank intentionally </excerpt> [-- Attachment #2: Type: text/plain, Size: 151 bytes --] _______________________________________________ Help-gnu-emacs mailing list Help-gnu-emacs@gnu.org http://mail.gnu.org/mailman/listinfo/help-gnu-emacs ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2003-05-23 15:24 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <mailman.6614.1053651042.21513.help-gnu-emacs@gnu.org> 2003-05-23 15:03 ` How do I setup an extremely simple font-lock mode? Stefan Monnier 2003-05-23 15:05 ` Stefan Monnier [not found] <mailman.6601.1053636524.21513.help-gnu-emacs@gnu.org> 2003-05-22 23:58 ` Alex Schroeder 2003-05-23 13:50 ` Barman Brakjoller 2003-05-23 15:02 ` kgold 2003-05-23 15:24 ` Bryan W. Lepore 2003-05-22 20:47 Matt Noel 2003-05-22 21:11 ` myrkraverk 2003-05-23 0:48 ` Matt Noel
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.