* Basic font-lock without font-locking double-quoted strings
@ 2013-12-19 23:58 Joe Riel
0 siblings, 0 replies; 5+ messages in thread
From: Joe Riel @ 2013-12-19 23:58 UTC (permalink / raw)
To: Help GNU Emacs
Why would the following minimal mode
(define-derived-mode msdbg-mode fundamental-mode
(setq font-lock-keywords '(("EA" . font-lock-warning-face))))
cause text delimited by double-quotes, say
"This gets font-locked"
to get font-locked? Is this syntactic font-locking?
How can I turn it off in that mode?
If I set font-lock-keywords to nil, then the strings
don't get font-locked, nor anything else.
--
Joe Riel
^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <mailman.9709.1387497505.10748.help-gnu-emacs@gnu.org>]
* Re: Basic font-lock without font-locking double-quoted strings
[not found] <mailman.9709.1387497505.10748.help-gnu-emacs@gnu.org>
@ 2013-12-20 0:26 ` Emanuel Berg
2013-12-20 0:30 ` Emanuel Berg
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Emanuel Berg @ 2013-12-20 0:26 UTC (permalink / raw)
To: help-gnu-emacs
Joe Riel <joer@san.rr.com> writes:
> Why would the following minimal mode
>
> (define-derived-mode msdbg-mode fundamental-mode (setq
> font-lock-keywords '(("EA"
> . font-lock-warning-face))))
Does that work at all?
According to the help, it should look like this:
(define-derived-mode article-mode sgml-mode "Article"
"Major mode for editing technical articles."
(setq case-fold-search nil))
But strings are highlighted in fundamental-mode
(font-look-face-face) so at least that makes sense.
You'll have to wait for a better answer, but the below
code (the only mode I did) might interest you. When I
did it, I was told on this list not to make it a
generic mode but to derive from fundamental-mode,
however, I didn't do that - first the keywords, then
create the mode.
(defvar fpscalc-keywords
'(("\\(!.*$\\)" . 'fpscalc-comment)
("\\(semaphore\\)\\((\\)\\([[:word:]]+\\)\\(\\, \\)\\([[:word:]]+\\)"
(1 'fpscalc-semaphore-keyword)
(3 'fpscalc-semaphore-name)
(5 'fpscalc-task-name-and-index) )
("declarations\\|initialise\\|semaphores\\|formulas" . 'fpscalc-program-parts)
("sigma\\|floor\\|ceiling\\|min\\|max" . 'fpscalc-math-functions)
("lp\\|ep\\|hp\\|all" . 'fpscalc-task-priority-sets)
("\\([[:word:]]\\)\\(\\[\\)\\(i\\)\\(\\]\\)"
(1 'fpscalc-variable-name)
(3 'fpscalc-i-task) )
("\\([[:word:]]\\)\\(\\[\\)\\(j\\)\\(\\]\\)"
(1 'fpscalc-variable-name)
(3 'fpscalc-j-task))
("\\([[:word:]]\\)\\(\\[\\)\\(.*\\)\\(\\]\\)"
(1 'fpscalc-variable-name)
(3 'fpscalc-task-name-and-index))
("\\(system \\)\\(.* \\)"
(1 'fpscalc-system-keyword)
(2 'fpscalc-system-name))
("\\(scalar\\|indexed\\|priority\\|blocking\\)\\( \\)+\\(\\(\\([[:word:]]\\( *\\, *\\)?\\)\\)*\\)"
(1 'fpscalc-variable-type)
(3 'fpscalc-variable-name))
("\\(tasks +\\)\\(\\(\\([[:word:]]\\( *\\, *\\)?\\)\\)*\\)"
(1 'fpscalc-tasks-keyword)
(2 'fpscalc-task-name-and-index))
))
(define-generic-mode
'fpscalc-mode
'("!")
nil
fpscalc-keywords
'("\\.fps\\'")
'((lambda ()
(progn
(setq indent-line-function 'fpscalc-indent-line)
(local-set-key "\C-c\C-c" 'compute) )))
"Major mode for .fps files and the fpscalc tool.")
--
Emanuel Berg, programmer-for-rent. CV, projects, etc at uXu
underground experts united: http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Basic font-lock without font-locking double-quoted strings
2013-12-20 0:26 ` Emanuel Berg
@ 2013-12-20 0:30 ` Emanuel Berg
2013-12-20 5:00 ` Joe Riel
[not found] ` <mailman.9722.1387515631.10748.help-gnu-emacs@gnu.org>
2 siblings, 0 replies; 5+ messages in thread
From: Emanuel Berg @ 2013-12-20 0:30 UTC (permalink / raw)
To: help-gnu-emacs
Emanuel Berg <embe8573@student.uu.se> writes:
> But strings are highlighted in fundamental-mode
> (font-look-face-face) so at least that makes sense.
Or...? So you did you did activate that somehow. Then I
have no idea.
--
Emanuel Berg, programmer-for-rent. CV, projects, etc at uXu
underground experts united: http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Basic font-lock without font-locking double-quoted strings
2013-12-20 0:26 ` Emanuel Berg
2013-12-20 0:30 ` Emanuel Berg
@ 2013-12-20 5:00 ` Joe Riel
[not found] ` <mailman.9722.1387515631.10748.help-gnu-emacs@gnu.org>
2 siblings, 0 replies; 5+ messages in thread
From: Joe Riel @ 2013-12-20 5:00 UTC (permalink / raw)
To: Emanuel Berg; +Cc: help-gnu-emacs
On Fri, 20 Dec 2013 01:26:26 +0100
Emanuel Berg <embe8573@student.uu.se> wrote:
> Joe Riel <joer@san.rr.com> writes:
>
> > Why would the following minimal mode
> >
> > (define-derived-mode msdbg-mode fundamental-mode (setq
> > font-lock-keywords '(("EA"
> > . font-lock-warning-face))))
>
> Does that work at all?
Yes. One solution was to set font-lock-keywords-only to t.
That can be done when assigning to font-lock-defaults.
My solution was different; I don't need font-lock mode,
so called (font-lock-mode -1) to turn it off, then coded a
loop to fontify what I needed (the mode is just for viewing).
>
> According to the help, it should look like this:
>
> (define-derived-mode article-mode sgml-mode "Article"
> "Major mode for editing technical articles."
> (setq case-fold-search nil))
>
> But strings are highlighted in fundamental-mode
> (font-look-face-face) so at least that makes sense.
>
> You'll have to wait for a better answer, but the below
> code (the only mode I did) might interest you. When I
> did it, I was told on this list not to make it a
> generic mode but to derive from fundamental-mode,
> however, I didn't do that - first the keywords, then
> create the mode.
>
> (defvar fpscalc-keywords
> '(("\\(!.*$\\)" . 'fpscalc-comment)
> ("\\(semaphore\\)\\((\\)\\([[:word:]]+\\)\\(\\, \\)\\([[:word:]]+\\)"
> (1 'fpscalc-semaphore-keyword)
> (3 'fpscalc-semaphore-name)
> (5 'fpscalc-task-name-and-index) )
> ("declarations\\|initialise\\|semaphores\\|formulas" . 'fpscalc-program-parts)
> ("sigma\\|floor\\|ceiling\\|min\\|max" . 'fpscalc-math-functions)
> ("lp\\|ep\\|hp\\|all" . 'fpscalc-task-priority-sets)
> ("\\([[:word:]]\\)\\(\\[\\)\\(i\\)\\(\\]\\)"
> (1 'fpscalc-variable-name)
> (3 'fpscalc-i-task) )
> ("\\([[:word:]]\\)\\(\\[\\)\\(j\\)\\(\\]\\)"
> (1 'fpscalc-variable-name)
> (3 'fpscalc-j-task))
> ("\\([[:word:]]\\)\\(\\[\\)\\(.*\\)\\(\\]\\)"
> (1 'fpscalc-variable-name)
> (3 'fpscalc-task-name-and-index))
> ("\\(system \\)\\(.* \\)"
> (1 'fpscalc-system-keyword)
> (2 'fpscalc-system-name))
> ("\\(scalar\\|indexed\\|priority\\|blocking\\)\\( \\)+\\(\\(\\([[:word:]]\\( *\\, *\\)?\\)\\)*\\)"
> (1 'fpscalc-variable-type)
> (3 'fpscalc-variable-name))
> ("\\(tasks +\\)\\(\\(\\([[:word:]]\\( *\\, *\\)?\\)\\)*\\)"
> (1 'fpscalc-tasks-keyword)
> (2 'fpscalc-task-name-and-index))
> ))
>
> (define-generic-mode
> 'fpscalc-mode
> '("!")
> nil
> fpscalc-keywords
> '("\\.fps\\'")
> '((lambda ()
> (progn
> (setq indent-line-function 'fpscalc-indent-line)
> (local-set-key "\C-c\C-c" 'compute) )))
> "Major mode for .fps files and the fpscalc tool.")
>
--
Joe Riel
^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <mailman.9722.1387515631.10748.help-gnu-emacs@gnu.org>]
* Re: Basic font-lock without font-locking double-quoted strings
[not found] ` <mailman.9722.1387515631.10748.help-gnu-emacs@gnu.org>
@ 2013-12-20 17:37 ` Emanuel Berg
0 siblings, 0 replies; 5+ messages in thread
From: Emanuel Berg @ 2013-12-20 17:37 UTC (permalink / raw)
To: help-gnu-emacs
Joe Riel <joer@san.rr.com> writes:
>>> (define-derived-mode msdbg-mode fundamental-mode
>>> (setq > font-lock-keywords '(("EA" >
>>> . font-lock-warning-face))))
>> Does that work at all?
>
> Yes.
Really?
If you check out the help for `define-derived-mode', it
says:
(define-derived-mode CHILD PARENT NAME &optional
DOCSTRING &rest BODY)
and
NAME - a string which will appear in the status line
(e.g. "Hypertext")
So when you invoke the mode (with `M-x CHILD', as CHILD
is "the name of the command for the derived mode"),
won't it produce an error because in general it doesn't
make sense, and in particular, '(("EA"
. font-lock-warning-face)) is not a string?
At least this is what happens to me on GNU Emacs 24.3.
Compare:
(define-derived-mode msdbg-mode fundamental-mode
(setq font-lock-keywords '(("EA" . font-lock-warning-face))))
(msdbg-mode)
(message mode-name) ;; (wrong-type-argument stringp ...
(define-derived-mode msdbg-mode fundamental-mode
"MS Debug")
(msdbg-mode)
(message mode-name) ;; "MS Debug"
--
Emanuel Berg, programmer-for-rent. CV, projects, etc at uXu
underground experts united: http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-12-20 17:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-19 23:58 Basic font-lock without font-locking double-quoted strings Joe Riel
[not found] <mailman.9709.1387497505.10748.help-gnu-emacs@gnu.org>
2013-12-20 0:26 ` Emanuel Berg
2013-12-20 0:30 ` Emanuel Berg
2013-12-20 5:00 ` Joe Riel
[not found] ` <mailman.9722.1387515631.10748.help-gnu-emacs@gnu.org>
2013-12-20 17:37 ` Emanuel Berg
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).