;;; Emacs edit mode for this file is -*- Emacs-Lisp -*- ;;; $Id: .emacs-singular,v 1.13 2000-05-17 12:02:55 obachman Exp $ ;;; ;;; .emacs-singular - Emacs initialization file to use for ;;; Singular interactive mode. ;;; ;;; How you use this file very much depends on your attitude ;;; towards Emacs: ;;; ;;; 1) If you are going to use Emacs solely as frontend to ;;; Singular you do not have to worry at all about this file. ;;; 2) If you are already an experienced Emacs user you may ;;; want to copy this file's contents to your .emacs file. ;;; 3) If you are planning to become an experienced Emacs user ;;; you may use this file as starting point for your .emacs ;;; file, that is, for your Emacs initialization file. Simply ;;; copy it to your home directory and rename it to ".emacs" ;;; (without the quotes, of course). Then edit it as ;;; described below. ;;; ;;; In cases 2) and 3) you should be careful what exactly to copy ;;; to your .emacs file. In general, you need the following: ;;; ;;; o the hook-customizations with `add-hook'; ;;; o the pre-customized settings with `custom-set-variables' and ;;; `custom-set-faces'; ;;; o the code which creates menus for starting Singular; ;;; o the code which loads singular.el (located at the end of ;;; this file) you have to replace by something else, for ;;; example, an `autoload'. ;;; ;;; Here is how the Singular customization in your .emacs may ;;; look like: ;;; ;;; ;; extra key bindings ;;; (add-hook 'singular-interactive-mode-hook ;;; <... code omitted, see below for details ...>) ;;; ;;; ;; other, "non-customizable" settings ;;; (add-hook 'singular-interactive-mode-hook ;;; <... code omitted, see below for details ...>) ;;; ;;; ;; pre-customized settings ;;; (custom-set-variables ;;; <... code omitted, see below for details ...>) ;;; (custom-set-faces ;;; <... code omitted, see below for details ...>) ;;; ;;; ;; add global menus for Singular ;;; <... choose your version for either Emacs or XEmacs, see below ...> ;;; ;;; ;; add Singular toolbar for XEmacs ;;; <... insert the code below if you are running XEmacs ...> ;;; ;;; ;; add Singular Emacs home directory to `load-path' ;;; (setq load-path (cons "" load-path)) ;;; (autoload 'singular "singular" ;;; "Start Singular using default values." t) ;;; (autoload 'singular-other "singular" ;;; "Ask for arguments and start Singular." t) ;;; ;; extra key bindings (add-hook 'singular-interactive-mode-hook (function (lambda () ;; control cursor keys (cond ;; Emacs ((eq singular-emacs-flavor 'emacs) (local-set-key [C-prior] 'singular-scroll-right) (local-set-key [C-next] 'singular-scroll-left) (local-set-key [C-up] 'comint-previous-prompt) (local-set-key [C-down] 'comint-next-prompt)) ;; XEmacs (t (local-set-key [(control prior)] 'singular-scroll-right) (local-set-key [(control next)] 'singular-scroll-left) (local-set-key [(control up)] 'comint-previous-prompt) (local-set-key [(control down)] 'comint-next-prompt)))))) ;; other, "non-customizable" settings ;; lazy-lock seems to be broken under mswindows: ;; causes delay of input (only reacts after mouse click), or even total ;; hang (cond ((not (or (eq system-type 'cygwin32) (eq system-type 'windows-nt))) (add-hook 'font-lock-mode-hook 'lazy-lock-mode) (setq font-lock-support-mode 'lazy-lock-mode))) (add-hook 'singular-interactive-mode-hook (function (lambda () (font-lock-mode 1)))) ;; turn on c++-mode for files ending in ".sing" and ".lib" (setq auto-mode-alist (cons '("\\.sing\\'" . c++-mode) auto-mode-alist)) (setq auto-mode-alist (cons '("\\.lib\\'" . c++-mode) auto-mode-alist)) (add-hook 'c++-mode-hook (function (lambda () (font-lock-mode 1)))) ;; somewhat nicer scrolling ;; This causes a core dump with 21.1.9 under cygwin, when a file is opened ;; with a button ;; obachman: Fixed it with a simmple patch, by working around the assertion ;; in file indent.c line 517 (or so) ; (setq scroll-step 10) ;; this is a work-around for early version of Font Lock mode ;; which do not use `defface' to define faces. It forces ;; `custom-set-faces' to define the faces immediately. (make-face 'font-lock-comment-face) (make-face 'font-lock-string-face) ; a handy function for customizing face of point (defun customize-face-at-point () "Customize face which point is at." (interactive) (let ((face (get-text-property (point) 'face))) (if face (customize-face face) (message "No face defined at point")))) ;; tricky stuff: these customization settings are not used any ;; longer as soon as user saved her own to ~/.emacs-singular-cust (setq custom-file "~/.emacs-singular-cust") (if (file-exists-p custom-file) (load-file custom-file) ;; pre-customized settings (custom-set-variables '(mouse-yank-at-point t) '(font-lock-maximum-decoration t t) '(next-line-add-newlines nil) '(paren-mode (quote paren) nil (paren)) '(show-paren-mode t nil (paren)) '(singular-help-same-window t) '(singular-cursor-key-model (quote terminal)) '(transient-mark-mode t) '(Info-button1-follows-hyperlink t) '(singular-section-face-alist (quote ((input . singular-section-input-face) (output))))) (custom-set-faces '(show-paren-match-face ((((class color)) (:foreground "Red")))) '(font-lock-string-face ((((class color) (background light)) (:foreground "Blue")) (((class color) (background dark)) (:foreground "LightSkyBlue"))) t) '(font-lock-variable-name-face ((t (:foreground "black"))) t) '(paren-match ((t (:foreground "Red"))) t) '(singular-section-input-face ((t (:bold t)))) '(font-lock-keyword-face ((t (:bold t :foreground "violet"))) t) '(singular-section-output-face ((t (:bold nil)))) '(font-lock-type-face ((t (:bold t :foreground "violet"))) t) '(font-lock-comment-face ((t (:bold nil :foreground "Red"))) t) '(font-lock-function-name-face ((t (:bold t :foreground "blue3"))) t)) '(info-xref ((t (:foreground "blue" :bold t)))) '(info-node ((t (:foreground "blue" :bold t :italic nil)))) ;; obachman: played around a little bit, found this better ;; '(singular-section-input-face ((t (:bold t)))) ;; '(singular-section-output-face ((t (:bold nil)))) ;; '(font-lock-comment-face ((t (:bold nil :foreground "Grey30"))) t) ;; '(font-lock-string-face ((((class color) (background light)) (:foreground "Blue")) (((class color) (background dark)) (:foreground "LightSkyBlue"))) t) ;; '(paren-match ((t (:foreground "Red"))) t) ;; '(show-paren-match-face ((((class color)) (:foreground "Red"))))) ) ;; update singular-emacs-home-directory (setq singular-emacs-home-directory (concat singular-emacs-home-directory ;; we check for trailing slash and backslash ;; but unconditionally insert a slash. ;; Hopefully that works on NT, too. (if (memq (aref singular-emacs-home-directory (1- (length singular-emacs-home-directory))) '(?/ ?\\)) "" "/"))) ;; add global menus for Singular, Emacs version (unless (fboundp 'add-submenu) (setq singular-start-map (make-sparse-keymap)) (define-key singular-start-map [menu-bar singular] (cons "Singular" (make-sparse-keymap "Singular"))) (define-key singular-start-map [menu-bar singular restart] '("Start..." . singular-other)) (define-key singular-start-map [menu-bar singular start-default] '("Start default" . singular)) (setq menu-bar-final-item (append '(singular) menu-bar-final-items)) (use-local-map singular-start-map)) ;; add global menus for Singular, XEmacs version (when (fboundp 'add-submenu) (add-submenu nil '("Singular" ["Start default" singular t] ["Start..." singular-other t])) (setq-default current-menubar current-menubar)) ;; add Singular button to toolbar for XEmacs (if (fboundp 'toolbar-add-item) (toolbar-add-item (vector (toolbar-make-button-list (concat singular-emacs-home-directory "singular.xpm")) 'singular t "Start Singular") (length (specifier-instance default-toolbar)))) ;;; ;;; - load singular.el. ;;; ; get rid of superfluous "Load .emacs" menu entry on XEmacs (when (fboundp 'delete-menu-item) (delete-menu-item '("Load .emacs")) ; that is for the current buffer (let ((current-menubar (default-value 'current-menubar))) (delete-menu-item '("Load .emacs")) ; that is for all other buffers (set-default 'current-menubar current-menubar))) ; load singular.el from `singular-emacs-home-directory' (load-file (concat singular-emacs-home-directory "singular.el"))