* asm-mode comment character patch (with diff -c this time)
@ 2006-06-14 11:21 Alastair Houghton
0 siblings, 0 replies; only message in thread
From: Alastair Houghton @ 2006-06-14 11:21 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 46 bytes --]
Hi all,
Here's the patch in diff -c format:
[-- Attachment #2: asm-mode.patch --]
[-- Type: application/octet-stream, Size: 3303 bytes --]
*** asm-mode.el.prev 2006-06-09 12:26:09.000000000 +0100
--- asm-mode.el 2006-06-13 12:11:21.000000000 +0100
***************
*** 60,65 ****
--- 60,82 ----
:type 'character
:group 'asm)
+ (defun asm-comment-char-valid-p (val)
+ "Returns t if the argument is a valid value for `asm-comment-char`."
+ (if (and (stringp val) (= (length val) 1))
+ (char-valid-p (elt val 0))
+ (char-valid-p val)))
+
+ (put 'asm-comment-char 'safe-local-variable 'asm-comment-char-valid-p)
+
+ (defvar asm-current-comment-char nil
+ "Holds the current comment-start character in use in the current buffer.")
+
+ (defun asm-mode-ff-hook ()
+ (when (eq major-mode 'asm-mode)
+ (asm-set-comment-char asm-comment-char)))
+
+ (add-hook 'find-file-hook 'asm-mode-ff-hook)
+
(defvar asm-mode-syntax-table
(let ((st (make-syntax-table)))
(modify-syntax-entry ?\n ">" st)
***************
*** 134,145 ****
;; 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)
(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,159 ----
;; 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))
(set-syntax-table (make-syntax-table asm-mode-syntax-table))
! (asm-set-comment-char asm-comment-char)
(make-local-variable 'comment-add)
(setq comment-add 1)
(make-local-variable 'comment-start-skip)
***************
*** 151,156 ****
--- 165,203 ----
(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")
+
+ ;; Check that we've got a valid argument
+ (unless (asm-comment-char-valid-p newch)
+ (error "comment characters must be a character or a single-character string"))
+
+ ;; Check for strings
+ (when (and (stringp newch) (= (length newch) 1))
+ (setq newch (elt newch 0)))
+
+ ;; First, undo the existing comment character setup
+ (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)))))
+
+ ;; Now set-up the new comment character
+ (make-local-variable 'asm-comment-char)
+ (make-local-variable '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))
+
+ ;; Finally, re-fontify, if necessary
+ (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-14 11:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-14 11:21 asm-mode comment character patch (with diff -c this time) Alastair Houghton
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.