aboutsummaryrefslogtreecommitdiff
path: root/elisp
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2004-10-16 14:54:46 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2004-10-16 14:54:46 +0000
commit27e9921809dfe421242b8730c3c39e5061310a30 (patch)
tree6009af6c0be062dcaff6c288cc6745d168afd32c /elisp
parenta5d39b70625b2bc344d31a6742ecfbd4cb2bff9a (diff)
downloadellinika-27e9921809dfe421242b8730c3c39e5061310a30.tar.gz
ellinika-27e9921809dfe421242b8730c3c39e5061310a30.tar.bz2
Derive ellinika-dict-mode from ellinika-mode
git-svn-id: file:///home/puszcza/svnroot/ellinika/trunk@252 941c8c0f-9102-463b-b60b-cd22ce0e6858
Diffstat (limited to 'elisp')
-rw-r--r--elisp/ellinika-dict-mode.el198
1 files changed, 47 insertions, 151 deletions
diff --git a/elisp/ellinika-dict-mode.el b/elisp/ellinika-dict-mode.el
index ae851d9..eefec36 100644
--- a/elisp/ellinika-dict-mode.el
+++ b/elisp/ellinika-dict-mode.el
@@ -23,22 +23,11 @@
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
-(defun greek-input (arg)
- (interactive "p")
- (set-input-method 'greek))
-
-(defun alt-input (arg)
- (interactive "p")
- (if (boundp 'alternative-input-method)
- (set-input-method alternative-input-method)
- (inactivate-input-method)))
-
-(set-language-environment 'utf-8)
-
-
-;;;
+(eval-when-compile
+ ;; We use functions from these modules
+ (mapcar 'require '(ellinika-mode)))
-(defun ellinika-guess-syntax ()
+(defun ellinika-dict-guess-syntax ()
(save-excursion
(catch 'loop
(while (search-backward-regexp "<\\(/?[^ >]+\\)\\(\\s +[^>]*\\)?>"
@@ -48,7 +37,7 @@
(match-end 1))))
(cond
((or (string-equal tag "T") (string-equal tag "/T"))
- (throw 'loop (ellinika-guess-syntax)))
+ (throw 'loop (ellinika-dict-guess-syntax)))
((looking-at "</[MKXPF]>")
(throw 'loop 'node))
((or (looking-at "</NODE>") (looking-at "<DICT>"))
@@ -64,34 +53,8 @@
(throw 'loop (intern tag))))))
'initial)))
-
-(defun ellinika-find-open-tag-internal ()
- (catch 'loop
- (let ((tag-list nil))
- (while (search-backward-regexp "<\\(/?[^ >]+\\)\\(\\s +[^>]*\\)?>"
- nil t)
- (let ((tag (buffer-substring
- (match-beginning 1)
- (match-end 1))))
- (cond
- ((char-equal (string-to-char tag) ?\/)
- (setq tag-list (cons (substring tag 1)
- tag-list)))
- ((looking-at "<!"))
- ((looking-at "<[^ >]+\\(\\s +[^>]*\\)?/>"))
- ((string-equal (car tag-list) tag)
- (setq tag-list (cdr tag-list)))
- (t
- (throw 'loop tag))))))))
-
-(defun ellinika-find-open-tag (&optional move-point)
- (if move-point
- (ellinika-find-open-tag-internal)
- (save-excursion
- (ellinika-find-open-tag-internal))))
-
-(defun ellinika-select-input-method nil
- (let ((syntax (ellinika-guess-syntax)))
+(defun ellinika-dict-select-input-method nil
+ (let ((syntax (ellinika-dict-guess-syntax)))
(cond
((eq syntax 'ascii-input)
(inactivate-input-method))
@@ -102,35 +65,14 @@
((or (eq syntax 'node) (eq syntax 'initial))
(inactivate-input-method)))))
-(defun ellinika-newline (arg)
+(defun ellinika-dict-newline (arg)
(interactive "p")
- (ellinika-select-input-method)
+ (ellinika-dict-select-input-method)
(newline-and-indent))
-(defun ellinika-electric-obrace (arg)
- (interactive "p")
- (inactivate-input-method)
- (self-insert-command arg))
-
-(defun ellinika-electric-cbrace (arg)
- (interactive "p")
- (inactivate-input-method)
- (self-insert-command arg)
- (ellinika-select-input-method))
-
-(defun ellinika-close-tag (arg)
+(defun ellinika-dict-begin-node (arg)
(interactive "p")
- (let ((tag (ellinika-find-open-tag)))
- (cond
- (tag
- (insert (concat "</" tag ">"))
- (ellinika-select-input-method))
- (t
- (message "No open tags")))))
-
-(defun ellinika-begin-node (arg)
- (interactive "p")
- (let ((syntax (ellinika-guess-syntax)))
+ (let ((syntax (ellinika-dict-guess-syntax)))
(cond
((eq syntax 'initial)
(beginning-of-line)
@@ -142,7 +84,7 @@
(t
(message "Cannot start node here")))))
-(defun ellinika-init-block (tag &optional input-method)
+(defun ellinika-dict-init-block (tag &optional input-method)
(beginning-of-line)
(if (string-equal (ellinika-find-open-tag) "P")
(insert " "))
@@ -151,65 +93,65 @@
(when input-method
(set-input-method input-method)))
-(defun ellinika-begin-article (arg)
+(defun ellinika-dict-begin-article (arg)
(interactive "p")
- (let ((syntax (ellinika-guess-syntax)))
+ (let ((syntax (ellinika-dict-guess-syntax)))
(cond
((eq syntax 'node)
- (ellinika-init-block "M" (if (boundp 'alternative-input-method)
+ (ellinika-dict-init-block "M" (if (boundp 'alternative-input-method)
alternative-input-method
nil)))
(t
(message "Cannot start key here")))))
-(defun ellinika-begin-key (arg)
+(defun ellinika-dict-begin-key (arg)
(interactive "p")
- (let ((syntax (ellinika-guess-syntax)))
+ (let ((syntax (ellinika-dict-guess-syntax)))
(cond
((eq syntax 'node)
- (ellinika-init-block "K" 'greek))
+ (ellinika-dict-init-block "K" 'greek))
(t
(message "Cannot start key here")))))
-(defun ellinika-begin-pos (arg)
+(defun ellinika-dict-begin-pos (arg)
(interactive "p")
- (let ((syntax (ellinika-guess-syntax)))
+ (let ((syntax (ellinika-dict-guess-syntax)))
(cond
((eq syntax 'node)
- (ellinika-init-block "P" 'greek))
+ (ellinika-dict-init-block "P" 'greek))
(t
(message "Cannot start pos here")))))
-(defun ellinika-begin-forms (arg)
+(defun ellinika-dict-begin-forms (arg)
(interactive "p")
- (let ((syntax (ellinika-guess-syntax)))
+ (let ((syntax (ellinika-dict-guess-syntax)))
(cond
((eq syntax 'node)
- (ellinika-init-block "F" 'greek))
+ (ellinika-dict-init-block "F" 'greek))
(t
(message "Cannot start forms here")))))
-(defun ellinika-begin-xref (arg)
+(defun ellinika-dict-begin-xref (arg)
(interactive "p")
- (let ((syntax (ellinika-guess-syntax)))
+ (let ((syntax (ellinika-dict-guess-syntax)))
(cond
((eq syntax 'node)
- (ellinika-init-block "X" 'greek))
+ (ellinika-dict-init-block "X" 'greek))
(t
(message "Cannot start xref here")))))
-(defun ellinika-begin-ant (arg)
+(defun ellinika-dict-begin-ant (arg)
(interactive "p")
- (let ((syntax (ellinika-guess-syntax)))
+ (let ((syntax (ellinika-dict-guess-syntax)))
(cond
((eq syntax 'node)
- (ellinika-init-block "A" 'greek))
+ (ellinika-dict-init-block "A" 'greek))
(t
(message "Cannot start antonym here")))))
-(defun ellinika-begin-topic (arg)
+(defun ellinika-dict-begin-topic (arg)
(interactive "p")
- (let ((syntax (ellinika-guess-syntax)))
+ (let ((syntax (ellinika-dict-guess-syntax)))
(cond
((eq syntax 'initial)
(insert "<T ID=\"\">\n</T>")
@@ -222,7 +164,7 @@
(t
(message "Cannot start topic here")))))
-(defun ellinika-begin-comment (arg)
+(defun ellinika-dict-begin-comment (arg)
(interactive "p")
(let ((tag (ellinika-find-open-tag)))
(cond
@@ -233,7 +175,7 @@
(t
(message "Cannot start comment here")))))
-(defun ellinika-begin-expl (arg)
+(defun ellinika-dict-begin-expl (arg)
(interactive "p")
(let ((tag (ellinika-find-open-tag)))
(cond
@@ -244,72 +186,26 @@
(t
(message "Cannot start explanation here")))))
-(defun ellinika-insert-include (arg)
- (interactive "p")
- (beginning-of-line)
- (insert "<INCLUDE FILE=\"\" />")
- (backward-char 4)
- (inactivate-input-method))
-
-(defcustom alternative-input-method nil
- "Defines input-method for non-greek text in this buffer.")
-
-(defcustom alternative-dictionary nil
- "Defines alternative (non-greek) spell-checking dictionary for this buffer.")
-
-(defun ellinika-run-ispell (dict)
- (let ((ispell-skip-html t)
- (ispell-local-dictionary dict))
- (ispell)))
-
-(defun ellinika-ispell-greek (arg)
- (interactive "p")
- (ellinika-run-ispell "greek"))
-
-(defun ellinika-ispell-alt (arg)
- (interactive "p")
- (ellinika-run-ispell (if alternative-dictionary
- alternative-dictionary
- (error "Alternative dictionary not defined"))))
-
-(defun ellinika-ispell (arg)
- (interactive "p")
- (ellinika-run-ispell (if (> arg 0)
- "greek"
- (if alternative-dictionary
- alternative-dictionary
- (error "Alternative dictionary not defined")))))
-
;;;###autoload
-(define-derived-mode ellinika-dict-mode sgml-mode "Ellinika-Dict"
+(define-derived-mode ellinika-dict-mode ellinika-mode "Ellinika-Dict"
"Major mode for editing Ellinika dictionary sources.
Key bindings:
\\{ellinika-dict-mode-map}"
- (make-variable-buffer-local 'alternative-input-method)
- (make-variable-buffer-local 'alternative-dictionary)
+ (ellinika-set-close-tag-hook 'ellinika-dict-select-input-method)
- (define-key ellinika-dict-mode-map "\C-c\C-b" 'ellinika-begin-node)
- (define-key ellinika-dict-mode-map "\C-c\C-m" 'ellinika-begin-article)
- (define-key ellinika-dict-mode-map "\C-c\C-k" 'ellinika-begin-key)
- (define-key ellinika-dict-mode-map "\C-c\C-p" 'ellinika-begin-pos)
- (define-key ellinika-dict-mode-map "\C-c\C-f" 'ellinika-begin-forms)
- (define-key ellinika-dict-mode-map "\C-c\C-x" 'ellinika-begin-xref)
- (define-key ellinika-dict-mode-map "\C-c\C-a" 'ellinika-begin-ant)
- (define-key ellinika-dict-mode-map "\C-c\C-t" 'ellinika-begin-topic)
- (define-key ellinika-dict-mode-map "\C-c\C-c" 'ellinika-begin-comment)
- (define-key ellinika-dict-mode-map "\C-c\C-e" 'ellinika-begin-expl)
- (define-key ellinika-dict-mode-map "\C-c\C-i" 'ellinika-insert-include)
- (define-key ellinika-dict-mode-map "\C-c\C-g" 'ellinika-ispell-greek)
- (define-key ellinika-dict-mode-map "\C-c\C-s" 'ellinika-ispell-alt)
-
- (define-key ellinika-dict-mode-map "\M-g" 'greek-input)
- (define-key ellinika-dict-mode-map "\M-r" 'alt-input)
- (define-key ellinika-dict-mode-map "\C-c>" 'ellinika-close-tag)
- (define-key ellinika-dict-mode-map "<" 'ellinika-electric-obrace)
- (define-key ellinika-dict-mode-map ">" 'ellinika-electric-cbrace)
- (define-key ellinika-dict-mode-map "\C-m" 'ellinika-newline))
+ (define-key ellinika-dict-mode-map "\C-c\C-b" 'ellinika-dict-begin-node)
+ (define-key ellinika-dict-mode-map "\C-c\C-m" 'ellinika-dict-begin-article)
+ (define-key ellinika-dict-mode-map "\C-c\C-k" 'ellinika-dict-begin-key)
+ (define-key ellinika-dict-mode-map "\C-c\C-p" 'ellinika-dict-begin-pos)
+ (define-key ellinika-dict-mode-map "\C-c\C-f" 'ellinika-dict-begin-forms)
+ (define-key ellinika-dict-mode-map "\C-c\C-x" 'ellinika-dict-begin-xref)
+ (define-key ellinika-dict-mode-map "\C-c\C-a" 'ellinika-dict-begin-ant)
+ (define-key ellinika-dict-mode-map "\C-c\C-t" 'ellinika-dict-begin-topic)
+ (define-key ellinika-dict-mode-map "\C-c\C-c" 'ellinika-dict-begin-comment)
+ (define-key ellinika-dict-mode-map "\C-c\C-e" 'ellinika-dict-begin-expl)
+ (define-key ellinika-dict-mode-map "\C-m" 'ellinika-dict-newline))
(provide 'ellinika-dict-mode)

Return to:

Send suggestions and report system problems to the System administrator.