;;; srecode/srt-mode.el --- Major mode for writing screcode macros
-;; Copyright (C) 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
+;; Copyright (C) 2005, 2007-2011 Free Software Foundation, Inc.
;; This file is part of GNU Emacs.
"Keymap used in srecode mode.")
;;;###autoload
-(defun srecode-template-mode ()
- "Major-mode for writing srecode macros."
- (interactive)
- (kill-all-local-variables)
- (setq major-mode 'srecode-template-mode
- mode-name "SRecoder"
- comment-start ";;"
+(define-derived-mode srecode-template-mode fundamental-mode "SRecorder"
+ "Major-mode for writing SRecode macros."
+ (setq comment-start ";;"
comment-end "")
(set (make-local-variable 'parse-sexp-ignore-comments) t)
(set (make-local-variable 'comment-start-skip)
"\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\);+ *")
- (set-syntax-table srecode-template-mode-syntax-table)
- (use-local-map srecode-template-mode-map)
(set (make-local-variable 'font-lock-defaults)
'(srecode-font-lock-keywords
nil ;; perform string/comment fontification
nil ;; keywords are case sensitive.
- ;; This puts _ & - as a word constituant,
+ ;; This puts _ & - as a word constituent,
;; simplifying our keywords significantly
- ((?_ . "w") (?- . "w"))))
- (run-hooks 'srecode-template-mode-hook))
+ ((?_ . "w") (?- . "w")))))
;;;###autoload
(defalias 'srt-mode 'srecode-template-mode)
(beginning-of-line)
(while (re-search-forward es start t 2))
(if (re-search-forward es start t)
- ;; If there is a single, the the answer is yes.
+ ;; If there is a single, the answer is yes.
t
;; If there wasn't another, then the answer is no.
nil)
(define-mode-local-override semantic-beginning-of-context
srecode-template-mode (&optional point)
"Move to the beginning of the current context.
-Moves the the beginning of one named section."
+Moves to the beginning of one named section."
(if (semantic-up-context point)
t
(let ((es (regexp-quote (srecode-template-get-escape-start)))
(define-mode-local-override semantic-end-of-context
srecode-template-mode (&optional point)
- "Move to the beginning of the current context.
-Moves the the beginning of one named section."
+ "Move to the end of the current context.
+Moves to the end of one named section."
(let ((name (srecode-up-context-get-name point))
(tag (semantic-current-tag))
(es (regexp-quote (srecode-template-get-escape-start))))
(if (> start (point))
;; If our starting point is after the found point, that
- ;; means we are not inside the macro. Retur nil.
+ ;; means we are not inside the macro. Return nil.
nil
;; We are inside the macro, extract the text so far.
(let* ((macroend (match-beginning 0))
(define-mode-local-override semantic-analyze-possible-completions
srecode-template-mode (context)
"Return a list of possible completions based on NONTEXT."
- (save-excursion
- (set-buffer (oref context buffer))
+ (with-current-buffer (oref context buffer)
(let* ((prefix (car (last (oref context :prefix))))
(prefixstr (cond ((stringp prefix)
prefix)