;; The licence of this software is GPL version 3 ;;---------------------- Closing parens, lispm style : ;; To evaluate any sexp inside the *inferior-lisp* buffer by simply closing the paren (require 'inf-lisp) ; First, an auxiliar function : (defun lispmstyle-unbalanced-parens () "Simplified version of the original check-parens function in file lisp.el" (interactive) (condition-case data (scan-sexps (marker-position (process-mark (get-buffer-process (current-buffer)))) (point-max)) (scan-error () t) (error t))) ; The main part : (defun lispmstyle-close-paren (&optional N) "If the closing paren being written completes a sexp, it is directly sent for evaluation without using the return key." (interactive "P") (if (not N) (setq N 1)) (self-insert-command N) (if (not (lispmstyle-unbalanced-parens)) (comint-send-input))) ;; Now that the command has been defined, it is assigned to close-paren : (define-key inferior-lisp-mode-map ")" 'lispmstyle-close-paren) ; It is also necessary to redefine the function of the return key ; to make it work well with the altered closing paren. (defun lispmstyle-return (&optional N) "For sending to the lisp inferior process sexps instead of lines." (interactive "P") (if (not N) (setq N 1)) (if (lispmstyle-unbalanced-parens) (cond ((functionp 'newline-and-indent-lisp) (dotimes (i N) (newline-and-indent-lisp))) ((functionp 'newline-and-indent) (dotimes (i N) (newline-and-indent))) (t (dotimes (i N) (newline)))) (progn ; This would not seem necessary, but beware it is. (goto-char (point-max)) (comint-send-input)))) ;; Now that the command has been defined, it is assigned to the return key : (define-key inferior-lisp-mode-map "\r" 'lispmstyle-return) ;;---------------------- End of closing parens lispm style.