[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fun with *zwei-comtab*



In article <900625122321.891820@DOCKMASTER.NCSC.MIL> Arbaugh@DOCKMASTER.NCSC.MIL writes:
>
>I'm using a Sun with the UX board and like it a great deal.  There is
>one nagging problem, however.  In zmacs, the line feed key acts as the
>line key.  This key is to small- so I normally end up hitting return and
>then tab.  In my attempts to reduce keystrokes, I've tried the
>following:
>
>Set package zwei ;; Note I'll use a $ instead of a sharp sign- mulitcs
>doesn't like sharps (set-comtab *zmacs-comtab* '($\line com-insert-crs))
>(set-comtab *zmacs-comtab* '($\return com-indent-new-line)) ;; This
>basically should switch the two keys- or am I doing something silly?  ;;
>When I move to zmacs and hit $\return- I end up in the debugger with ;;
>an error I can't remember at the moment.  ;; If I hit $\line, no
>problem.  It works like it should, i.e.  $\return.
>
>Any ideas?  And no- I don't want to buy a symbolics keyboard for the
>sun.
>
>                   Many thanks, Bill

BILL

The problem seems to be that ZMACS handles RETURN in a special way.

But, don't despair.  Following is a hack that I wrote for a friend who
wanted the same functionality.  RETURN-TAB-MODE is minor mode in which the
(standard) functionality of RETURN and LINEFEED are exchanged.

(I originally wrote it in ~7.0, but it still seems to work in 8.0)

Hope this helps
NICHAEL

;;; -*- Syntax: Zetalisp; Mode: LISP; Package: ZWEI; Base: 8 -*-
(defminor COM-RETURN-TAB-MODE RETURN-TAB-MODE "ReturnTab" 6
	  "Return-and-Tab mode.
Reverses the normal behavior of <RETURN> and <LINE>." ()
  (set-comtab *MODE-COMTAB* '(#\Return COM-INDENT-NEW-LINE-IN-RETURN-TAB-MODE
			      #\Line COM-INSERT-CRS)))

;;; Hacked version of COM-INDENT-NEW-LINE to make it compatible
;;; with RETURN-TAB-MODE.
(DEFCOM COM-INDENT-NEW-LINE-IN-RETURN-TAB-MODE
	"Starts a new line, indenting the new line as appropriate for the major mode.
For modes in which comments have explicit end strings, you can use this command
before the end of the comment and the comment end does not move to the new line." ()
  (WHEN (FIND-COMMENT-START (BP-LINE (POINT)))	;only when there is a comment on this line
    (LET ((CANDIDATE (STRING-TRIM '(#\SPACE #\TAB)	;survive some random spaces
				  (SUBSTRING (BP-LINE (POINT)) (BP-INDEX (POINT))))))
      (IF (AND (> (STRING-LENGTH *COMMENT-END*) 0)	;only when nontrivial comment ender
	       (STRING-EQUAL CANDIDATE *COMMENT-END*))	;does remainder of line match?
	  (MOVE-POINT (END-LINE (POINT))))))		;so fool it by moving point to end
  (MOVE-POINT (DELETE-BACKWARD-OVER *BLANKS* (POINT)))
  (LET ((*LAST-COMMAND-TYPE* 'INDENT-NEW-LINE)
	*CURRENT-COMMAND-TYPE*)			;Don't be fooled
    (MAX (IF *INDENT-NEW-LINE-NEW-LINE-FUNCTION*
	     (FUNCALL *INDENT-NEW-LINE-NEW-LINE-FUNCTION*)
	   ;;;NLC24MAR88 (KEY-EXECUTE #\RETURN *NUMERIC-ARG-P* *NUMERIC-ARG*)
	   (KEY-EXECUTE #\Line *NUMERIC-ARG-P* *NUMERIC-ARG*))
	 (IF *INDENT-NEW-LINE-INDENT-FUNCTION*
	     (LET ((*NUMERIC-ARG-P*) (*NUMERIC-ARG* 1))
	       (FUNCALL *INDENT-NEW-LINE-INDENT-FUNCTION*))
	   (KEY-EXECUTE #\TAB)))))