Changeset a0cde2 in git
- Timestamp:
- Jul 22, 1998, 12:37:46 PM (26 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 5fcd96638c9cc6007c245fd9dbd9b0818cebc986
- Parents:
- cf34a0fc5bbcdd46cd586ff09badd3261d953574
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
emacs/singular.el
rcf34a0 ra0cde2 10 10 11 11 ;;{{{ Code Common to Both Modes 12 ;;{{{ Debugging Stuff 12 13 (defvar singular-debug nil 13 "*List of states to debug. 14 Currently, only the state `interactive' is supported. 15 16 This variable is buffer local.") 17 18 (defmacro singular-debug (state form) 14 "*List of modes to debug or `all' to debug all modes. 15 Currently, only the mode `interactive' is supported.") 16 17 (defmacro singular-debug (mode form) 19 18 "Major debugging hook for singular.el. 20 Evaluates FORM if and only if STATE is an element of 21 `singular-debug'." 22 `(if (memq ,state singular-debug) ,form)) 19 Evaluates FORM if and only if `singular-debug' equals `all' or if MODE 20 is an element of `singular-debug'." 21 `(if (or (eq singular-debug 'all) 22 (memq ,mode singular-debug)) 23 ,form)) 24 ;;}}} 23 25 ;;}}} 24 26 … … 34 36 ;;}}} 35 37 38 ;;{{{ Miscellaneous 39 40 ;; Note: 41 ;; 42 ;; We assume a one-to-one correspondance between Singular buffers 43 ;; and Singular processes. We always have 44 ;; (equal buffer-name (concat "*" process-name "*")). 45 46 (defun singular-buffer-name-to-process-name (buffer-name) 47 "Create the process name for BUFFER-NAME. 48 The process name is the buffer name with surrounding `*' stripped 49 off." 50 (substring buffer-name 1 -1)) 51 52 (defun singular-process-name-to-buffer-name (process-name) 53 "Create the buffer name for PROCESS-NAME. 54 The buffer name is the process name with surrounding `*'." 55 (concat "*" process-name "*")) 56 ;;}}} 57 36 58 ;;{{{ Customization Variables of comint 37 59 (defvar singular-prompt-regexp "^> " … … 42 64 (defvar singular-delimiter-argument-list '(?= ?\( ?\) ?, ?;) 43 65 "List of characters to recognize as separate arguments. 44 This variable is used to initialize `comint-delimiter-argument-list'.") 66 This variable is used to initialize `comint-delimiter-argument-list' 67 when Singular interactive mode starts up.") 45 68 46 69 (defvar singular-input-ignoredups t 47 70 "*If non-nil, don't add input matching the last on the input ring. 48 This variable is used to initialize `comint-input-ignoredups'.") 71 This variable is used to initialize `comint-input-ignoredups' when 72 Singular interactive mode starts up.") 49 73 50 74 (defvar singular-buffer-maximum-size 2048 51 75 "*The maximum size in lines for Singular buffers. 52 This variable is used to initialize `comint-buffer-maximum-size'. 53 54 This variable is buffer-local.") 76 This variable is used to initialize `comint-buffer-maximum-size' when 77 Singular interactive mode starts up.") 55 78 56 79 (defvar singular-input-ring-size 64 57 80 "Size of input history ring. 58 This variable is used to initialize `comint-input-ring-size'.") 59 ;;}}} 60 61 ;;{{{ Miscellaneous 62 63 ;; Note: 64 ;; 65 ;; We assume a one-to-one correspondance between Singular buffers 66 ;; and Singular processes. We always have 67 ;; (equal buffer-name (concat "*" process-name "*")). 68 69 (defun singular-buffer-name-to-process-name (buffer-name) 70 "Create the process name for BUFFER-NAME. 71 The process name is the buffer name with surrounding `*' stripped 72 off." 73 (substring buffer-name 1 -1)) 74 75 (defun singular-process-name-to-buffer-name (process-name) 76 "Create the buffer name for PROCESS-NAME. 77 The buffer name is the process name with surrounding `*'." 78 (concat "*" process-name "*")) 79 ;;}}} 80 81 This variable is used to initialize `comint-input-ring-size' when 82 Singular interactive mode starts up.") 83 ;;}}} 84 85 ;;{{{ Singular Interactive Mode 81 86 (defun singular-interactive-mode () 82 87 "Major mode for interacting with Singular. 83 88 84 \\[comint-send-input] after the end of Singular's output sends the text from the 85 end of process to the end of the current line. 86 87 \\[comint-send-input] before end of Singular's output copies the current line minus 88 the prompt to the end of the buffer and sends it 89 \(\\[comint-copy-old-input] just copies the current line). 89 NOT READY [how to send input]! 90 90 91 91 NOT READY [multiple Singulars]! 92 92 93 Singular buffers are automatically limited in length \(by default, 94 to 2048 lines). This limit may be adjusted by setting 95 `singular-buffer-maximum-size'. 93 Singular buffers are automatically limited in length \(by default, to 94 2048 lines). This limit may be adjusted by setting 95 `singular-buffer-maximum-size' before Singular interactive mode starts 96 up or by setting `comint-buffer-maximum-size' while Singular 97 interactive mode is running. 96 98 97 99 NOT READY [much more to come. See shell.el.]!" 98 100 (interactive) 99 (comint-mode) 101 ;; we do not run `comint-mode' because `make-comint' should 102 ;; have run it already 103 ;; (comint-mode) 100 104 101 105 ;; miscellaneous 102 106 (setq major-mode 'singular-interactive-mode) 103 (setq mode-name "Singular ")107 (setq mode-name "Singular Interactive") 104 108 (use-local-map singular-interactive-mode-map) 105 (make-local-variable 'singular-debug)106 109 107 110 ;; customize comint for Singular … … 110 113 (setq comint-input-ignoredups singular-input-ignoredups) 111 114 (make-local-variable 'comint-buffer-maximum-size) 112 (make-local-variable 'singular-buffer-maximum-size)113 115 (setq comint-buffer-maximum-size singular-buffer-maximum-size) 114 116 (setq comint-input-ring-size singular-input-ring-size) 117 (or (memq 'comint-truncate-buffer comint-output-filter-functions) 118 (setq comint-output-filter-functions 119 (cons 'comint-truncate-buffer comint-output-filter-functions))) 115 120 116 121 ;; get name of history file (if any) … … 128 133 (defvar singular-start-file "~/.emacs_singularrc" 129 134 "Name of start-up file to pass to Singular. 130 If the file named by this variable exists it is given as 131 initial input to any Singular process being started \(Note that 132 this may lose due to a timing error if Singular discards input 133 when it starts up.)") 135 If the file named by this variable exists it is given as initial input 136 to any Singular process being started. Note that this may lose due to 137 a timing error if Singular discards input when it starts up.") 134 138 135 139 (defvar singular-default-executable "Singular" 136 "Default name of Singular executable.") 140 "Default name of Singular executable. 141 Used by `singular' when new Singular processes are started.") 137 142 138 143 (defvar singular-default-name "singular" 139 "Default process name for Singular process.") 144 "Default process name for Singular process. 145 Used by `singular' when new Singular processes are started.") 140 146 141 147 (defvar singular-default-switches '("-t") 142 "List of switches to pass to Singular processes on startup.") 148 "Default switches for Singular processes. 149 Used by `singular' when new Singular processes are started.") 143 150 144 151 (defun singular-exit-sentinel (process message) 145 152 "Clean up after termination of Singular. 146 Writes back input ring after regular termination of Singular 147 ifprocess buffer is still alive."153 Writes back input ring after regular termination of Singular if 154 process buffer is still alive." 148 155 (save-excursion 149 156 (singular-debug 'interactive 150 (message "Sentinel : %s" (substring message 0 -1)))157 (message "Sentinel message: %s" (substring message 0 -1))) 151 158 (if (string-match "finished\\|exited" message) 152 159 (let ((process-buffer (process-buffer process))) 153 (and process-buffer 154 (buffer-name process-buffer) 155 (set-buffer process-buffer) 156 (comint-write-input-ring)))))) 160 (if (and process-buffer 161 (buffer-name process-buffer) 162 (set-buffer process-buffer)) 163 (progn 164 (singular-debug 'interactive (message "Writing input ring back")) 165 (comint-write-input-ring))))))) 157 166 158 167 (defun singular (&optional singular-executable singular-name singular-switches) 159 168 "Run an inferior Singular process, with I/O through an Emacs buffer. 160 169 161 NOT READY [arguments and interactive use]!170 NOT READY [arguments, default values, and interactive use]! 162 171 163 172 If buffer exists but Singular is not running, start new Singular. 164 173 If buffer exists and Singular is running, just switch to buffer. 165 If a file `~/.emacs_singularrc' exists, it is given as initial 166 input \(Note that this may lose due to a timing error if Singular 167 discards input when it starts up.) 168 The buffer is put in Singular interactive mode, giving commands 169 for sending input and handling ouput of Singular. See 174 If a file `~/.emacs_singularrc' exists, it is given as initial input. 175 Note that this may lose due to a timing error if Singular discards 176 input when it starts up. 177 178 The buffer is put in Singular interactive mode, giving commands for 179 sending input and handling ouput of Singular. See 170 180 `singular-interactive-mode'. 171 181 172 \(Type \\[describe-mode] in the Singular buffer for a list of commands.)" 182 Type \\[describe-mode] in the Singular buffer for a list of commands." 183 ;; handle interactive calls 173 184 (interactive (list singular-default-executable 174 185 singular-default-name 175 186 singular-default-switches)) 176 ;; make buffer name canonical 187 177 188 (let* (;; get default values for optional arguments 178 189 (singular-executable (or singular-executable … … 201 212 (defalias 'Singular 'singular) 202 213 ;;}}} 214 ;;}}} 203 215 204 216 (provide 'singular)
Note: See TracChangeset
for help on using the changeset viewer.