[GAP Forum] Gap Emacs mode

aker at gursey.gov.tr aker at gursey.gov.tr
Tue Nov 17 13:30:02 GMT 2009


Hello,

Thanks for the code. I would definitely benefit from an emacs mode for GAP
with more functionality.

The code is not fully working, unfortunately. I think you have some other
related code, which it is looking for.

I have added your code to gap-mode.el.
When I tried it, this is what happened:

I have tried these command with these key bindings. The first and the last
worked properly.

> (define-key gap-mode-map "\C-c\C-s" 'nea-send-string-to-gap)
> (define-key gap-mode-map "\C-c\C-l" 'nea-send-line-to-gap)
> (define-key gap-mode-map "\C-c\C-r" 'nea-send-region-to-gap)
> (define-key gap-mode-map "\C-c\C-f" 'nea-send-region-to-gap-as-file)
> (define-key gap-mode-map "\C-ci" 'nea-ins-gap)

For 2,3,4, I got the following error messages (with the same order).

;nea-send-line-to-gap: Symbol's function definition is void:  
send-region-to-gap

;Symbol's function definition is void: send-string-to-gap

;nea-send-region-to-gap-as-file: Symbol's function definition is void:
send-string-to-gap-normally

I guess I am missing some functions here. If I have them, I think it will work
fine.

Thanks a lot, this was really helpful,

kursat

Quoting Nikos Apostolakis <nikos.ap at gmail.com>:

>
> On Tue, Nov 17, 2009 at 10:32:33AM +0200, thus spake aker at gursey.gov.tr:
>> Hello,
>>
>> I am using Emacs mode for Gap.
>>
>> The only way I know to send the file I work to gap-mode is
>>
>> C-u M-x gap
>>
>> This sends the whole file to gap-mode and executes it.
>>
>> I have used Maple via an emacs mode which I have got from
>>
>> http://www.mapleprimes.com/blog/joe-riel/emacs-mode-for-maple
>>
>> In this Maple mode, it was possible to send a single line to maple mode,
>> a region, or a function, or buffer etc. Among the features were
>> highlighting...
>>
>> Does the emacs mode for gap do these?
>>
>
> No.  I think that a modern gap mode that has these features would be a
> great idea.
>
>> Or, does anyone have his version of these features?
>>
>
>
> Well, I use the following hack.  I'm not exactly an elisp expert so I'm sure
> there is a better way of doing this but you may find the following useful:
>
> -- 8< -------- Begin Elisp code
>
> (defun nea-send-string-to-gap (string)
>   "Send the the string to an already running gap process. The output is
> displayed in the process' buffer."
> (interactive "sString to send to GAP (Include final \`;\')")
>   (set-process-filter (get-process "gap") 'gap-output-filter)
>     (save-window-excursion
>     (set-buffer "*gap*")
>     (goto-char (point-max))
>     (process-send-string "gap" (concat string  "\n"))))
>
>
> ;; The name of the temp file should probably be randomly chosen.
> ;;; Haven't really used this command much.
> (defun nea-send-region-to-gap-as-file (begin end)
>   "Have GAP read the contents of the region as a file."
>   (interactive "r")
>   (let ((temp-gap-file "/tmp/tmp.gap"))
>     (write-region  begin end temp-gap-file)
>     (send-string-to-gap-normally (concat "Read(\"" temp-gap-file "\");\n"))))
>
>
> (defun nea-send-region-to-gap (begin end &optional arg)
>   "Send region to gap."
>   (interactive "r\nP")
>   (let ((string (buffer-substring begin end)))
>     (save-window-excursion
>     (set-buffer "*gap*")
>     (goto-char (point-max))
>     (send-string-to-gap string arg))))
>
>
> (defun nea-send-line-to-gap (&optional arg)
>   "Send current line to GAP."
>   (interactive "P")
>   (send-region-to-gap (line-beginning-position) (line-end-position) arg))
>
>
> (defun nea-get-last-gap-output ()
>   "Scrap the last output from the gap buffer"
>   (interactive)
>   (save-excursion
>     (set-buffer "*gap*")
>     (let ((pt (point))
> 	  (pmark (progn (goto-char (process-mark (get-buffer-process "*gap*")))
> 			(forward-line 0)
> 			(point-marker)))
> 	  output)
>       (goto-char pmark)
>       (search-backward-regexp gap-prompt-regexp nil t)
>       (forward-line 1)
>       (setq output (buffer-substring-no-properties
> 		    (point) pmark))
>     (goto-char pt)
>     output)))
>
>
>
> ;; The following is an example of how to use nea-get-last-gap-output
> (defun nea-ins-gap ()
>   "Insert the last output in buffer."
>   (interactive)
>   (end-of-line)
>   (let ((string (nea-get-last-gap-output)))
>     (if (string-match "
> ." (nea-get-last-gap-output))
> 	(setq string (format "\n#==>\n %s;\n#<==" string))
>       (setq string (format " #==> %s" string )))
>     (insert string)))
>
>
> ;; I use the following key bindings:
>
> (define-key gap-mode-map "\C-c\C-s" 'nea-send-string-to-gap)
> (define-key gap-mode-map "\C-c\C-l" 'nea-send-line-to-gap)
> (define-key gap-mode-map "\C-c\C-r" 'nea-send-region-to-gap)
> (define-key gap-mode-map "\C-c\C-f" 'nea-send-region-to-gap-as-file)
> (define-key gap-mode-map "\C-ci" 'nea-ins-gap)
>
> -- 8< -------- End Elisp code
>
>> Thanks a lot,
>>
>> kursat
>



----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.





More information about the Forum mailing list