unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* user-friendly improvements to the cmuscheme library
@ 2005-01-06 18:54 Emilio Lopes
  2005-01-06 23:08 ` Thien-Thi Nguyen
  0 siblings, 1 reply; 4+ messages in thread
From: Emilio Lopes @ 2005-01-06 18:54 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 1007 bytes --]

The attached patch to "cmuscheme.el" makes editing of Scheme files, as
I see, more user friendly.

The first change introduces an user option to control whether the Scheme
process buffer should be automatically displayed upon evaluation of
Scheme code by the user, thus making the results of the evaluation
visible.  The default value of this option is `nil', so that the current
behavior is preserved.

The second set of changes offers the user to start a Scheme interpreter if
she tries to evaluates Scheme code without having started an interpreter
before.  Right now Emacs just raises an error in this case.

2005-01-06  Emilio C. Lopes  <eclig@gmx.net>

	* cmuscheme.el (scheme-display-buffer-on-eval): new user option.
	(scheme-send-region): display process buffer, if desired.
	(scheme-display-process-buffer): new function.
	(switch-to-scheme): start new scheme process, if none found.
	(scheme-proc): dito.
	(scheme-get-process): new function.
	(scheme-interactively-start-process): new function.


[-- Attachment #2: diffs to cmuscheme --]
[-- Type: text/plain, Size: 4178 bytes --]

Index: lisp/cmuscheme.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/cmuscheme.el,v
retrieving revision 1.36
diff -u -c -r1.36 cmuscheme.el
*** lisp/cmuscheme.el	19 Sep 2004 02:14:14 -0000	1.36
--- lisp/cmuscheme.el	6 Jan 2005 17:58:23 -0000
***************
*** 109,114 ****
--- 109,118 ----
    :type 'hook
    :group 'cmuscheme)
  
+ (defcustom scheme-display-buffer-on-eval nil
+   "*Non nil means display the Scheme process buffer when evaluating code."
+   :group 'scheme :type 'boolean)
+ 
  (defvar inferior-scheme-mode-map
    (let ((m (make-sparse-keymap)))
      (define-key m "\M-\C-x" 'scheme-send-definition) ;gnu convention
***************
*** 257,263 ****
    "Send the current region to the inferior Scheme process."
    (interactive "r")
    (comint-send-region (scheme-proc) start end)
!   (comint-send-string (scheme-proc) "\n"))
  
  (defun scheme-send-definition ()
    "Send the current definition to the inferior Scheme process."
--- 261,277 ----
    "Send the current region to the inferior Scheme process."
    (interactive "r")
    (comint-send-region (scheme-proc) start end)
!   (comint-send-string (scheme-proc) "\n")
!   (when scheme-display-buffer-on-eval
!     (scheme-display-process-buffer)))
! 
! (defun scheme-display-process-buffer ()
!   "Display the Scheme process buffer.
! This function ignores `same-window-buffer-names'."
!   (let ((same-window-buffer-names nil))
!     (display-buffer scheme-buffer)
!     (set-window-point (get-buffer-window scheme-buffer)
!                       (process-mark (scheme-proc)))))
  
  (defun scheme-send-definition ()
    "Send the current definition to the inferior Scheme process."
***************
*** 300,311 ****
    "Switch to the scheme process buffer.
  With argument, position cursor at end of buffer."
    (interactive "P")
!   (if (get-buffer scheme-buffer)
        (pop-to-buffer scheme-buffer)
!       (error "No current process buffer.  See variable `scheme-buffer'"))
!   (cond (eob-p
! 	 (push-mark)
! 	 (goto-char (point-max)))))
  
  (defun scheme-send-region-and-go (start end)
    "Send the current region to the inferior Scheme process.
--- 314,326 ----
    "Switch to the scheme process buffer.
  With argument, position cursor at end of buffer."
    (interactive "P")
!   (if (or (get-buffer scheme-buffer)
!           (scheme-interactively-start-process))
        (pop-to-buffer scheme-buffer)
!     (error "No current process buffer.  See variable `scheme-buffer'"))
!   (when eob-p
!     (push-mark)
!     (goto-char (point-max))))
  
  (defun scheme-send-region-and-go (start end)
    "Send the current region to the inferior Scheme process.
***************
*** 417,429 ****
  for a minimal, simple implementation.  Feel free to extend it.")
  
  (defun scheme-proc ()
!   "Return the current scheme process.  See variable `scheme-buffer'."
!   (let ((proc (get-buffer-process (if (eq major-mode 'inferior-scheme-mode)
! 				      (current-buffer)
! 				      scheme-buffer))))
!     (or proc
! 	(error "No current process.  See variable `scheme-buffer'"))))
! 
  
  ;;; Do the user's customisation...
  
--- 432,456 ----
  for a minimal, simple implementation.  Feel free to extend it.")
  
  (defun scheme-proc ()
!   "Return the current Scheme process, starting one if necessary.
! See the variable `scheme-buffer' for details."
!   (or (scheme-get-process)
!       (scheme-interactively-start-process)
!       (error "No current process.  See variable `scheme-buffer'")))
! 
! (defun scheme-get-process ()
!   "Return the current Scheme process or nil if none is running."
!   (get-buffer-process (if (eq major-mode 'inferior-scheme-mode)
!                           (current-buffer)
!                         scheme-buffer)))
! 
! (defun scheme-interactively-start-process (&optional cmd)
!   "Start an inferior Scheme process.  Return the process started.
! Since this command is run implicitly, always ask the user for the
! command to run."
!   (save-window-excursion
!     (run-scheme (read-string "Run Scheme: " scheme-program-name)))
!   (scheme-get-process))
  
  ;;; Do the user's customisation...
  

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: user-friendly improvements to the cmuscheme library
  2005-01-06 18:54 user-friendly improvements to the cmuscheme library Emilio Lopes
@ 2005-01-06 23:08 ` Thien-Thi Nguyen
  2005-01-07 11:59   ` Emilio Lopes
  0 siblings, 1 reply; 4+ messages in thread
From: Thien-Thi Nguyen @ 2005-01-06 23:08 UTC (permalink / raw)
  Cc: emacs-devel

   From: Emilio Lopes <eclig@gmx.net>
   Date: Thu, 06 Jan 2005 19:54:43 +0100

   The first change introduces an user option to control whether the
   Scheme process buffer should be automatically displayed upon
   evaluation of Scheme code by the user, thus making the results of the
   evaluation visible.  The default value of this option is `nil', so
   that the current behavior is preserved.

have you considered using the variables and hooks associated w/
comint.el to effect this behavior?  apropos on comint.*function shows:

comint-input-filter-functions
  Variable: Functions to call before input is sent to the process.
  Plist: variable-documentation permanent-local

among other things.  (another variable in cmuscheme.el is harmless, but
IMHO it is more elegant to make use of existing facilities.)

   The second set of changes offers the user to start a Scheme
   interpreter if she tries to evaluates Scheme code without having
   started an interpreter before.  Right now Emacs just raises an error
   in this case.

and errors are not user-friendly?!  (just kidding.)  i think this is a
good feature to add.

thi

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: user-friendly improvements to the cmuscheme library
  2005-01-06 23:08 ` Thien-Thi Nguyen
@ 2005-01-07 11:59   ` Emilio Lopes
  2005-01-07 14:48     ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Emilio Lopes @ 2005-01-07 11:59 UTC (permalink / raw)


Thien-Thi Nguyen <ttn <at> glug.org> wrote:

> Emilio Lopes wrote:
> 
>> The first change introduces an user option to control whether the
>> Scheme process buffer should be automatically displayed upon
>> evaluation of Scheme code by the user, thus making the results of the
>> evaluation visible.  The default value of this option is `nil', so
>> that the current behavior is preserved.
> 
> have you considered using the variables and hooks associated w/
> comint.el to effect this behavior?  apropos on comint.*function shows:
> 
> comint-input-filter-functions
> [...]

This doesn't work.  The functions in `comint-input-filter-functions'
are not run when input comes from another buffer sent by a
function, only when it's sent by the user directly in the
comint/Scheme process buffer.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: user-friendly improvements to the cmuscheme library
  2005-01-07 11:59   ` Emilio Lopes
@ 2005-01-07 14:48     ` Stefan Monnier
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2005-01-07 14:48 UTC (permalink / raw)
  Cc: emacs-devel

>>> The first change introduces an user option to control whether the
>>> Scheme process buffer should be automatically displayed upon
>>> evaluation of Scheme code by the user, thus making the results of the
>>> evaluation visible.  The default value of this option is `nil', so
>>> that the current behavior is preserved.
>> 
>> have you considered using the variables and hooks associated w/
>> comint.el to effect this behavior?  apropos on comint.*function shows:
>> 
>> comint-input-filter-functions
>> [...]

I don't think that putting this window-manipulation code in
comint-input-filter-functions is a good idea.


        Stefan

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-01-07 14:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-01-06 18:54 user-friendly improvements to the cmuscheme library Emilio Lopes
2005-01-06 23:08 ` Thien-Thi Nguyen
2005-01-07 11:59   ` Emilio Lopes
2005-01-07 14:48     ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).