* bug#8933: 'js-mode' break single char comment highlighting from 'define-generic-mode'.
@ 2011-06-24 21:23 Oleksandr Gavenko
2011-06-27 9:08 ` Lawrence Mitchell
0 siblings, 1 reply; 3+ messages in thread
From: Oleksandr Gavenko @ 2011-06-24 21:23 UTC (permalink / raw)
To: 8933
I use Emacs 23.3.
$ emacs -Q
Next eval:
(define-generic-mode my-mode
'(?\; ?#)
nil nil nil nil)
And open file with two or more lines:
; commented line (1)
wrongly highlighted line (2)
another wrongly highlighted line (3)
After 'M-x my-mode RET' line (1) highlighted as comment line.
Another line not.
Then open any .js file so js-mode loaded and back to 'my-mode'
file and revert it.
Now all line highlighted as comment lines!
Because of this I switch .js files to c++-mode (from my .emacs):
(setq auto-mode-alist (rassq-delete-all 'js-mode auto-mode-alist))
(add-to-list 'auto-mode-alist '("\\.js$" . c++-mode))
and move '(desktop-save-mode 1)' below this lines.
For C-like comments this bug not reproduced.
--
Best regards!
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#8933: 'js-mode' break single char comment highlighting from 'define-generic-mode'.
2011-06-24 21:23 bug#8933: 'js-mode' break single char comment highlighting from 'define-generic-mode' Oleksandr Gavenko
@ 2011-06-27 9:08 ` Lawrence Mitchell
2011-06-30 16:23 ` Stefan Monnier
0 siblings, 1 reply; 3+ messages in thread
From: Lawrence Mitchell @ 2011-06-27 9:08 UTC (permalink / raw)
To: 8933
Oleksandr Gavenko wrote:
> I use Emacs 23.3.
Also reproducible in Emacs 24.0.50
> $ emacs -Q
> Next eval:
> (define-generic-mode my-mode
> '(?\; ?#)
> nil nil nil nil)
> And open file with two or more lines:
> ; commented line (1)
> wrongly highlighted line (2)
> another wrongly highlighted line (3)
> After 'M-x my-mode RET' line (1) highlighted as comment line.
> Another line not.
> Then open any .js file so js-mode loaded and back to 'my-mode'
> file and revert it.
> Now all line highlighted as comment lines!
This is because js-mode stomps on the default value of
comment-start and comment-end (rather than using
make-local-variable). This confuses generic-mode.
Cheers,
Lawrence
Here's a commit-message plus patch.
js-mode: Don't stomp on comment-start/end's default value
* progmodes/js.el (js-mode): Ensure comment-start and comment-end
are local variables (Bug#8933).
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 5bc756e..4b3a2ba 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2011-06-27 Lawrence Mitchell <wence@gmx.li>
+
+ * progmodes/js.el (js-mode): Ensure comment-start and comment-end
+ are local variables (Bug#8933).
+
2011-06-22 Lawrence Mitchell <wence@gmx.li>
* net/browse-url.el (browse-url-xdg-open): Use 0, rather than nil
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index a0437cc..1bdcb4c 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -3306,8 +3306,8 @@ If one hasn't been set, or if it's stale, prompt for a new one."
#'js--which-func-joiner)
;; Comments
- (setq comment-start "// ")
- (setq comment-end "")
+ (set (make-local-variable 'comment-start) "// ")
+ (set (make-local-variable 'comment-end) "")
(set (make-local-variable 'fill-paragraph-function)
'js-c-fill-paragraph)
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-06-30 16:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-24 21:23 bug#8933: 'js-mode' break single char comment highlighting from 'define-generic-mode' Oleksandr Gavenko
2011-06-27 9:08 ` Lawrence Mitchell
2011-06-30 16:23 ` Stefan Monnier
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).