- Timestamp:
- Jul 23, 1998, 10:38:08 AM (26 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- f7ac05f40537c46c4f7c55dd263035e13f651e01
- Parents:
- 1135fd63a8c300daf52527692ee2c9ba30e88965
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
emacs/singular.el
r1135fd6 r1735b4e 1 1 ;;; singular.el --- Emacs support for Computer Algebra System Singular 2 2 3 ;; $Id: singular.el,v 1. 3 1998-07-22 15:09:34schmidt Exp $3 ;; $Id: singular.el,v 1.4 1998-07-23 08:38:08 schmidt Exp $ 4 4 5 5 ;;; Commentary: … … 9 9 ;;; Code: 10 10 11 ;;{{{ Style and coding conventions 12 13 ;; Style and coding conventions: 14 ;; 15 ;; - "Singular" is written with an upper-case `S' in comments, doc 16 ;; strings, and messages. As part of symbols, it is written with 17 ;; a lower-case `s'. 18 ;; - use a `fill-column' of 70 for doc strings and comments 19 ;; - use foldings to structure the source code but try not to exceed a 20 ;; maximal depth of two folding (one folding in another folding which is 21 ;; on top-level) 22 ;; - use lowercase folding titles except for first word 23 ;; - folding-marks are `;;{{{' and `;;}}}' resp., for sake of standard 24 ;; conformity 25 ;; 26 ;; - use `singular' as prefix for all global symbols 27 ;; - use `singular-debug' as prefix for all global symbols concerning 28 ;; debugging. 29 ;; 30 ;; - mark dependencies on Emacs flavor/version with a comment of the form 31 ;; `;; Emacs[ version]' resp. `;; XEmacs[ version]' 32 ;; - use a `cond' statement to execute Emacs flavor/version-dependent code, 33 ;; not `if'. This is to make such checks more extensible. 34 ;; - try to define different functions for different flavors/version 35 ;; and use `singular-fset' at library-loading time to set the function 36 ;; you really need. If the function is named `singular-<basename>', the 37 ;; flavor/version-dependent functions should be named 38 ;; `singular-<flavor>[-<version>]-<basename>'. 39 40 ;; - use `singular-debug' for debugging output/actions 41 ;; - to switch between buffer and process names, use the functions 42 ;; `singular-process-name-to-buffer-name' and 43 ;; `singular-buffer-name-to-process-name' 44 45 ;;}}} 46 11 47 (require 'comint) 12 48 13 ;;{{{ Code Common to Both Modes14 ;;{{{ Debugging Stuff49 ;;{{{ Code common to both modes 50 ;;{{{ Debugging stuff 15 51 (defvar singular-debug nil 16 52 "*List of modes to debug or `all' to debug all modes. 17 53 Currently, only the mode `interactive' is supported.") 54 55 (defun singular-debug-format (string) 56 "Return STRING in a nicer format." 57 58 ;; is there any better way to replace in strings?? 59 (while (string-match "\n" string) 60 (setq string (concat (substring string 0 (match-beginning 0)) 61 "^J" 62 (substring string (match-end 0))))) 63 64 (if (> (length string) 16) 65 (concat "<" (substring string 0 7) ">...<" (substring string -8) ">") 66 (concat "<" string ">"))) 18 67 19 68 (defmacro singular-debug (mode form) … … 25 74 ,form)) 26 75 ;;}}} 27 ;;}}} 28 29 ;;{{{ Singular Interactive Mode 30 ;;{{{ Key Map 76 77 ;;{{{ Determining version 78 (defvar singular-emacs-flavor nil 79 "A symbol describing the current Emacs. 80 Currently, only Emacs \(`emacs') and XEmacs are supported \(`xemacs').") 81 82 (defvar singular-emacs-major-version nil 83 "An integer describing the major version of the current emacs.") 84 85 (defvar singular-emacs-minor-version nil 86 "An integer describing the major version of the current emacs.") 87 88 (defun singular-fset (real-function emacs-function xemacs-function 89 &optional emacs-19-function) 90 "Set REAL-FUNCTION to one of the functions, in dependency on Emacs flavor and version. 91 Sets REAL-FUNCTION to XEMACS-FUNCTION if `singular-emacs-flavor' is 92 `xemacs'. Sets REAL-FUNCTION to EMACS-FUNCTION if `singular-emacs-flavor' 93 is `emacs' and `singular-emacs-major-version' is 20. Otherwise, sets 94 REAL-FUNCTION to EMACS-19-FUNCTION which defaults to EMACS-FUNCTION. 95 96 This is not as common as would be desirable. But it is sufficient so far." 97 (cond 98 ;; XEmacs 99 ((eq singular-emacs-flavor 'xemacs) 100 (fset real-function xemacs-function)) 101 ;; Emacs 20 102 ((eq singular-emacs-major-version 20) 103 (fset real-function emacs-function)) 104 ;; Emacs 19 105 (t 106 (fset real-function (or emacs-19-function emacs-function))))) 107 108 (defun singular-set-version () 109 "Determine flavor, major version, and minor version of current emacs. 110 singular.el is guaranteed to run on Emacs 19.34, Emacs 20.2, and XEmacs 111 20.2. It should run on newer version and on slightly older ones, too." 112 113 ;; get major and minor versions first 114 (if (and (boundp 'emacs-major-version) 115 (boundp 'emacs-minor-version)) 116 (setq singular-emacs-major-version emacs-major-version 117 singular-emacs-minor-version emacs-minor-version) 118 (with-output-to-temp-buffer "*singular warnings*" 119 (princ 120 "You seem to have quite an old Emacs or XEmacs version. Some of the 121 features from singular.el will not work properly. Consider upgrading to a 122 more recent version of Emaxs or XEmacs. singular.el is guaranteed to run 123 on Emacs 19.34, Emacs 20.2, and XEmacs 20.2.")) 124 ;; assume the oldest version we support 125 (setq singular-emacs-major-version 19 126 singular-emacs-minor-version 34)) 127 128 ;; get flavor 129 (if (string-match "XEmacs\\|Lucid" emacs-version) 130 (setq singular-emacs-flavor 'xemacs) 131 (setq singular-emacs-flavor 'emacs))) 132 133 (singular-set-version) 134 ;;}}} 135 ;;}}} 136 137 ;;{{{ Singular interactive mode 138 ;;{{{ Key map 31 139 (defvar singular-interactive-mode-map () 32 140 "Key map to use in Singular interactive mode.") 33 141 34 (if singular-interactive-mode-map 35 () 36 (setq singular-interactive-mode-map 37 (nconc (make-sparse-keymap) comint-mode-map))) 142 (if (not singular-interactive-mode-map) 143 (cond 144 ;; Emacs 145 ((eq singular-emacs-flavor 'emacs) 146 (setq singular-interactive-mode-map 147 (nconc (make-sparse-keymap) comint-mode-map))) 148 ;; XEmacs 149 (t 150 (setq singular-interactive-mode-map (make-keymap)) 151 (set-keymap-parents singular-interactive-mode-map (list comint-mode-map)) 152 (set-keymap-name singular-interactive-mode-map 153 'singular-interactive-mode-map)))) 38 154 ;;}}} 39 155 … … 58 174 ;;}}} 59 175 60 ;;{{{ Customiz ation Variables of comint176 ;;{{{ Customizing variables of comint 61 177 62 178 ;; Note: … … 118 234 ;;}}} 119 235 120 ;;{{{ Singular Interactive Mode 236 ;;{{{ Input and output filters 237 (defconst singular-bogus-output-filter-calls 238 (cond 239 ;; XEmacs 240 ((eq singular-emacs-flavor 'xemacs) 2) 241 ;; Emacs 242 (t 1)) 243 "Number of bogus runs of hooks on `comint-output-filter-functions'.") 244 245 ;; debugging filters 246 (defvar singular-debug-bogus-output-filter-cnt 0 247 "Number of bogus runs of hooks on `comint-output-filter-functions' yet to do. 248 This variable is set to `singular-bogus-output-filter-calls' in 249 `singular-debug-input-filter' and decremented for each bogus run of 250 `singular-debug-output-filter' until it becomes zero.") 251 252 (defun singular-debug-input-filter (string) 253 "Echo STRING and reset `singular-debug-bogus-output-filter-cnt'." 254 (message "Input filter: %s" (singular-debug-format string)) 255 (setq singular-debug-bogus-output-filter-cnt 256 singular-bogus-output-filter-calls)) 257 258 (defun singular-debug-output-filter (string) 259 "Echo STRING and `singular-debug-bogus-output-filter-cnt'. 260 Decrement " 261 (if (zerop singular-debug-bogus-output-filter-cnt) 262 (message "Output filter (real): %s" 263 (singular-debug-format string)) 264 (message "Output filter (bogus %d): %s" 265 singular-debug-bogus-output-filter-cnt 266 (singular-debug-format string)) 267 (setq singular-debug-bogus-output-filter-cnt 268 (1- singular-debug-bogus-output-filter-cnt)))) 269 ;;}}} 270 271 ;;{{{ Singular interactive mode 121 272 122 273 ;; Note: … … 194 345 (setq comint-input-ring-file-name nil)) 195 346 347 ;; marking of input and output 348 (singular-debug 'interactive-filter 349 (add-hook 'comint-input-filter-functions 350 'singular-debug-input-filter nil t)) 351 (singular-debug 'interactive-filter 352 (add-hook 'comint-output-filter-functions 353 'singular-debug-output-filter nil t)) 354 196 355 (run-hooks 'singular-interactive-mode-hook)) 197 356 ;;}}} 198 357 199 ;;{{{ Starting Singular358 ;;{{{ Starting singular 200 359 (defvar singular-start-file "~/.emacs_singularrc" 201 360 "Name of start-up file to pass to Singular.
Note: See TracChangeset
for help on using the changeset viewer.