[48d74cb] | 1 | ;;; Emacs edit mode for this file is -*- Emacs-Lisp -*- |
---|
[841181] | 2 | ;;; $Id: .emacs-singular,v 1.7 1999-11-01 16:14:21 obachman Exp $ |
---|
[48d74cb] | 3 | |
---|
[f7ffaa] | 4 | ;;; |
---|
[48d74cb] | 5 | ;;; .emacs-singular - Emacs initialization file to use for |
---|
| 6 | ;;; Singular interactive mode. |
---|
[f7ffaa] | 7 | ;;; |
---|
[48d74cb] | 8 | ;;; How you use this file very much depends on your attitude |
---|
| 9 | ;;; towards Emacs: |
---|
| 10 | ;;; |
---|
| 11 | ;;; 1) If you are going to use Emacs solely as frontend to |
---|
| 12 | ;;; Singular you do not have to worry at all about this file. |
---|
| 13 | ;;; 2) If you are already an experienced Emacs user you may |
---|
| 14 | ;;; want to copy this file's contents to your .emacs file. |
---|
| 15 | ;;; 3) If you are planning to become an experienced Emacs user |
---|
| 16 | ;;; you may use this file as starting point for your .emacs |
---|
| 17 | ;;; file, that is, for your Emacs initialization file. Simply |
---|
| 18 | ;;; copy it to your home directory and rename it to ".emacs" |
---|
| 19 | ;;; (without the quotes, of course). Then edit it as |
---|
| 20 | ;;; described below. |
---|
| 21 | ;;; |
---|
| 22 | ;;; In cases 2) and 3) you should be careful what exactly to copy |
---|
| 23 | ;;; to your .emacs file. In general, you need the following: |
---|
| 24 | ;;; |
---|
| 25 | ;;; o the hook-customizations with `add-hook'; |
---|
| 26 | ;;; o the pre-customized settings with `custom-set-variables' and |
---|
| 27 | ;;; `custom-set-faces'; |
---|
| 28 | ;;; o the code which creates menus for starting Singular; |
---|
| 29 | ;;; o the code which loads singular.el (located at the end of |
---|
| 30 | ;;; this file) you have to replace by something else, for |
---|
| 31 | ;;; example, an `autoload'. |
---|
| 32 | ;;; |
---|
| 33 | ;;; Here is how the Singular customization in your .emacs may |
---|
| 34 | ;;; look like: |
---|
[f7ffaa] | 35 | ;;; |
---|
[48d74cb] | 36 | ;;; ;; extra key bindings |
---|
| 37 | ;;; (add-hook 'singular-interactive-mode-hook |
---|
| 38 | ;;; <... code omitted, see below for details ...>) |
---|
[f7ffaa] | 39 | ;;; |
---|
[48d74cb] | 40 | ;;; ;; other, "non-customizable" settings |
---|
| 41 | ;;; (add-hook 'singular-interactive-mode-hook |
---|
| 42 | ;;; <... code omitted, see below for details ...>) |
---|
| 43 | ;;; |
---|
| 44 | ;;; ;; pre-customized settings |
---|
| 45 | ;;; (custom-set-variables |
---|
| 46 | ;;; <... code omitted, see below for details ...>) |
---|
| 47 | ;;; (custom-set-faces |
---|
| 48 | ;;; <... code omitted, see below for details ...>) |
---|
| 49 | ;;; |
---|
| 50 | ;;; ;; add global menus for Singular |
---|
| 51 | ;;; <... choose your version for either Emacs or XEmacs, see below ...> |
---|
| 52 | ;;; |
---|
[26ceba] | 53 | ;;; ;; add Singular toolbar for XEmacs |
---|
| 54 | ;;; <... insert the code below if you are running XEmacs ...> |
---|
| 55 | ;;; |
---|
[48d74cb] | 56 | ;;; ;; add Singular Emacs home directory to `load-path' |
---|
| 57 | ;;; (setq load-path (cons "<your-singular-emacs-home-directory>" load-path)) |
---|
| 58 | ;;; (autoload 'singular "singular" |
---|
| 59 | ;;; "Start Singular using default values." t) |
---|
| 60 | ;;; (autoload 'singular-other "singular" |
---|
| 61 | ;;; "Ask for arguments and start Singular." t) |
---|
| 62 | ;;; |
---|
| 63 | |
---|
| 64 | ;; extra key bindings |
---|
[f7ffaa] | 65 | (add-hook 'singular-interactive-mode-hook |
---|
| 66 | (function (lambda () |
---|
| 67 | ;; control cursor keys |
---|
| 68 | (cond |
---|
| 69 | ;; Emacs |
---|
| 70 | ((eq singular-emacs-flavor 'emacs) |
---|
| 71 | (local-set-key [C-prior] 'singular-scroll-right) |
---|
| 72 | (local-set-key [C-next] 'singular-scroll-left) |
---|
| 73 | (local-set-key [C-up] 'comint-previous-prompt) |
---|
| 74 | (local-set-key [C-down] 'comint-next-prompt)) |
---|
| 75 | ;; XEmacs |
---|
| 76 | (t |
---|
| 77 | (local-set-key [(control prior)] 'singular-scroll-right) |
---|
| 78 | (local-set-key [(control next)] 'singular-scroll-left) |
---|
| 79 | (local-set-key [(control up)] 'comint-previous-prompt) |
---|
| 80 | (local-set-key [(control down)] 'comint-next-prompt)))))) |
---|
| 81 | |
---|
[48d74cb] | 82 | ;; other, "non-customizable" settings |
---|
[c7a817] | 83 | (add-hook 'font-lock-mode-hook 'lazy-lock-mode) |
---|
| 84 | (setq font-lock-support-mode 'lazy-lock-mode) |
---|
| 85 | |
---|
[f7ffaa] | 86 | (add-hook 'singular-interactive-mode-hook |
---|
| 87 | (function (lambda () (font-lock-mode 1)))) |
---|
| 88 | |
---|
[c7a817] | 89 | ;; turn on c++-mode for files ending in ".sing" |
---|
| 90 | (setq auto-mode-alist (cons '("\\.sing\\'" . c++-mode) auto-mode-alist)) |
---|
[841181] | 91 | (setq auto-mode-alist (cons '("\\.lib\\'" . c++-mode) auto-mode-alist)) |
---|
| 92 | (add-hook 'c++-mode-hook |
---|
| 93 | (function (lambda () (font-lock-mode 1)))) |
---|
[c7a817] | 94 | |
---|
[f7ffaa] | 95 | ;; this is a work-around for early version of Font Lock mode |
---|
| 96 | ;; which do not use `defface' to define faces. It forces |
---|
| 97 | ;; `custom-set-faces' to define the faces immediately. |
---|
| 98 | (make-face 'font-lock-comment-face) |
---|
| 99 | (make-face 'font-lock-string-face) |
---|
| 100 | |
---|
[48d74cb] | 101 | ;; tricky stuff: these customization settings are not used any |
---|
| 102 | ;; longer as soon as user saved her own to ~/.emacs-singular-cust |
---|
| 103 | (setq custom-file "~/.emacs-singular-cust") |
---|
| 104 | (if (file-exists-p custom-file) |
---|
| 105 | (load-file custom-file) |
---|
| 106 | |
---|
| 107 | ;; pre-customized settings |
---|
[f7ffaa] | 108 | (custom-set-variables |
---|
[841181] | 109 | '(font-lock-maximum-decoration t t) |
---|
[f7ffaa] | 110 | '(next-line-add-newlines nil) |
---|
| 111 | '(paren-mode (quote paren) nil (paren)) |
---|
| 112 | '(show-paren-mode t nil (paren)) |
---|
[48d74cb] | 113 | '(singular-help-same-window t) |
---|
[c7a817] | 114 | '(singular-cursor-key-model (quote terminal)) |
---|
| 115 | '(transient-mark-mode t) |
---|
| 116 | '(singular-section-face-alist (quote ((input . singular-section-input-face) (output))))) |
---|
[841181] | 117 | |
---|
[f7ffaa] | 118 | (custom-set-faces |
---|
[841181] | 119 | '(show-paren-match-face ((((class color)) (:foreground "Red")))) |
---|
[f7ffaa] | 120 | '(font-lock-string-face ((((class color) (background light)) (:foreground "Blue")) (((class color) (background dark)) (:foreground "LightSkyBlue"))) t) |
---|
[841181] | 121 | '(font-lock-variable-name-face ((t (:foreground "black"))) t) |
---|
[f7ffaa] | 122 | '(paren-match ((t (:foreground "Red"))) t) |
---|
[841181] | 123 | '(singular-section-input-face ((t (:bold t)))) |
---|
| 124 | '(font-lock-keyword-face ((t (:bold t :foreground "violet"))) t) |
---|
| 125 | '(singular-section-output-face ((t (:bold nil)))) |
---|
| 126 | '(font-lock-type-face ((t (:bold t :foreground "violet"))) t) |
---|
| 127 | '(font-lock-comment-face ((t (:bold nil :foreground "Red"))) t) |
---|
| 128 | '(font-lock-function-name-face ((t (:bold t :foreground "blue3"))) t)) |
---|
| 129 | ;; obachman: played around a little bit, found this better |
---|
| 130 | ;; '(singular-section-input-face ((t (:bold t)))) |
---|
| 131 | ;; '(singular-section-output-face ((t (:bold nil)))) |
---|
| 132 | ;; '(font-lock-comment-face ((t (:bold nil :foreground "Grey30"))) t) |
---|
| 133 | ;; '(font-lock-string-face ((((class color) (background light)) (:foreground "Blue")) (((class color) (background dark)) (:foreground "LightSkyBlue"))) t) |
---|
| 134 | ;; '(paren-match ((t (:foreground "Red"))) t) |
---|
| 135 | ;; '(show-paren-match-face ((((class color)) (:foreground "Red"))))) |
---|
[f7ffaa] | 136 | |
---|
[48d74cb] | 137 | ) |
---|
| 138 | |
---|
[26ceba] | 139 | ;; update singular-emacs-home-directory |
---|
| 140 | (setq singular-emacs-home-directory |
---|
| 141 | (concat singular-emacs-home-directory |
---|
| 142 | ;; we check for trailing slash and backslash |
---|
| 143 | ;; but unconditionally insert a slash. |
---|
| 144 | ;; Hopefully that works on NT, too. |
---|
| 145 | (if (memq (aref singular-emacs-home-directory |
---|
| 146 | (1- (length singular-emacs-home-directory))) |
---|
| 147 | '(?/ ?\\)) |
---|
| 148 | "" "/"))) |
---|
| 149 | |
---|
[48d74cb] | 150 | ;; add global menus for Singular, Emacs version |
---|
| 151 | (unless (fboundp 'add-submenu) |
---|
[c7a817] | 152 | (setq singular-start-map (make-sparse-keymap)) |
---|
| 153 | (define-key singular-start-map [menu-bar singular] |
---|
| 154 | (cons "Singular" (make-sparse-keymap "Singular"))) |
---|
| 155 | (define-key singular-start-map [menu-bar singular restart] |
---|
[48d74cb] | 156 | '("Start..." . singular-other)) |
---|
[c7a817] | 157 | (define-key singular-start-map [menu-bar singular start-default] |
---|
[48d74cb] | 158 | '("Start default" . singular)) |
---|
[c7a817] | 159 | (setq menu-bar-final-item (append '(singular) menu-bar-final-items)) |
---|
| 160 | (use-local-map singular-start-map)) |
---|
[48d74cb] | 161 | |
---|
| 162 | ;; add global menus for Singular, XEmacs version |
---|
[c2f709] | 163 | (when (fboundp 'add-submenu) |
---|
| 164 | (add-submenu nil |
---|
| 165 | '("Singular" |
---|
| 166 | ["Start default" singular t] |
---|
| 167 | ["Start..." singular-other t])) |
---|
| 168 | (setq-default current-menubar current-menubar)) |
---|
[48d74cb] | 169 | |
---|
[26ceba] | 170 | ;; add Singular button to toolbar for XEmacs |
---|
| 171 | (if (fboundp 'toolbar-add-item) |
---|
| 172 | (toolbar-add-item |
---|
| 173 | (vector |
---|
| 174 | (toolbar-make-button-list (concat singular-emacs-home-directory |
---|
| 175 | "singular.xpm")) |
---|
| 176 | 'singular t "Start Singular") |
---|
| 177 | (length (specifier-instance default-toolbar)))) |
---|
| 178 | |
---|
[f7ffaa] | 179 | ;;; |
---|
[48d74cb] | 180 | ;;; - load singular.el. |
---|
[f7ffaa] | 181 | ;;; |
---|
[48d74cb] | 182 | |
---|
| 183 | ;; get rid of superfluous "Load .emacs" menu entry on XEmacs |
---|
| 184 | (when (fboundp 'delete-menu-item) |
---|
| 185 | (delete-menu-item '("Load .emacs")) ; that is for the current buffer |
---|
| 186 | (let ((current-menubar (default-value 'current-menubar))) |
---|
| 187 | (delete-menu-item '("Load .emacs")) ; that is for all other buffers |
---|
| 188 | (set-default 'current-menubar current-menubar))) |
---|
| 189 | |
---|
| 190 | ;; load singular.el from `singular-emacs-home-directory' |
---|
[26ceba] | 191 | (load-file (concat singular-emacs-home-directory "singular.el")) |
---|