unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* asm-mode per-file comment character patch (take 2)
@ 2006-06-11 11:38 Alastair Houghton
  0 siblings, 0 replies; only message in thread
From: Alastair Houghton @ 2006-06-11 11:38 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 171 bytes --]

Hi there,

I spotted a small mistake in my previous patch (it doesn't make  
comment-start buffer-local like it should).

I've attached a revised version to this e-mail.


[-- Attachment #2: asm-mode.patch --]
[-- Type: application/octet-stream, Size: 2072 bytes --]

--- asm-mode.el.prev	2006-06-09 12:26:09.000000000 +0100
+++ asm-mode.el	2006-06-09 19:42:46.000000000 +0100
@@ -59,6 +59,14 @@
   "*The comment-start character assumed by Asm mode."
   :type 'character
   :group 'asm)
+(make-variable-buffer-local 'asm-comment-char)
+(put 'asm-comment-char 'safe-local-variable t)
+
+(defvar asm-current-comment-char nil
+  "Holds the current comment-start character in use in this buffer.")
+(make-variable-buffer-local 'asm-current-comment-char)
+
+(add-hook 'find-file-hook (lambda () (asm-set-comment-char asm-comment-char)))
 
 (defvar asm-mode-syntax-table
   (let ((st (make-syntax-table)))
@@ -134,12 +142,9 @@
   ;; Make our own local child of asm-mode-map
   ;; so we can define our own comment character.
   (use-local-map (nconc (make-sparse-keymap) asm-mode-map))
-  (local-set-key (vector asm-comment-char) 'asm-comment)
+  (asm-set-comment-char asm-comment-char)
   (set-syntax-table (make-syntax-table asm-mode-syntax-table))
-  (modify-syntax-entry	asm-comment-char "<")
 
-  (make-local-variable 'comment-start)
-  (setq comment-start (string asm-comment-char))
   (make-local-variable 'comment-add)
   (setq comment-add 1)
   (make-local-variable 'comment-start-skip)
@@ -151,6 +156,23 @@
   (setq fill-prefix "\t")
   (run-mode-hooks 'asm-mode-hook))
 
+(defun asm-set-comment-char (newch)
+  "Set the comment character for the current buffer"
+  (interactive "c")
+  (when asm-current-comment-char
+    (local-unset-key (vector asm-current-comment-char))
+    (modify-syntax-entry asm-current-comment-char
+			 (with-syntax-table asm-mode-syntax-table
+			   (string (char-syntax asm-current-comment-char)))))
+  (setq asm-comment-char newch)
+  (setq asm-current-comment-char newch)
+  (local-set-key (vector asm-comment-char) 'asm-comment)
+  (modify-syntax-entry asm-comment-char "<")
+  (make-local-variable 'comment-start)
+  (setq comment-start (string asm-comment-char))
+  (when font-lock-mode
+    (font-lock-fontify-buffer)))
+
 (defun asm-indent-line ()
   "Auto-indent the current line."
   (interactive)

[-- Attachment #3: Type: text/plain, Size: 63 bytes --]


Kind regards,

Alastair.

--
http://www.alastairs-place.net



[-- Attachment #4: 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] only message in thread

only message in thread, other threads:[~2006-06-11 11:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-11 11:38 asm-mode per-file comment character patch (take 2) Alastair Houghton

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).