unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Highlight comment in gauss mode
@ 2004-01-06 15:00 jyangstat
  2004-01-06 15:51 ` Highlight comment in HTML Gian Uberto Lauri
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: jyangstat @ 2004-01-06 15:00 UTC (permalink / raw)


Hi, 

I would like to ask if anyone can help me setup highlight gauss mode
comment such as the two different types:

@ This is one line comment @

/* 
This is multiple-lines comments
*/

My current syntax  table is as the follows but it did not work.

  (modify-syntax-entry ?@ "\"" gauss-mode-syntax-table)
  (modify-syntax-entry ?/ ". 14b" gauss-mode-syntax-table)
  (modify-syntax-entry ?* ". 23b" gauss-mode-syntax-table)

Please help me correct my error. Any help is appreciated.

James

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Highlight comment in HTML
  2004-01-06 15:00 Highlight comment in gauss mode jyangstat
@ 2004-01-06 15:51 ` Gian Uberto Lauri
  2004-01-06 18:39 ` Highlight comment in gauss mode Stefan Monnier
       [not found] ` <mailman.29.1073407916.928.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 13+ messages in thread
From: Gian Uberto Lauri @ 2004-01-06 15:51 UTC (permalink / raw)


What could  be a good  way to highlight  HTML comments (they  can span
multiple lines) ?

Syntax tables only support 1 character and 2 character delimiters.

 /\            ___
/___/\__|_|\_|__|___Gian Uberto Lauri_____________________
  //--\ | | \|  |   Integralista GNUslamico e fancazzista 
\/

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Highlight comment in HTML
       [not found] ` <mailman.29.1073407916.928.help-gnu-emacs@gnu.org>
@ 2004-01-06 18:36   ` Tim McNamara
  2004-01-06 18:57     ` Tim McNamara
  2004-01-06 19:13   ` Stefan Monnier
  1 sibling, 1 reply; 13+ messages in thread
From: Tim McNamara @ 2004-01-06 18:36 UTC (permalink / raw)


GianUberto.Lauri@eng.it (Gian Uberto Lauri) writes:

> What could be a good way to highlight HTML comments (they can span
> multiple lines) ?
>
> Syntax tables only support 1 character and 2 character delimiters.

Could it be a defined function (e.g., html-comment-highlight) and
added to html-helper-mode that way?  I haven't seen the Lisp that
html-helper-mode uses to highlight tags, but couldn't comments be
defined as a special tag to be highlighted in a different color?

Since comments are placed within <!-- and //--!> tags, comments ought
to at least highlight in the same color as other tags.  I can't tell,
I don't have any comments in any handy .html files to check against
and don't have time to create a file to play with on my lunch break.
I'll try later on this evening, if I can.  Since the opening and
closing tags have a unique structure, perhaps that could be exploited
for highlighting.

html-helper-mode is one of the most useful things I've seen in Emacs,
for my purposes.  One idea I might suggest is something that I found
in BBEdit, which is that an area of text could be highlighted, the
desired tag selected from a menu, and the opening and closing tags
were automatically placed at the appropriate end of the selected
text. It worked really well; Emacs might be able to be more
sophisticated by working automatically around newlines and white space
and such for locating the proper placement of tags since it already
has those capacities in the text modes.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Highlight comment in gauss mode
  2004-01-06 15:00 Highlight comment in gauss mode jyangstat
  2004-01-06 15:51 ` Highlight comment in HTML Gian Uberto Lauri
@ 2004-01-06 18:39 ` Stefan Monnier
  2004-01-07  0:20   ` jyangstat
       [not found] ` <mailman.29.1073407916.928.help-gnu-emacs@gnu.org>
  2 siblings, 1 reply; 13+ messages in thread
From: Stefan Monnier @ 2004-01-06 18:39 UTC (permalink / raw)


> @ This is one line comment @

Is

  @ this is
    a two line comment @

valid?  Or is

  @ this is a one line comment

valid?  How about

  @ comment @ not comment

?

> /* 
> This is multiple-lines comments
> */

> My current syntax  table is as the follows but it did not work.

You don't give us enough info to know what you did and what failed to happen.

>   (modify-syntax-entry ?@ "\"" gauss-mode-syntax-table)

This is wrong because it says @ is used for strings rather than
for comments.  You probably want to use "!" instead of "\"" although
it depends on the answers to the above questions.

>   (modify-syntax-entry ?/ ". 14b" gauss-mode-syntax-table)
>   (modify-syntax-entry ?* ". 23b" gauss-mode-syntax-table)

That looks right.


        Stefan

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Highlight comment in HTML
  2004-01-06 18:36   ` Highlight comment in HTML Tim McNamara
@ 2004-01-06 18:57     ` Tim McNamara
  0 siblings, 0 replies; 13+ messages in thread
From: Tim McNamara @ 2004-01-06 18:57 UTC (permalink / raw)


Tim McNamara <timmcn@bitstream.net> writes:

> GianUberto.Lauri@eng.it (Gian Uberto Lauri) writes:
>
>> What could be a good way to highlight HTML comments (they can span
>> multiple lines) ?

<snip>

> Since comments are placed within <!-- and //--!> tags, comments
> ought to at least highlight in the same color as other tags.  I
> can't tell, I don't have any comments in any handy .html files to
> check against and don't have time to create a file to play with on
> my lunch break.  I'll try later on this evening, if I can.  Since
> the opening and closing tags have a unique structure, perhaps that
> could be exploited for highlighting.

OK, I couldn't resist.  Checking it out, I found that html-helper-mode
*does* highlight comments between <-- and -->, even those spanning
multiple lines.  They highlight in a unique color, too.

Perhaps I didn't understand the question?

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Highlight comment in HTML
       [not found] ` <mailman.29.1073407916.928.help-gnu-emacs@gnu.org>
  2004-01-06 18:36   ` Highlight comment in HTML Tim McNamara
@ 2004-01-06 19:13   ` Stefan Monnier
  1 sibling, 0 replies; 13+ messages in thread
From: Stefan Monnier @ 2004-01-06 19:13 UTC (permalink / raw)


> What could  be a good  way to highlight  HTML comments (they  can span
> multiple lines) ?

Any problem with the way sgml-mode does nit ?


        Stefan

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Highlight comment in gauss mode
  2004-01-06 18:39 ` Highlight comment in gauss mode Stefan Monnier
@ 2004-01-07  0:20   ` jyangstat
  2004-01-07  1:04     ` Stefan Monnier
  0 siblings, 1 reply; 13+ messages in thread
From: jyangstat @ 2004-01-07  0:20 UTC (permalink / raw)


Thank you for your response and sorry for unclear information. 

Based on Gauss, the valid comment format is anything between /* and */
(same as C) and between @ ... @ when @ ... @ is at the same line.

I just use the gauss mode implemented by Steve Berry. However, this
mode only supports @ ... @ type comment but not highlight the comment.
The whole gauss mode is as follows. Could you help me modify the mode?
Thanks a lot.

James 


;; --------------------------------------------------------------
;; gauss-mode.el - major mode for editing Gauss programs with GNU
Emacs
;;
;; This major mode for GNU Emacs provides support for editing Gauss
;; source files.  It automatically indents for block structures, line
;; continuations (e.g., ...), and comments.  The usual paren matching
;; support is included.  
;;
;; In addition to automatic indentation when typing "do while" blocks,
;; "if" blocks, "proc" 's, etc., TAB indents an existing or new line
to
;; the correct level and META-; sets up a comment line.  META-return
starts
;; a newline at column one, ignoring the automatic indentation.
;; To properly indent an existing region in a *.prg file, use the
command
;; M-x indent-region.
;;
;;
;;
;;
;;
;;
;;
;;
;;
;;
;; To enter gauss-mode automatically when editing .prg files, put 
;; something like this in your .emacs file.
;;
;;   (autoload 'gauss-mode "gauss-mode" "Enter Gauss-mode." t)
;;   (setq auto-mode-alist (cons '("\\.prg$" . gauss-mode)
auto-mode-alist))
;;   (setq gauss-mode-hook '(lambda () (setq fill-column 74)))
;;
;; Enjoy.
;;
;; THIS FILE IS A COMPLETE HACK by Steve Berry (March 1994).  It is
;; modified from octave-mode.el, which is modified from
;; matlab-mode.el.  Warning: I am no lisp programmer. 
;; The support for
;; syntax-highlighting (ie font-lock-mode) was added by Neel
Krishnaswami
;; in July 1999. 
;;
;; Octave-mode.el was modified by John W. Eaton (jwe@che.utexas.edu)
from
;; the file matlab-mode.el which is:
;;
;; Copyright (C) 1991 Matthew R. Wette.
;; Everyone is granted permission to copy, modify and redistribute
this
;; file provided:
;;   1. All copies contain this copyright notice.
;;   2. All modified copies shall carry a prominant notice stating who
;;      made the last modification and the date of such modification.
;;   3. No charge is made for this software or works derived from it.
;;      This clause shall not be construed as constraining other
software
;;      distributed on the same medium as this software, nor is a
;;      distribution fee considered a charge.
;;
;;
;; Constants used in all Gauss-mode buffers.
(defconst gauss-indent-level 2
  "*The indentation in Gauss-mode.")

(defconst gauss-comment-column 40
  "*The goal comment column in Gauss-mode buffers.")


;; Syntax Table
(defvar gauss-mode-syntax-table nil
  "Syntax table used in Gauss-mode buffers.")

(if gauss-mode-syntax-table
    ()
  (setq gauss-mode-syntax-table (make-syntax-table))
  (modify-syntax-entry ?\\ "." gauss-mode-syntax-table)
  (modify-syntax-entry ?/ "." gauss-mode-syntax-table)
  (modify-syntax-entry ?* "." gauss-mode-syntax-table)
  (modify-syntax-entry ?+ "." gauss-mode-syntax-table)
  (modify-syntax-entry ?- "." gauss-mode-syntax-table)
  (modify-syntax-entry ?= "." gauss-mode-syntax-table)
  (modify-syntax-entry ?< "." gauss-mode-syntax-table)
  (modify-syntax-entry ?> "." gauss-mode-syntax-table)
  (modify-syntax-entry ?& "." gauss-mode-syntax-table)
  (modify-syntax-entry ?| "." gauss-mode-syntax-table)
  (modify-syntax-entry ?\' "\"" gauss-mode-syntax-table)
  (modify-syntax-entry ?@ "\"" gauss-mode-syntax-table)
  (modify-syntax-entry ?/ ". 14b" gauss-mode-syntax-table)
  (modify-syntax-entry ?* ". 23b" gauss-mode-syntax-table)
  (set-syntax-table gauss-mode-syntax-table))


;; Abbrev Table
(defvar gauss-mode-abbrev-table nil
  "Abbrev table used in Gauss-mode buffers.")

(define-abbrev-table 'gauss-mode-abbrev-table ())


;; Syntax Highlighting

(defvar gauss-compiler-directives
  (mapconcat 'identity
	     '( "#define\\>"	    "#definecs\\>"
		"#undef\\>"	    "#ifdef\\>"
		"#ifndef\\>"	    "#iflight\\>"
		"#ifdos\\>"	    "#ifos2win\\>"
		"#ifunix\\>"	    "#else\\>"
		"#endif\\>"	    "#include\\>"
		"#lineson\\>"	    "#linesoff\\>"
		"#srcfile\\>"	    "#srcline\\>")
	     "\\|"))

(defvar gauss-keywords
  (mapconcat 'identity
	     '("\\<proc\\>"	"\\<keyword\\>"	
	       "\\<endp\\>"	"\\<retp\\>"
	       "\\<do\\>"	"\\<while\\>"
	       "\\<until\\>"	"\\<endo\\>"
	       "\\<for\\>"	"\\<endfor\\>"
	       "\\<break\\>"	"\\<continue\\>"
	       "\\<if\\>"	"\\<elseif\\>"
	       "\\<else\\>"	"\\<endif\\>"
	       "\\<goto\\>"	"\\<gosub\\>")
	     "\\|"))

(defvar gauss-types
  (mapconcat 'identity
	     '("\\<matrix\\>"	"\\<string\\>"
	       "\\<declare\\>"	"\\<let\\>"
	       "\\<fn\\>"	"\\<local\\>")
	     "\\|"))

(defvar gauss-identifier "[a-zA-Z0-9_]+")

(defvar gauss-local-declaration
  (concat "\\<local\\s-+"
	  "\\("
	  gauss-identifier
	  "\\s-*\\(,\\s-*" gauss-identifier "\\s-*\\)*"
	  "\\);"))

(defvar gauss-type-declaration-1
  (concat "\\<declare\\s-+"
	  "\\(matrix\\|string\\)?"
	  "\\("
	  gauss-identifier
	  "\\s-*\\(,\\s-*" gauss-identifier "\\s-*\\)*"
	  "\\);"))

(defvar gauss-type-declaration-2
  (concat "\\<declare\\s-+"
	  "\\(" gauss-types "\\)?"
	  "\\s-*"
	  "\\(" gauss-identifier "\\)"
	  "\\s-*"
	  "\\(=\\|!=\\|:=\\|\?=\\)"
	  "[^;]+;"))

(defvar gauss-proc-declaration
  (concat "\\<proc\\s-*"
	  "\\(([0-9]+)\\)?"
	  "\\s-*[=]?\\s-*"
	  "\\(" gauss-identifier "\\)"))

(defvar gauss-font-lock-keywords
  (list
   (cons gauss-compiler-directives 'font-lock-warning-face)
   (cons gauss-types 'font-lock-type-face)
   (cons gauss-keywords 'font-lock-keyword-face)
   (cons gauss-proc-declaration
	 '(2 font-lock-function-name-face nil nil))
   (cons gauss-local-declaration
	 '(1 font-lock-variable-name-face nil nil))
   (cons gauss-type-declaration-1
	 '(2 font-lock-variable-name-face nil nil))
   (cons gauss-type-declaration-2
	 '(2 font-lock-variable-name-face nil nil))))

;; Mode Map
(defvar gauss-mode-map ()
  "Keymap used in gauss-mode.")

(if gauss-mode-map
    ()
  (setq gauss-mode-map (make-sparse-keymap))
  (define-key gauss-mode-map "\r" 'gauss-return)
  (define-key gauss-mode-map "\t" 'gauss-indent-line)
  (define-key gauss-mode-map "\M-;" 'gauss-comment)
  (define-key gauss-mode-map "\C-ct" 'gauss-line-type)
  (define-key gauss-mode-map "\C-ci" 'gauss-indent-type)
  (define-key gauss-mode-map "\M-\r" 'newline))


;; Gauss Mode
(defun gauss-mode ()
  "Major mode for editing Gauss source files.  Version 1.0, 23 Feb
1993.
Will run gauss-mode-hook if it is non-nil.  Auto-fill-mode seems to
work.
Filling does not work (yet).
Special Key Bindings:
\\{gauss-mode-map}
Variables:
  gauss-indent-level                   Level to indent blocks.
  gauss-comment-column                 Goal column for on-line
comments.
  fill-column                           Column used in auto-fill
(default=70).
Commands:
  gauss-mode                           Enter Gauss major mode.
  gauss-return                         Handle return with indenting.
  gauss-indent-line                    Indent line for structure.
  gauss-comment                        Add comment to current line.
  gauss-comment-indent                 Compute indent for comment.
  gauss-line-type                      Tell current line type (for
debugging).
  gauss-indent-type                    Tell last indent type (for
debugging).
To add automatic support put something like the following in your
.emacs file:
  \(autoload 'gauss-mode \"gauss-mode\" \"Enter Gauss-mode.\" t\)
  \(setq auto-mode-alist \(cons '\(\"\\\\.m[201z$\" . gauss-mode\) \
auto-mode-alist\)\)
  \(setq gauss-mode-hook '\(lambda \(\) \(setq fill-column 74\)\)\)"
  (interactive)
  (kill-all-local-variables)
  (use-local-map gauss-mode-map)
  (setq major-mode 'gauss-mode)
  (setq mode-name "Gauss")
  (setq local-abbrev-table gauss-mode-abbrev-table)
  (set-syntax-table gauss-mode-syntax-table)
  (make-local-variable 'paragraph-start)
  (setq paragraph-start (concat "^$\\|" page-delimiter))
  (make-local-variable 'paragraph-separate)
  (setq paragraph-separate paragraph-start)
  (make-local-variable 'paragraph-ignore-fill-prefix)
  (setq paragraph-ignore-fill-prefix t)
  (make-local-variable 'indent-line-function)
  (setq indent-line-function 'gauss-indent-line)
  (make-local-variable 'comment-start-skip)
  (setq comment-start-skip "[%@][ \t]*")
  (make-local-variable 'comment-column)
  (setq comment-column 'gauss-comment-column)
  (make-local-variable 'comment-indent-hook)
  (setq comment-indent-hook 'gauss-comment-indent)
  (make-local-variable 'fill-column)
  (setq fill-column default-fill-column)
  (make-local-variable 'font-lock-defaults)
  (setq font-lock-defaults '(gauss-font-lock-keywords
			     t		         ;; Keywords-only?
			     t  		 ;; Fold case?
			     nil		 ;; Syntax-alist
			     nil		 ;; Syntax-begin    
			    ))
  (run-hooks 'gauss-mode-hook))


(defun gauss-return ()
  "Handle carriage return in Gauss-mode."
  (interactive)
  (if (gauss-block-end-line)
      (gauss-indent-line))
  (newline)
  (gauss-indent-line))

(defun gauss-comment ()
  "Add a comment to the following line, or format if one already
exists."
  (interactive)
  (cond
   ((gauss-empty-line)
    (gauss-indent-line)
    (insert "@   @") 
    (backward-char) (backward-char) (backward-char) )
   ((gauss-comment-line))
   (t
    (end-of-line)
    (re-search-backward "[^ \t^]" 0 t)
    (forward-char)
    (delete-horizontal-space)
    (if (< (current-column) gauss-comment-column)
        (indent-to gauss-comment-column)
      (insert " "))
    (insert "@   @") 
     (backward-char) (backward-char) (backward-char) )))

(defun gauss-comment-indent ()
  "Indent a comment line in Gauss-mode."
  (gauss-calc-indent))

(defun gauss-indent-line ()
  "Indent a line in Gauss-mode."
  (interactive)
  (save-excursion
    (beginning-of-line)
    (delete-horizontal-space)
    (indent-to (gauss-calc-indent)))
  (skip-chars-forward " \t"))

(defconst gauss-comment-1
  (list
   '("@.*@" . font-lock-warning-face))
  "highlighting comment.")


(defun gauss-line-type ()
  "Display type of current line.  Used in debugging."
  (interactive)
  (cond
   ((gauss-empty-line)
    (message "gauss-line-type: empty-line"))
   ((gauss-comment-line)
    (message "gauss-line-type: comment-line"))
   ((gauss-continuation-line)
    (message "gauss-line-type: continuation-line"))
   ((gauss-block-beg-end-line)
    (message "gauss-line-type: block-beg-end-line"))
   ((gauss-block-beg-line)
    (message "gauss-line-type: block-beg-line"))
   ((gauss-block-end-line)
    (message "gauss-line-type: block-end-line"))
   (t
    (message "gauss-line-type: other"))))

(defun gauss-indent-type ()
  "Display type of current or previous nonempty line.  Used in
debugging."
  (interactive)
  (message (concat "gauss-ident-type: " gauss-last-indent-type)))

(defun gauss-fill-region (from to &optional justify-flag)
  "Fill the region of comments.
Prefix arg (non-nil third arg, if called from program)
means justify as well."
  (interactive "r\nP")
  (messages "gauss-fill-region not implemented yet."))

(defvar gauss-last-indent-type "unknown"
  "String to tell line type.")

(defun gauss-calc-indent ()
  "Return the appropriate indentation for this line as an int."
  (let ((indent 0))
    (save-excursion
      (forward-line -1)                 ; compute indent based on
previous
      (if (gauss-empty-line)               ;   non-empty line
          (re-search-backward "[^ \t\n]" 0 t))
      (cond
       ((gauss-empty-line) 
        (setq gauss-last-indent-type "empty"))
       ((gauss-comment-line) 
        (setq gauss-last-indent-type "comment"))
       ((gauss-continuation-line)
        (setq gauss-last-indent-type "continuation")
        (setq indent (* 2 gauss-indent-level)))
       ((gauss-block-beg-end-line)
        (setq gauss-last-indent-type "block begin-end"))
       ((gauss-block-beg-line)
        (setq gauss-last-indent-type "block begin")
        (setq indent gauss-indent-level))
       ((gauss-unbal-matexp-line)
        (setq gauss-last-indent-type "unbalanced-matrix-expression")
        (setq indent (gauss-calc-matexp-indent)))
       (t
        (setq gauss-last-indent-type "other")))
      (setq indent (+ indent (current-indentation)))
      (if (= 0 (forward-line -1))
          (if (gauss-continuation-line)
              (setq indent (- indent (* 2 gauss-indent-level))))))
    (if (gauss-block-end-line) (setq indent (- indent
gauss-indent-level)))
    (if (< indent 0) (setq indent 0))
    indent))


(defun gauss-empty-line ()
  "Returns t if current line is empty."
  (save-excursion
    (beginning-of-line)
    (looking-at "^[ \t]*$")))

(defun gauss-comment-line ()
  "Returns t if current line is an Gauss comment line."
  (save-excursion
    (beginning-of-line)
    (skip-chars-forward " \t")
    (looking-at "[%@]")))

(defun gauss-continuation-line ()
  "Returns t if current line ends in ... and optional comment."
  (save-excursion
    (beginning-of-line)
    (re-search-forward "\\.\\.\\.+[ \t]*\\(%.*\\)?$"
(gauss-eoln-point) t)))

(defun gauss-eoln-point ()
  "Returns point for end-of-line in Gauss-mode."
  (save-excursion
    (end-of-line)
    (point)))

(defun gauss-block-beg-line ()
  "Returns t if line contains beginning of Gauss block."
  (save-excursion
    (beginning-of-line)
    (looking-at (concat "\\([^%@\n]*[ \t]\\)?" gauss-block-beg-kw))))

(defconst gauss-block-beg-kw
  "\\(for\\|while\\|until\\|if\\|else\\|elseif\\|proc \\)"
  "Regular expression for keywords which begin blocks in Gauss-mode.")

(defun gauss-block-end-line ()
  "Returns t if line contains end of Gauss block."
  (save-excursion
    (beginning-of-line)
    (looking-at (concat "\\([^%@\n]*[ \t]\\)?" gauss-block-end-kw))))

(defconst gauss-block-end-kw
  "\\(endfor\\|endo\\|endif\\|endp\\|else\\|elseif\\)"
  "Regular expression for keywords which end blocks.")

(defun gauss-block-beg-end-line ()
  "Returns t if line contains matching block begin-end in Gauss-mode."
  (save-excursion
    (beginning-of-line)
    (looking-at (concat
                 "\\([^%@\n]*[ \t]\\)?" gauss-block-beg-kw 
                 "." "\\([^%@\n]*[ \t]\\)?" gauss-block-end-kw))))

(defun gauss-unbal-matexp-line ()
  (if (= (gauss-calc-matexp-indent) 0)
    ()
    t))

(defun gauss-calc-matexp-indent ()
  (let ((indent 0))
    (save-excursion
      (beginning-of-line)
      (while (< (point) (gauss-eoln-point))
	(cond
	 ((looking-at "\\[")
	  (setq indent (+ indent gauss-indent-level)))
	 ((looking-at "\\]")
	  (setq indent (- indent gauss-indent-level))))
	(forward-char)))
    (* 2 indent)))

(defun gauss-comment-on-line ()
  "Returns t if current line contains a comment."
  (save-excursion
    (beginning-of-line)
    (looking-at "[^\n]*[%@]")))

(defun gauss-in-comment ()
  "Returns t if point is in a comment."
  (save-excursion
    (and (/= (point) (point-max)) (forward-char))
    (search-backward "[%@]" (save-excursion (beginning-of-line)
(point)) t)))

(defvar gauss-auto-newline nil
  "*Non-nil means automatically newline after semicolomns.")




(provide 'gauss-mode)

;; --- last line of gauss-mode.el --- 




Stefan Monnier <monnier@iro.umontreal.ca> wrote in message news:<jwvad517wo7.fsf-monnier+gnu.emacs.help@asado.iro.umontreal.ca>...
> > @ This is one line comment @
> 
> Is
> 
>   @ this is
>     a two line comment @
> 
> valid?  Or is
> 
>   @ this is a one line comment
> 
> valid?  How about
> 
>   @ comment @ not comment
> 
> ?
> 
> > /* 
> > This is multiple-lines comments
> > */
>  
> > My current syntax  table is as the follows but it did not work.
> 
> You don't give us enough info to know what you did and what failed to happen.
> 
> >   (modify-syntax-entry ?@ "\"" gauss-mode-syntax-table)
> 
> This is wrong because it says @ is used for strings rather than
> for comments.  You probably want to use "!" instead of "\"" although
> it depends on the answers to the above questions.
> 
> >   (modify-syntax-entry ?/ ". 14b" gauss-mode-syntax-table)
> >   (modify-syntax-entry ?* ". 23b" gauss-mode-syntax-table)
> 
> That looks right.
> 
> 
>         Stefan

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Highlight comment in gauss mode
  2004-01-07  0:20   ` jyangstat
@ 2004-01-07  1:04     ` Stefan Monnier
  2004-01-07 13:33       ` jyangstat
  0 siblings, 1 reply; 13+ messages in thread
From: Stefan Monnier @ 2004-01-07  1:04 UTC (permalink / raw)


> Thank you for your response and sorry for unclear information. 
> Based on Gauss, the valid comment format is anything between /* and */
> (same as C) and between @ ... @ when @ ... @ is at the same line.

But the question remains of whether or not

     @ foo

is valid Gauss (and whether it is a comment).

> I just use the gauss mode implemented by Steve Berry. However, this
> mode only supports @ ... @ type comment but not highlight the comment.

Reading the code, I'd expect it to highlight them, although in `string'
face rather than in `comment' face.  Can you precisely (i.e. as if talking
to a complete idiot) describe what you do, what you see, and what you
expected instead ?


        Stefan

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Highlight comment in gauss mode
  2004-01-07  1:04     ` Stefan Monnier
@ 2004-01-07 13:33       ` jyangstat
  2004-01-07 15:30         ` Stefan Monnier
  0 siblings, 1 reply; 13+ messages in thread
From: jyangstat @ 2004-01-07 13:33 UTC (permalink / raw)


Stefan Monnier <monnier@iro.umontreal.ca> wrote in message news:<jwvn090372j.fsf-monnier+gnu.emacs.help@asado.iro.umontreal.ca>...
> > Thank you for your response and sorry for unclear information. 
> > Based on Gauss, the valid comment format is anything between /* and */
> > (same as C) and between @ ... @ when @ ... @ is at the same line.
> 
> But the question remains of whether or not
> 
>      @ foo

@ foo 
is not valid Gauss. The valid Gauss comments are
 
/* this kind of comment can be nested */ 

@ this kind of comment cannot be nested @ 

For example, the followings are valid gauss comment:

Case 1:
/* foo1
  /* foo2 */
*/

Case 2:
@ foo2@

Case 3:

@ foo3
@


> 
> is valid Gauss (and whether it is a comment).
> 
> > I just use the gauss mode implemented by Steve Berry. However, this
> > mode only supports @ ... @ type comment but not highlight the comment.
> 
> Reading the code, I'd expect it to highlight them, although in `string'
> face rather than in `comment' face.  Can you precisely (i.e. as if talking
> to a complete idiot) describe what you do, what you see, and what you
> expected instead ?

I just want to see the colors are different in comment areas. For example,

{ans1,ans2} = call_foo(arg1,arg2,arg3); @This is foo subroutine@
/* foo is calculating ....
 ....
*/

I would like to see highlight in
@This is foo subroutine@
/* foo is calculating ....
 ....
*/

Thanks.

James

> 
> 
>         Stefan

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Highlight comment in gauss mode
  2004-01-07 13:33       ` jyangstat
@ 2004-01-07 15:30         ` Stefan Monnier
  2004-01-08 21:30           ` jyangstat
  0 siblings, 1 reply; 13+ messages in thread
From: Stefan Monnier @ 2004-01-07 15:30 UTC (permalink / raw)


> @ foo 
> is not valid Gauss. The valid Gauss comments are
 
> /* this kind of comment can be nested */ 

> @ this kind of comment cannot be nested @ 

Oh, so it's not a question of whether the closing @ is on the same line but
of nesting.  Good.

Then you want to add "n" to the syntax of "*" (to cause /* */ to be
nestable) and you want to use "!" (instead of "\"") for for syntax of @.

> For example, the followings are valid gauss comment:

> Case 1:
> /* foo1
>   /* foo2 */
> */

> Case 2:
> @ foo2@

> Case 3:

> @ foo3
> @

With my suggestions above, all three should work just fine in Emacs-21.

> I just want to see the colors are different in comment areas.

What have you tried to do to make it happen ?
Have you turned on font-lock-mode ?


        Stefan

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Highlight comment in gauss mode
  2004-01-07 15:30         ` Stefan Monnier
@ 2004-01-08 21:30           ` jyangstat
  2004-01-08 22:41             ` Stefan Monnier
  0 siblings, 1 reply; 13+ messages in thread
From: jyangstat @ 2004-01-08 21:30 UTC (permalink / raw)


Thank you very much. The format is correct now but the comment areas
do not change the color though font-lock-mode is on. Could you kindly
tell me what lisp algorithm I should add to change the comment color.
Any help is highly appreciated.

James

Stefan Monnier <monnier@iro.umontreal.ca> wrote in message news:<jwv1xqb3hjl.fsf-monnier+gnu.emacs.help@asado.iro.umontreal.ca>...
> > @ foo 
> > is not valid Gauss. The valid Gauss comments are
>  
> > /* this kind of comment can be nested */ 
>  
> > @ this kind of comment cannot be nested @ 
> 
> Oh, so it's not a question of whether the closing @ is on the same line but
> of nesting.  Good.
> 
> Then you want to add "n" to the syntax of "*" (to cause /* */ to be
> nestable) and you want to use "!" (instead of "\"") for for syntax of @.
> 
> > For example, the followings are valid gauss comment:
>  
> > Case 1:
> > /* foo1
> >   /* foo2 */
> > */
>  
> > Case 2:
> > @ foo2@
>  
> > Case 3:
>  
> > @ foo3
> > @
> 
> With my suggestions above, all three should work just fine in Emacs-21.
> 
> > I just want to see the colors are different in comment areas.
> 
> What have you tried to do to make it happen ?
> Have you turned on font-lock-mode ?
> 
> 
>         Stefan

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Highlight comment in gauss mode
  2004-01-08 21:30           ` jyangstat
@ 2004-01-08 22:41             ` Stefan Monnier
  2004-01-09 12:46               ` jyangstat
  0 siblings, 1 reply; 13+ messages in thread
From: Stefan Monnier @ 2004-01-08 22:41 UTC (permalink / raw)


> Thank you very much. The format is correct now but the comment areas
> do not change the color though font-lock-mode is on. Could you kindly
> tell me what lisp algorithm I should add to change the comment color.
> Any help is highly appreciated.

The part of the code that says:

  (setq font-lock-defaults '(gauss-font-lock-keywords
			     t		         ;; Keywords-only?
			     t  		 ;; Fold case?
			     nil		 ;; Syntax-alist
			     nil		 ;; Syntax-begin    
			    ))

should say

  (setq font-lock-defaults '(gauss-font-lock-keywords
			     nil	         ;; Keywords-only?
			     t  		 ;; Fold case?
			     nil		 ;; Syntax-alist
			     nil		 ;; Syntax-begin
			    ))

so that font-lock uses syntax-tables.


        Stefan

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Highlight comment in gauss mode
  2004-01-08 22:41             ` Stefan Monnier
@ 2004-01-09 12:46               ` jyangstat
  0 siblings, 0 replies; 13+ messages in thread
From: jyangstat @ 2004-01-09 12:46 UTC (permalink / raw)


Hi Stefan,

Thank you so much. You save me so much time and teach me a lot. It is
working as I want.

James

Stefan Monnier <monnier@iro.umontreal.ca> wrote in message news:<jwvfzeqoyjr.fsf-monnier+gnu.emacs.help@asado.iro.umontreal.ca>...
> > Thank you very much. The format is correct now but the comment areas
> > do not change the color though font-lock-mode is on. Could you kindly
> > tell me what lisp algorithm I should add to change the comment color.
> > Any help is highly appreciated.
> 
> The part of the code that says:
> 
>   (setq font-lock-defaults '(gauss-font-lock-keywords
> 			     t		         ;; Keywords-only?
> 			     t  		 ;; Fold case?
> 			     nil		 ;; Syntax-alist
> 			     nil		 ;; Syntax-begin    
> 			    ))
> 
> should say
> 
>   (setq font-lock-defaults '(gauss-font-lock-keywords
> 			     nil	         ;; Keywords-only?
> 			     t  		 ;; Fold case?
> 			     nil		 ;; Syntax-alist
> 			     nil		 ;; Syntax-begin
> 			    ))
> 
> so that font-lock uses syntax-tables.
> 
> 
>         Stefan

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2004-01-09 12:46 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-06 15:00 Highlight comment in gauss mode jyangstat
2004-01-06 15:51 ` Highlight comment in HTML Gian Uberto Lauri
2004-01-06 18:39 ` Highlight comment in gauss mode Stefan Monnier
2004-01-07  0:20   ` jyangstat
2004-01-07  1:04     ` Stefan Monnier
2004-01-07 13:33       ` jyangstat
2004-01-07 15:30         ` Stefan Monnier
2004-01-08 21:30           ` jyangstat
2004-01-08 22:41             ` Stefan Monnier
2004-01-09 12:46               ` jyangstat
     [not found] ` <mailman.29.1073407916.928.help-gnu-emacs@gnu.org>
2004-01-06 18:36   ` Highlight comment in HTML Tim McNamara
2004-01-06 18:57     ` Tim McNamara
2004-01-06 19:13   ` Stefan Monnier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).